Category:Z80 Assembly: Difference between revisions

removed unnecesary example
m (changed tags to display code correctly)
(removed unnecesary example)
Line 112:
Not only is the second method shorter, it's also faster. The accumulator-specific bit rotates take 1 byte and 4 clock cycles each. They are different, however, because unlike the two-byte versions, these <i>do not affect the zero flag.</i> This isn't a big deal, however, as more often than not if you're rotating the accumulator you're not expecting to get zero as the output anyway.
 
Correction: The <code>AND</code> <i>does</i> affect the Z flag. So the end result will be the same, right?
Note that the Z flag is preserved through the rotates. And zero rotated is still zero.
 
If you want to know zero or not, you could also use this:
<syntaxhighlight lang="Z80">
RLCA
RLCA
RLCA
RLCA
AND %11110000 ;6 bytes, 23 cycles total
</syntaxhighlight>
 
For 16-bit bit shifting, use A instead of the other half of the register pair for faster results (unless you're checking for equality to zero, or you need the accumulator for something else.)