summaryrefslogtreecommitdiff
path: root/Optimizing-assembly-code.md
diff options
context:
space:
mode:
authorEldred Habert <eldredhabert0@gmail.com>2019-02-18 20:53:31 +0100
committerEldred Habert <eldredhabert0@gmail.com>2019-02-18 20:53:31 +0100
commitb8e1245b7a56779276a669024eb3c5d21c11e583 (patch)
treec374b50736b1b5f490e9943d58caa667e8d93fe2 /Optimizing-assembly-code.md
parent6636c4b8f3a867e5b3cb4e496148c82a2053605a (diff)
Reorder two sections to group those related to `[hl]`
Diffstat (limited to 'Optimizing-assembly-code.md')
-rw-r--r--Optimizing-assembly-code.md38
1 files changed, 19 insertions, 19 deletions
diff --git a/Optimizing-assembly-code.md b/Optimizing-assembly-code.md
index d5f60c5..f45a44a 100644
--- a/Optimizing-assembly-code.md
+++ b/Optimizing-assembly-code.md
@@ -14,8 +14,8 @@ Most of these tricks come from either [Jeff's GB Assembly Code Tips v1.0](http:/
- [Increment a 16-bit register](#increment-decrement-a-16-bit-register)
- [Load from an address to `hl`](#load-from-an-address-to-hl)
- [Exchange two 16-bit registers](#exchange-two-16-bit-registers)
- - [Load a constant into `[hl]`](#load-a-constant-into-hl)
- [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 increment or decrement `hl`](#load-a-constant-into-hl-and-increment-or-decrement-hl)
- [Increment or decrement `[hl]`](#increment-or-decrement-hl)
- [Branching (control flow)](#branching-control-flow)
@@ -238,24 +238,6 @@ If you care about size:
```
-### Load a constant into `[hl]`
-
-Don't do:
-
-```asm
- ; 3 bytes, 4 cycles
- ld a, CONST
- ld [hl], a
-```
-
-But do:
-
-```asm
- ; 2 bytes, 3 cycles
- ld [hl], CONST
-```
-
-
### Load two constants into a register pair
(The example uses `bc`, but `hl` or `de` would also work.)
@@ -283,6 +265,24 @@ Or better, use the `lb` macro in [macros/code.asm](../blob/master/macros/code.as
```
+### Load a constant into `[hl]`
+
+Don't do:
+
+```asm
+ ; 3 bytes, 4 cycles
+ ld a, CONST
+ ld [hl], a
+```
+
+But do:
+
+```asm
+ ; 2 bytes, 3 cycles
+ ld [hl], CONST
+```
+
+
### Load a constant into `[hl]` and incrementing or decrementing `hl`
Don't do: