Document new "unionized section" feature

This commit is contained in:
ISSOtm
2020-03-26 23:50:30 +01:00
parent 4df74d44ec
commit 5039af6af1

View File

@@ -575,12 +575,12 @@ Luckily,
blocks are the perfect solution to that.
Here's an example of how to use them:
.Bd -literal -offset indent
SECTION "LOAD example", ROMX
CopyCode:
SECTION "LOAD example", ROMX
CopyCode:
ld de, RAMCode
ld hl, RAMLocation
ld c, RAMLocation.end - RAMLocation
.loop
\&.loop
ld a, [de]
inc de
ld [hli], a
@@ -588,12 +588,12 @@ Here's an example of how to use them:
jr nz, .loop
ret
RAMCode:
RAMCode:
LOAD "RAM code", WRAM0
RAMLocation:
RAMLocation:
ld hl, .string
ld de, $9864
.copy
\&.copy
ld a, [hli]
ld [de], a
inc de
@@ -601,9 +601,9 @@ Here's an example of how to use them:
jr nz, .copy
ret
.string
\&.string
db "Hello World!", 0
.end
\&.end
ENDL
.Ed
.Pp
@@ -625,6 +625,52 @@ The former is situated in ROM, where the code is stored, the latter in RAM, wher
You cannot nest
.Ic LOAD
blocks, nor can you change the current section within them.
.Ss Unionized Sections
.Pp
When you're tight on RAM, you may want to define overlapping blocks of variables, as explained in the
.Sx Unions
section.
However, the
.Ic UNION
keyword only works within a single file, which prevents e.g. defining temporary variables on a single memory area across several files.
Unionized sections solve this problem.
To declare an unionized section, add a
.Ic UNION
keyword after the
.Ic SECTION
one; the declaration is otherwise not different.
Unionized sections follow some different rules from normal sections:
.Bl -bullet -offset indent
.It
The same unionized section (= having the same name) can be declared several times per
.Nm
invocation, and across several invocations.
Different declarations are treated and merged identically whether within the same invocation, or different ones.
.It
A section cannot be declared both as unionized or non-unionized.
.It
All declarations must have the same type.
For example, even if
.Xr rgblink 1 Ap s
.Fl w
flag is used,
.Ic WRAM0
and
.Ic WRAMX
types are still considered different.
.It
Different constraints (alignment, bank, etc.) can be specified for each unionized section declaration, but they must all be compatible.
For example, alignment must be compatible with any fixed address, all specified banks must be the same, etc.
.It
Unionized sections cannot have type
.Ic ROM0
or
.Ic ROMX .
.El
.Pp
Different declarations of the same unionized section are not appended, but instead overlaid on top of eachother, just like
.Sx Unions .
Similarly, the size of an unionized section is the largest of all its declarations.
.Sh SYMBOLS
.Pp
RGBDS supports several types of symbols: