CHAPTER 11 ARITHMETIC AND LOGIC UNIT
102
11.7 ROTATIONS
There are rotation instructions for rotation to the right and for rotation to the left.
The RORC instruction is used for rotation to the right.
The RORC instruction can only be used with the general register.
Rotation using the RORC instruction is not affected by the BCD or CMP flags in the program status word (PSWORD)
and does not affect the Z flag in the program status word (PSWORD).
Rotation to the left is performed by using the addition instruction ADDC.
11.7.1
and
11.7.2
explain rotation.
11.7.1 Rotation to the Right
The instruction used for rotation to the right (RORC r) rotates the contents of the general register in the direction
of its least significant bit.
When this instruction is executed, the contents of the CY flag becomes the most significant bit of the general
register (bit 3) and the least significant bit of the general register is placed in the CY flag.
Example
1.
MOV
PSW,
#0100B ; Sets CY flag to 1.
MOV
R1,
#1100B
RORC R1
When these instructions are executed, the following operation is performed.
Basically, when rotation to the right is performed, the following operation is executed:
CY flag
→
b
3
, b
3
→
b
2
, b
2
→
b
1
, b
1
→
b
0
, b
∞
→
CY flag.
2.
MOV
PSW,
#0000B ; Resets CY flag to 0.
MOV
R1,
#1000B
MOV
R2,
#0100B
MOV
R3,
#0010B
RORC R1
RORC R2
RORC R3
The program code above rotates the 13 bits in CY, R1, R2 and R3 to the right.
CY flag
b
3
b
2
b
1
b
0
1
1
1
0
0
Summary of Contents for mPD17120 Subseries
Page 15: ... x MEMO ...
Page 23: ... MEMO 8 ...
Page 45: ... MEMO 30 ...
Page 49: ... MEMO 34 ...
Page 55: ... MEMO 40 ...
Page 93: ... MEMO 78 ...
Page 99: ... MEMO 84 ...
Page 102: ...CHAPTER 11 ARITHMETIC AND LOGIC UNIT 87 MEMO ...
Page 119: ... MEMO 104 ...
Page 175: ... MEMO 160 ...
Page 199: ... MEMO 184 ...
Page 265: ... MEMO 250 ...
Page 281: ...266 MEMO ...
Page 285: ... MEMO 270 ...
Page 289: ... MEMO 274 ...