summaryrefslogtreecommitdiff
path: root/Optimizing-assembly-code.md
diff options
context:
space:
mode:
Diffstat (limited to 'Optimizing-assembly-code.md')
-rw-r--r--Optimizing-assembly-code.md26
1 files changed, 26 insertions, 0 deletions
diff --git a/Optimizing-assembly-code.md b/Optimizing-assembly-code.md
index b3453b4..d2fafc2 100644
--- a/Optimizing-assembly-code.md
+++ b/Optimizing-assembly-code.md
@@ -177,6 +177,8 @@ The exception is if you need to set the zero flag when the operation results in
(This optimization is from [Retro Programming](http://www.retroprogramming.com/2014/01/fast-z80-bit-reversal.html)).
+(The example uses `b` and `c`, but any of `d`, `e`, `h`, or `l` would also work.)
+
Don't do:
```asm
@@ -769,6 +771,30 @@ Don't do:
add hl, de
```
+And don't do:
+
+```asm
+ ; 8 bytes, 8 cycles
+ ld hl, Address
+ add l
+ ld l, a
+ adc h
+ sub l
+ ld h, a
+```
+
+And don't do:
+
+```asm
+ ; 8 bytes, 7 or 8 cycles
+ ld h, HIGH(Address)
+ add LOW(Address)
+ ld l, a
+ jr nc, .no_carry
+ inc h
+.no_carry
+```
+
But do:
```asm