summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRangi <remy.oukaour+rangi42@gmail.com>2020-11-26 14:33:41 -0500
committerRangi <remy.oukaour+rangi42@gmail.com>2020-11-26 14:33:41 -0500
commit10b24652123a561282f8e77f6352cbef48de4d61 (patch)
tree0559c6c514dba3da61cd161e296e77ab152ad91b
parent1481cc2c1a7bdfcc026dba02facb33bc2d12099d (diff)
GF's bad example
-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