Changes

Jump to: navigation, search

Z80 - undocumented opcodes

16 bytes removed, 02:13, 10 December 2012
/* CB prefix */
Of the 247 opcodes that use the prefix &CB, the block &CB &30 to &CB &37 is undocumented officially. These commands shift the operand register left and set its lowest bit to 1.
This is in contrast to SRL (Shift Right Logical), which shifts right and clears the highest bit. Some believe that this difference indicates why these opcodes are undocumented, feeling that this result represent represents a bug in the Z80 and that the operation was supposed to be Shift Left Logical, which would thus ''clear'' the lowest bit after shifting. Others call the opcodes SLIA, for Shift Left Inverted Arithmetic.
Regardless of the story behind this operation, its effective result of the operation is ''register'' = (''register'' * 2) + 1, something that does have its uses and has been employed in various programming contexts for that reason.
If you want a way to do an actual Shift Left Logical, ''i.e.'' ''register'' = ''register'' * 2, first ensure the carry is clear, inserting an OR A or AND A to achieve this if necessary, and then do an RL ''register''.
25
edits