Category:Z80 Assembly: Difference between revisions
m
→Bit Shifting
Puppydrum64 (talk | contribs) m (→LDIR is slow: formatting) |
Puppydrum64 (talk | contribs) m (→Bit Shifting) |
||
Line 84:
RLCA ;6 bytes total</lang>
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.
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.)
<lang z80>rept 4 ;inline the following 4 times, back to back:
SRL H
RR L
endr
rept 4 ;this version is faster.
SRL H
RRA
endr</lang>
===Inlined bytecode===
|