This the multi-page printable view of this section.Click here to print.

Return to the regular view of this page.

Rotate and Shift

Rotate Shift instructions

Table of Contents

1 - RL Rotate bits left with Carry

Rotate bits left with carry
Visualisation of the RLA instruction
76543210
 
RLA
0001011117
 
RL r
11001011CB
00010r
 
RL (HL)
11001011CB
0001011016
 
RL (IX+d)
11011101DD
11001011CB
d
0001011016
 
RL (IY+d)
11111101FD
11001011CB
d
0001011016
Registers
Registerr
B000
C001
D010
E011
H100
L101
A111
Flags Affected
Flags
sz-h-p/v-c
sset if result negative
zset if result is 0
hreset
p/vset if parity even, reset if parity odd
cdata from bit 7 of source register
Opcode Matrix
ABCDEHL(HL)(IX+d)(IY+d)
RL
RLA
1714









RL
RL A
CB1728
RL B
CB1028
RL C
CB1128
RL D
CB1228
RL E
CB1328
RL H
CB1428
RL L
CB1528
RL (HL)
CB16215
RL (IX+d)
DDCBnn16423
RL (IY+d)
FDCBnn16423
Opcode Matrix Legend
Instruction Opcode hexSize bytesCycle count
 Register Memory

2 - RLC Rotate bits left with Carry

Rotate bits left with carry
Visualisation of the RLC instruction
76543210
 
RLCA
0000011107
 
RLC r
11001011CB
00000r
 
RLC (HL)
11001011CB
0000011006
 
RLC (IX+d)
11011101DD
11001011CB
d
0000011006
 
RLC (IY+d)
11111101FD
11001011CB
d
0000011006
Registers
Registerr
B000
C001
D010
E011
H100
L101
A111
Flags Affected
Flags
sz-h-p/v-c
sset if result negative
zset if result is 0
hreset
p/vset if parity even, reset if parity odd
cdata from bit 7 of source register
Opcode Matrix
ABCDEHL(HL)(IX+d)(IY+d)
RLC
RLCA
0714









RLC
RLC A
CB0728
RLC B
CB0028
RLC C
CB0128
RLC D
CB0228
RLC E
CB0328
RLC H
CB0428
RLC L
CB0528
RLC (HL)
CB0628
RLC (IX+d)
DDCBnn06423
RLC (IY+d)
FDCBnn06423
Opcode Matrix Legend
Instruction Opcode hexSize bytesCycle count
 Register Memory

3 - RR Rotate bits right with Carry

Rotate bits right with carry
Visualisation of the RRA instruction
76543210
 
RRA
000111111F
 
RR r
11001011CB
00011r
 
RR (HL)
11001011CB
000111101E
 
RR(IX+d)
11011101DD
11001011CB
d
000111101E
 
RR (IY+d)
11111101FD
11001011CB
d
000111101E
Registers
Registerr
B000
C001
D010
E011
H100
L101
A111
Flags Affected
Flags
sz-h-p/v-c
sset if result negative
zset if result is 0
hreset
p/vset if parity even, reset if parity odd
cdata from bit 0 of source register
Opcode Matrix
ABCDEHL(HL)(IX+d)(IY+d)
RR
RRA
1F14









RR
RR A
CB1F28
RR B
CB1828
RR C
CB1928
RR D
CB1A28
RR E
CB1B28
RR H
CB1C28
RR L
CB1D28
RR (HL)
CB1E215
RR (IX+d)
DDCBnn1E423
RR (IY+d)
FDCBnn1E423
Opcode Matrix Legend
Instruction Opcode hexSize bytesCycle count
 Register Memory

4 - RRC Rotate bits right with Carry

Rotate bits left with carry
Visualisation of the RRC instruction
76543210
 
RRCA
000011110F
 
RRC r
11001011CB
00001r
 
RRC (HL)
11001011CB
000011100E
 
RRC (IX+d)
11011101DD
11001011CB
d
000011100E
 
RRC (IY+d)
11111101FD
11001011CB
d
000011100E
Registers
Registerr
B000
C001
D010
E011
H100
L101
A111
Flags Affected
Flags
sz-h-p/v-c
sset if result negative
zset if result is 0
hreset
p/vset if parity even, reset if parity odd
cdata from bit 0 of source register
Opcode Matrix
ABCDEHL(HL)(IX+d)(IY+d)
RRC
RRCA
0F14









RRC
RRC A
CB0F28
RRC B
CB0828
RRC C
CB0928
RRC D
CB0A28
RRC E
CB0B28
RRC H
CB0C28
RRC L
CB0D28
RRC (HL)
CB0E215
RRC (IX+d)
DDCBnn0E423
RRC (IY+d)
FDCBnn0E423
Opcode Matrix Legend
Instruction Opcode hexSize bytesCycle count
 Register Memory

5 - SLA Shift bits left with Carry

Shift bits left with carry
Visualisation of the SLA instruction
76543210
 
SLA r
11001011CB
00100r
 
SLA (HL)
11001011CB
0010011026
 
SLA (IX+d)
11011101DD
11001011CB
d
0010011026
 
SLA (IY+d)
11111101FD
11001011CB
d
0010011026
Registers
Registerr
B000
C001
D010
E011
H100
L101
A111
Flags Affected
Flags
sz-h-p/v-c
sset if result negative
zset if result is 0
hreset
p/vset if parity even, reset if parity odd
cdata from bit 7 of source register
Opcode Matrix
ABCDEHL(HL)(IX+d)(IY+d)
SLA
SLA A
CB2728
SLA B
CB2028
SLA C
CB2128
SLA D
CB2228
SLA E
CB2328
SLA H
CB2428
SLA L
CB2528
SLA (HL)
CB26215
SLA (IX+d)
DDCBnn26423
SLA (IY+d)
FDCBnn26423
Opcode Matrix Legend
Instruction Opcode hexSize bytesCycle count
 Register Memory

6 - SRA Rotate bits right with Carry

Rotate bits right with carry, bit 7 remains unchanged
Visualisation of the SRA instruction

An arithmetic shift right 1 bit position is performed on the contents of operand. The contents of bit 0 are copied to the Carry flag and the previous contents of bit 7 remain unchanged.

76543210
 
SRA r
11001011CB
00101r
 
SRA (HL)
11001011CB
001011102E
 
SRA (IX+d)
11011101DD
11001011CB
d
001011102E
 
SRA (IY+d)
11111101FD
11001011CB
d
001011102E
Registers
Registerr
B000
C001
D010
E011
H100
L101
A111
Flags Affected
Flags
sz-h-p/v-c
sset if result negative
zset if result is 0
hreset
p/vset if parity even, reset if parity odd
cdata from bit 0 of source register
Opcode Matrix
ABCDEHL(HL)(IX+d)(IY+d)
SRA
SRA A
CB2F28
SRA B
CB2828
SRA C
CB2928
SRA D
CB2A28
SRA E
CB2B28
SRA H
CB2C28
SRA L
CB2D28
SRA (HL)
CB2E215
SRA (IX+d)
DDCBnn2E423
SRA (IY+d)
FDCBnn2E423
Opcode Matrix Legend
Instruction Opcode hexSize bytesCycle count
 Register Memory

7 - SRL Rotate bits right with Carry

Rotate bits right with carry, bit 7 is reset
Visualisation of the SRL instruction
76543210
 
SRL r
11001011CB
00111r
 
SRL (HL)
11001011CB
001111103E
 
SRL (IX+d)
11011101DD
11001011CB
d
001111103E
 
SRL (IY+d)
11111101FD
11001011CB
d
001111103E
Registers
Registerr
B000
C001
D010
E011
H100
L101
A111
Flags Affected
Flags
sz-h-p/v-c
sset if result negative
zset if result is 0
hreset
p/vset if parity even, reset if parity odd
cdata from bit 0 of source register
Opcode Matrix
ABCDEHL(HL)(IX+d)(IY+d)
SRL
SRL A
CB3F28
SRL B
CB3828
SRL C
CB3928
SRL D
CB3A28
SRL E
CB3B28
SRL H
CB3C28
SRL L
CB3D28
SRL (HL)
CB3E215
SRL (IX+d)
DDCBnn3E423
SRL (IY+d)
FDCBnn3E423
Opcode Matrix Legend
Instruction Opcode hexSize bytesCycle count
 Register Memory

8 - RLD

Rotate bit pairs in A and (HL) left
Visualisation of the RLD instruction
76543210
11101101ED
011011116F

The contents of the low-order four bits (bits 3, 2, 1, and 0) of the memory location (HL) are copied to the high-order four bits (7, 6, 5, and 4) of that same memory location; the previous contents of those high-order four bits are copied to the low-order four bits of the Accumulator (Register A); and the previous contents of the low-order four bits of the Accumulator are copied to the low-order four bits of memory location (HL). The contents of the high-order bits of the Accumulator are unaffected.

Flags Affected
Flags
sz-h-p/v--
sset if result negative
zset if result is 0
hreset
p/vset if parity even, reset if parity odd
Opcode Matrix
(HL)
Op
RLD (HL)
ED6F218
Opcode Matrix Legend
Instruction Opcode hexSize bytesCycle count
 Memory

9 - RRD

Rotate bit pairs in A and (HL) right
Visualisation of the RRD instruction
76543210
11101101ED
0110011167

The contents of the low-order four bits (bits 3, 2, 1, and 0) of memory location (HL) are copied to the low-order four bits of the Accumulator (Register A). The previous contents of the low-order four bits of the Accumulator are copied to the high-order four bits (7, 6, 5, and 4) of location (HL); and the previous contents of the high-order four bits of (HL) are copied to the low-order four bits of (HL). The contents of the high-order bits of the Accumulator are unaffected.

Flags Affected
Flags
sz-h-p/v--
sset if result negative
zset if result is 0
hreset
p/vset if parity even, reset if parity odd
Opcode Matrix
(HL)
Op
RRD (HL)
ED67218
Opcode Matrix Legend
Instruction Opcode hexSize bytesCycle count
 Memory