Skip to content

Commit 02b2a2d

Browse files
committed
Revert "Introduce local labels in hello-world.asm (#154)"
This reverts commit c387679.
1 parent 566c5ca commit 02b2a2d

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

src/assets/hello-world.asm

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ WaitVBlank:
2929
; Copy the tile data
3030
ld de, Tiles
3131
ld hl, $9000
32-
ld bc, Tiles.End - Tiles
32+
ld bc, TilesEnd - Tiles
3333
CopyTiles:
3434
; ANCHOR: memcpy_first_two
3535
ld a, [de]
@@ -45,7 +45,7 @@ CopyTiles:
4545
; Copy the tilemap
4646
ld de, Tilemap
4747
ld hl, $9800
48-
ld bc, Tilemap.End - Tilemap
48+
ld bc, TilemapEnd - Tilemap
4949
CopyTilemap:
5050
ld a, [de]
5151
ld [hli], a
@@ -71,7 +71,6 @@ Done:
7171

7272
SECTION "Tile data", ROM0
7373

74-
; ANCHOR: tiles
7574
Tiles:
7675
db $00,$ff, $00,$ff, $00,$ff, $00,$ff, $00,$ff, $00,$ff, $00,$ff, $00,$ff
7776
db $00,$ff, $00,$80, $00,$80, $00,$80, $00,$80, $00,$80, $00,$80, $00,$80
@@ -143,12 +142,10 @@ Tiles:
143142
db $54,$ff, $aa,$ff, $54,$ff, $aa,$ff, $54,$ff, $aa,$ff, $54,$ff, $00,$ff
144143
db $15,$ff, $2a,$ff, $15,$ff, $0a,$ff, $15,$ff, $0a,$ff, $01,$ff, $00,$ff
145144
db $01,$ff, $80,$ff, $01,$ff, $80,$ff, $01,$ff, $80,$ff, $01,$ff, $00,$ff
146-
.End:
147-
; ANCHOR_END: tiles
145+
TilesEnd:
148146

149147
SECTION "Tilemap", ROM0
150148

151-
; ANCHOR: tilemap
152149
Tilemap:
153150
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, 0,0,0,0,0,0,0,0,0,0,0,0
154151
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, 0,0,0,0,0,0,0,0,0,0,0,0
@@ -168,5 +165,4 @@ Tilemap:
168165
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, 0,0,0,0,0,0,0,0,0,0,0,0
169166
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, 0,0,0,0,0,0,0,0,0,0,0,0
170167
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, 0,0,0,0,0,0,0,0,0,0,0,0
171-
.End:
172-
; ANCHOR_END: tilemap
168+
TilemapEnd:

src/part1/memory.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,6 @@ Writing out a label's name is equivalent to writing the address of the byte it's
9595
For example, consider the `ld de, Tiles` at line {{#line_no_of "ld\s+de\s*,\s*Tiles" ../assets/hello-world.asm}}.
9696
`Tiles` (line {{#line_no_of "^\s*Tiles:" ../assets/hello-world.asm}}) is referring to the first byte of the tile data; if we assume that the tile data ends up being stored starting at $0193, then `ld de, Tiles` is equivalent to `ld de, $0193`!
9797

98-
There's a shorthand for writing *local* labels: start their name with a dot `.` and it will implicitly be prefixed with the name of the most recent non-local label.
99-
For example, consider the two `.End:` labels at lines {{#line_no_of "^\.End:" ../assets/hello-world.asm:tiles}} and {{#line_no_of "^\.End:" ../assets/hello-world.asm:tilemap}}.
100-
The first one is implicitly defining "`Tiles.End:`" because of the non-local `Tiles:` label before it on line {{#line_no_of "^\s*Tiles:" ../assets/hello-world.asm}}, and the second one is defining "`Tilemap.End:`" because of the non-local `Tilemap:` label on line {{#line_no_of "^\s*Tilemap:" ../assets/hello-world.asm}}.
101-
Local labels are useful because as your project gets larger, you'll need more and more very similar names, and it would be tedious to have to make up unique prefixes for them everywhere.
102-
10398
## What's with the brackets?
10499

105100
Right, we came into this because we wanted to know what the brackets in `ld a, [de]` mean.
@@ -133,7 +128,7 @@ So, if we look at the first two instructions of `CopyTiles`:
133128
...we can see that we're copying the byte in memory *pointed to* by `de` (that is, whose address is contained in `de`) into the byte pointed to by `hl`.
134129
Here, `a` serves as temporary storage, since the CPU is unable to perform `ld [hl], [de]` directly.
135130

136-
While we're at this, let's examine the rest of `CopyTiles` in the following lessons!
131+
While we're at this, let's examine the rest of `.copyTiles` in the following lessons!
137132

138133
---
139134

0 commit comments

Comments
 (0)