diff options
Diffstat (limited to 'Optimizing-assembly-code.md')
| -rw-r--r-- | Optimizing-assembly-code.md | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Optimizing-assembly-code.md b/Optimizing-assembly-code.md index 4bda4b0..121a719 100644 --- a/Optimizing-assembly-code.md +++ b/Optimizing-assembly-code.md @@ -223,6 +223,23 @@ But do: xor b ``` +A slightly faster version of the above code that takes advantage of the `swap` opcode that exists on the GB but is missing on the Z80. (Adapted by nitro2k01.) + +``` + ; 15 bytes, 15 cycles + ld b, a + rlca + rlca + xor b + and $aa + xor b + ld b, a + swap b + xor b + and $33 + xor b + rrca +``` ### Set `a` to some constant minus `a` |
