Decoding CB Prefix
How the CB instruction prefix works
Instructions with the CB prefix consist of instructions that manipulate individual bits in a register or memory.
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | ||
---|---|---|---|---|---|---|---|---|---|
0 | 0 | 0 | 0 | 0 | x | x | x | RLC r | |
0 | 0 | 0 | 0 | 1 | x | x | x | RRC r | |
0 | 0 | 0 | 1 | 0 | x | x | x | RL | |
0 | 0 | 0 | 1 | 1 | x | x | x | RR | |
0 | 0 | 1 | 0 | 0 | x | x | x | SLA | |
0 | 0 | 1 | 0 | 1 | x | x | x | SRA | |
0 | 0 | 1 | 1 | 0 | x | x | x | SLL | |
0 | 0 | 1 | 1 | 1 | x | x | x | SRL | |
0 | 1 | x | x | x | x | x | x | BIT b,r | |
1 | 0 | x | x | x | x | x | x | RES b,r | |
1 | 1 | x | x | x | x | x | x | SET b,r |
Operations with IX and IY registers
The operations here which operator on the (HL)
register do also support use with the
IX
and IY
registers with a relative offset.
They are identical to the (HL)
operation but with a DD or
FD prefix.
Only instructions with the lower nibble set to 6 or E are documented. The other opcodes are undocumented.
Undocumented SLL instruction
Op codes CB30…CB37 are undocumented; but they do perform a shift left operation, placing a 1 in bit 0 and setting the carry flag to the original bit 7.
Last modified November 12, 2021: Change shortcode for the decoding tables (cd015a3)