Changes

Jump to: navigation, search

Z80 - undocumented opcodes

287 bytes removed, 07:25, 10 December 2012
/* CB prefix */ removing one bit I wrote as I'm pretty sure it's nonsense and SLA works fine
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 were supposed to be Shift Left Logical but that this result the setting of the lowest bit represents a bug in the Z80 and that the operation was supposed to be Shift Left Logical, which would thus ''clear'' claiming this is why the lowest bit after shiftingopcodes are undocumented. Others call the opcodes SLIA, for Shift Left Inverted Arithmetic.
Regardless of the story behind this operation, its effective result 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''.
<pre>CB30 SLL B
25
edits