From ZeldaHacking Wiki
Jump to: navigation, search
Author(s)Ville Helin

WLA-DX is the assembler used by the disassembly. A recent build from github is used. Windows/cygwin builds that work with the disassembly can be found here.

Handy features

High and low bytes

One can use > or < to get the high and low bytes of a value, respectively.

For example, >$1234 = $12, and <$1234 = $34.

Child labels

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:

    ld b,4
    dec b
    jr nz,@loop

    ld b,8
    dec b
    jr nz,@loop

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).

Anonymous labels

Before child labels, there were anonymous labels. These are labels named +, ++, +++, or -, --, ---, etc...

+ 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

Local labels are prefixed with an underscore (_). These labels are not visible outside of the section they are defined in.

Quirks and Workarounds

Argument separation

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)