High and low bytes
One can use
< to get the high and low bytes of a value, respectively.
>$1234 = $12, and
<$1234 = $34.
Labels prefixed with
@ are considered "child" labels; they will fall out of scope when a new "parent" label is specified. This allows one to use short and sweet label names for a specific context.
As an example, here, two labels named
@loop are used, which don't conflict because they have different parents:
parentLabel1: ld b,4 @loop: dec b jr nz,@loop ret parentLabel2: ld b,8 @loop: dec b jr nz,@loop ret
One can jump directly to a child label by prefixing the parent name, ie.
jp parentLabel1@loop. This should be used sparingly, since it is useful to assume that child labels are not jumped to by external sources (this makes reasoning about a function easier).
Before child labels, there were anonymous labels. These are labels named
+ labels are ones that only work with forward jumps, while
- labels only work with backward jumps. These should generally only be used for very short jumps (the destination should be visible on the screen without scrolling).
One can also use
__ (two underscores) as an anonymous label; then,
_f works as a forward reference to this label, and
_b works as a backward reference to it. I prefer not to use this since it's not as clear.
Local labels are prefixed with an underscore (
_). These labels are not visible outside of the section they are defined in.
Quirks and Workarounds
When passing arguments to macros or assembler directives, arguments can be separated by spaces or commas, ie, these two lines are equivalent:
.db $01 $02 .db $01, $02
There are rare cases where WLA gets confused by the space-separators. For instance, this line in the disassembly caused issues:
.db <wObtainedTreasureFlags (1<<TREASURE_PUNCH) | (1<<TREASURE_SWORD)
This is fixed by using comma-separators instead.
.db <wObtainedTreasureFlags, (1<<TREASURE_PUNCH) | (1<<TREASURE_SWORD)