diff options
author | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-03-14 18:05:55 -0400 |
---|---|---|
committer | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-03-14 18:05:55 -0400 |
commit | cc92a108567feabaf84d3450f68d08b817cd8a1f (patch) | |
tree | 2a0c952eb0610308a9e655e570128cf1cd7751c7 | |
parent | cd7db09433ebbb36c31ff6a5d10d37159c1ec715 (diff) |
srl a
-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: |