diff options
-rw-r--r-- | Optimizing-assembly-code.md | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Optimizing-assembly-code.md b/Optimizing-assembly-code.md index 428add0..24bea11 100644 --- a/Optimizing-assembly-code.md +++ b/Optimizing-assembly-code.md @@ -20,6 +20,7 @@ WikiTI's advice fully applies here: - [Invert the bits of `a`](#invert-the-bits-of-a) - [Set `a` to some constant minus `a`](#set-a-to-some-constant-minus-a) - [Set `a` to one constant or another depending on the carry flag](#set-a-to-one-constant-or-another-depending-on-the-carry-flag) + - [Shift `a` right by 3 bits](#shift-a-right-by-3-bits) - [Multiply `hl` by 2](#multiply-hl-by-2) - [Add `a` to a 16-bit register](#add-a-to-a-16-bit-register) - [Add `a` to an address](#add-a-to-an-address) @@ -192,6 +193,28 @@ If `FOO` equals `BAR - 2`, then do: +### Shift `a` right by 3 bits + +Don't do: + +```asm + ; 6 bytes, 6 cycles + srl a + srl a + srl a +``` + +But do: + +```asm + ; 5 bytes, 5 cycles + rrca + rrca + rrca + and %00011111 +``` + + ### Multiply `hl` by 2 Don't do: |