From 6ae7cdf4bb40aa1f43ec5946223ef4fd19bfddfe Mon Sep 17 00:00:00 2001 From: nitro2k01 Date: Thu, 26 Nov 2020 18:51:33 +0100 Subject: Added version of the bit reverse code adapter for GB. --- Optimizing-assembly-code.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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` -- cgit v1.2.3