summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Optimizing-assembly-code.md33
1 files changed, 17 insertions, 16 deletions
diff --git a/Optimizing-assembly-code.md b/Optimizing-assembly-code.md
index 791c7a6..cfeb403 100644
--- a/Optimizing-assembly-code.md
+++ b/Optimizing-assembly-code.md
@@ -182,20 +182,7 @@ The exception is if you need to set the zero flag when the operation results in
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
-```
-
-And don't do:
-
-```asm
-; 26 bytes, 26 cycles
+ ; 26 bytes, 26 cycles
rept 8
rra
rl b
@@ -206,7 +193,7 @@ endr
And don't do:
```asm
-; 17 bytes, 17 cycles
+ ; 17 bytes, 17 cycles
ld b, a
rlca
rlca
@@ -226,7 +213,7 @@ And don't do:
But do:
```asm
-; 15 bytes, 15 cycles
+ ; 15 bytes, 15 cycles
ld b, a
rlca
rlca
@@ -241,6 +228,20 @@ But do:
rrca
```
+Or if you really want to optimize for size over speed, then 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
+```
+
+
### Set `a` to some constant minus `a`
Don't do: