summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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