summaryrefslogtreecommitdiff
path: root/Optimizing-assembly-code.md
diff options
context:
space:
mode:
authorRangi <remy.oukaour+rangi42@gmail.com>2019-02-19 18:47:30 -0500
committerRangi <remy.oukaour+rangi42@gmail.com>2019-02-19 18:47:30 -0500
commit0c58b0eb1abf270e641371ce30df8e9f8d200170 (patch)
treeb8d8af7112adea321c2436a6bc0826ba682723cc /Optimizing-assembly-code.md
parentab7db971ff16ed4a9101a50b8dcaa3d875c1eb20 (diff)
Ordering
Diffstat (limited to 'Optimizing-assembly-code.md')
-rw-r--r--Optimizing-assembly-code.md58
1 files changed, 25 insertions, 33 deletions
diff --git a/Optimizing-assembly-code.md b/Optimizing-assembly-code.md
index 2cc248a..61f3873 100644
--- a/Optimizing-assembly-code.md
+++ b/Optimizing-assembly-code.md
@@ -16,8 +16,8 @@ Most of these tricks come from either [Jeff's GB Assembly Code Tips v1.0](http:/
- [Exchange two 16-bit registers](#exchange-two-16-bit-registers)
- [Load two constants into a register pair](#load-two-constants-into-a-register-pair)
- [Load a constant into `[hl]`](#load-a-constant-into-hl)
- - [Load a constant into `[hl]` and incrementing or decrementing `hl`](#load-a-constant-into-hl-and-incrementing-or-decrementing-hl)
- [Increment or decrement `[hl]`](#increment-or-decrement-hl)
+ - [Load a constant into `[hl]` and increment or decrement `hl`](#load-a-constant-into-hl-and-increment-or-decrement-hl)
- [Branching (control flow)](#branching-control-flow)
- [Relative jumps](#relative-jumps)
- [Compare `a` to 0](#compare-a-to-0)
@@ -297,71 +297,63 @@ But do:
```
-### Load a constant into `[hl]` and incrementing or decrementing `hl`
+### Increment or decrement `[hl]`
Don't do:
```asm
- ; 2 bytes, 4 cycles
+ ; 3 bytes, 5 cycles
+ ld a, [hl]
+ inc a
ld [hl], a
- inc hl
```
-But do:
-
```asm
- ; 1 bytes, 2 cycles
- ld [hli], a
+ ; 3 bytes, 5 cycles
+ ld a, [hl]
+ dec a
+ ld [hl], a
```
-And don't do:
+But do:
```asm
- ; 2 bytes, 4 cycles
- ld [hl], a
- dec hl
+ ; 1 bytes, 3 cycles
+ inc [hl]
```
-But do:
-
```asm
- ; 1 bytes, 2 cycles
- ld [hld], a
+ ; 1 bytes, 3 cycles
+ dec [hl]
```
-### Increment or decrement `[hl]`
+### Load a constant into `[hl]` and increment or decrement `hl`
Don't do:
```asm
- ; 3 bytes, 5 cycles
- ld a, [hl]
- inc a
+ ; 2 bytes, 4 cycles
ld [hl], a
+ inc hl
```
-But do:
-
```asm
- ; 1 bytes, 3 cycles
- inc [hl]
+ ; 2 bytes, 4 cycles
+ ld [hl], a
+ dec hl
```
-And don't do:
+But do:
```asm
- ; 3 bytes, 5 cycles
- ld a, [hl]
- dec a
- ld [hl], a
+ ; 1 bytes, 2 cycles
+ ld [hli], a
```
-But do:
-
```asm
- ; 1 bytes, 3 cycles
- dec [hl]
+ ; 1 bytes, 2 cycles
+ ld [hld], a
```