summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Optimizing-assembly-code.md17
1 files changed, 15 insertions, 2 deletions
diff --git a/Optimizing-assembly-code.md b/Optimizing-assembly-code.md
index e2afc6f..8739c9b 100644
--- a/Optimizing-assembly-code.md
+++ b/Optimizing-assembly-code.md
@@ -228,11 +228,24 @@ But do:
rrca
```
-Or if you really want to optimize for size over speed, then do:
+Or if you really want to optimize for size over speed, then don't do:
+
+```asm
+ ; 10 bytes, 59 cycles
+ ld bc, 8 ; lb bc, 0, 8
+.loop
+ rra
+ rl b
+ dec c
+ jr nz, .loop
+ ld a, b
+```
+
+But do:
```asm
; 8 bytes, 50 cycles
- ld b, $01 ; loop finishes once this 1 shifts to carry
+ ld b, 1
.loop
rra
rl b