Closed jeffythedragonslayer closed 2 years ago
This likely indicates relative addressing which is probably why there are two different kinds of labels used, a BRA (near) is 2 bytes and a JMP (long) takes 4 bytes, thanks to Emil Dotchevski
That is a syntax specifically for ca65, which is called a "cheap local". It's a way to provide scoping for labels so that they don't have to be globally unique. Cheap locals are only addressable between pairs of global labels (without the @).
Ah, because the instructions to jump to them are cheaper
Not necessarily, it could still require an absolute jump to them, but it's "cheaper" in terms of the namespace, meaning a cheap local label doesn't use up another label from the global namespace. So, you can have only one "loop", but you can have an "@loop" inside any scope:
foo:
ldx #5
@loop:
inc counter
dex
bne @loop
rts
bar:
ldx #6
@loop:
dec counter
dex
bne @loop
rts
I notice that some labels in hello.asm begin with @ and some don't. What does this mean?