Implement unionized sections in RGBASM

This touched a lot more code than initially expected, for two reasons.

First, this broke a big RGBASM assumption: that sections are always being
written to at their end. This plus other problems required touching
basically the entirety of `section.c`.

Second, I tried different solutions to solve the above problem, and along
the way I cleaned up many things around. (I believe that keeping this to
"cleanup" commits yields subpar results, and since it's boring they get
postponed anyways.)

RGBLINK support still needs to be added, but this will come next.
This commit is contained in:
ISSOtm
2020-03-20 21:02:32 +01:00
parent 46a402f7d7
commit cb52ae0f26
13 changed files with 314 additions and 162 deletions

View File

@@ -0,0 +1,37 @@
SECTION UNION "test", WRAM0
Base:
ds $1000
SECTION UNION "test", WRAM0,ALIGN[8]
ds 42
Plus42:
SECTION UNION "test", WRAM0,ALIGN[4]
SECTION UNION "test", WRAM0[$C000]
; Since the section's base address is known, the labels are constant now
ds $1000 ; This shouldn't overflow
End:
SECTION UNION "test", WRAM0,ALIGN[9]
check_label: MACRO
EXPECTED equ \2
IF \1 == EXPECTED
RESULT equs "OK!"
ELSE
RESULT equs "expected {EXPECTED}"
ENDC
PURGE EXPECTED
PRINTT "\1 is at {\1} ({RESULT})\n"
PURGE RESULT
ENDM
check_label Base, $C000
check_label Plus42, $C000 + 42
check_label End, $D000
SECTION "test", WRAM0 ; Don't allow creating a section that's not a union!