summaryrefslogtreecommitdiff
path: root/Optimizing-assembly-code.md
diff options
context:
space:
mode:
authorRangi <remy.oukaour+rangi42@gmail.com>2020-10-06 08:35:44 -0400
committerRangi <remy.oukaour+rangi42@gmail.com>2020-10-06 08:35:44 -0400
commit61398dcd34dbcb985d71306df65ec255afb5506e (patch)
tree839a3a3eb2dd517859c33e5d5300d30a35b24e5d /Optimizing-assembly-code.md
parent2860eb2607fe6f2fc13decb039a3b9260811fc65 (diff)
Fix jr
Diffstat (limited to 'Optimizing-assembly-code.md')
-rw-r--r--Optimizing-assembly-code.md4
1 files changed, 3 insertions, 1 deletions
diff --git a/Optimizing-assembly-code.md b/Optimizing-assembly-code.md
index a2c52d9..513f97b 100644
--- a/Optimizing-assembly-code.md
+++ b/Optimizing-assembly-code.md
@@ -1247,10 +1247,12 @@ But do:
```asm
; 2 bytes, 2 or 7 cycles
- jr z, @ - 1 ; the byte for @ - 1 is $ff, which is the opcode for rst $38
+ jr z, @ + 1 ; the byte for @ + 1 is $ff, which is the opcode for rst $38
...
```
+(The label `@` evaluates to the current `pc` value, which in `jr z, @ + 1` is right before the `jr` instruction. The instruction consists of two bytes, the opcode and the relative offset. `@ + 1` evaluates to in-between those two bytes. The `jr` instruction encodes its offset relative to the *end* of the instruction, i.e. the *next* `pc` value after the instruction has been read, so the relative offset is `-1`, aka `$ff`.)
+
## Jump and lookup tables