Labels, constants & numbers
Labels
A label names a location in your program. Labels must start with a letter, a period, or an underscore, and may optionally end with a colon:
start:
jp start
message db "Hello", 0 ; the colon is optionalLocal labels
A label that starts with a period (.) is local — it’s scoped to the nearest preceding global label. This lets you reuse short names like .loop without clashing:
delay:
ld b, 255
.loop:
djnz .loop ; refers to delay.loop
ret
wait:
ld b, 100
.loop: ; a different .loop, scoped to wait
djnz .loop
retYou can refer to a local label from elsewhere by its full global.local name (e.g. delay.loop).
Constants
Define a constant with = or EQU:
WIDTH = 256
HEIGHT EQU 192
SIZE = WIDTH * HEIGHTConstants are compile-time values usable anywhere an expression is allowed.
Number formats
| Kind | Forms |
|---|---|
| Hexadecimal | 0x12EF, $12EF, 012EFh |
| Binary | %10101010, 0b10101010, 10101010b |
| Decimal | 1234 |
| Character | 'A' — evaluates to the ZX Spectrum character code |
mask = %00000111
addr = $8000
screen = 0x4000
letter = 'Z'