DCPU-16
DCPU-16 copied to clipboard
Macros and label resolution
In the example below, the label end
passed to the braf
macro is not resolved (it becomes zero) in the assembled output. It should behave like the macro-expanded line following it.
#macro brab(label) {
sub PC, 2+.-label
}
#macro braf(label) {
add PC, label-(2+.)
}
:start
dat 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
brab start
sub PC, 2+.+start
braf end
add PC, end-(2+.)
dat 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
:end
dat 0
To clarify the code example above:
brab start ; works like the following line
sub PC, 2+.+start
braf end ; broken -- generates a ADD PC, 0 (next word literal 0)
add PC, end-(2+.) ; works as expected
i think i might have fixed this in my macro branch that just got merged. can you try it now?