mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Allow LOAD FRAGMENT (#1552)
This was implemented in #736 but removed after discussion in #869. Fixes #1537
This commit is contained in:
@@ -968,11 +968,11 @@ block before performing its own function.
|
|||||||
.Ic LOAD
|
.Ic LOAD
|
||||||
blocks can use the
|
blocks can use the
|
||||||
.Ic UNION
|
.Ic UNION
|
||||||
modifier as described in
|
or
|
||||||
.Sx Unionized sections
|
|
||||||
below, but not the
|
|
||||||
.Ic FRAGMENT
|
.Ic FRAGMENT
|
||||||
modifier.
|
modifiers as described in
|
||||||
|
.Sx Unionized sections
|
||||||
|
below.
|
||||||
.Ss Unionized sections
|
.Ss Unionized sections
|
||||||
When you're tight on RAM, you may want to define overlapping static memory allocations, as explained in the
|
When you're tight on RAM, you may want to define overlapping static memory allocations, as explained in the
|
||||||
.Sx Allocating overlapping spaces in RAM
|
.Sx Allocating overlapping spaces in RAM
|
||||||
|
|||||||
@@ -462,11 +462,6 @@ void sect_SetLoadSection(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mod == SECTION_FRAGMENT) {
|
|
||||||
error("`LOAD FRAGMENT` is not allowed\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentLoadSection)
|
if (currentLoadSection)
|
||||||
sect_EndLoadSection("LOAD");
|
sect_EndLoadSection("LOAD");
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,29 @@
|
|||||||
SECTION "A", ROM0
|
SECTION "A", ROM0
|
||||||
|
AData::
|
||||||
LOAD FRAGMENT "RAM", WRAM0
|
LOAD FRAGMENT "RAM", WRAM0
|
||||||
|
AMem::
|
||||||
|
db 0, 1, 2
|
||||||
|
AMemEnd::
|
||||||
|
ENDL
|
||||||
|
ADataEnd::
|
||||||
|
dw AMem
|
||||||
|
|
||||||
|
SECTION "B", ROM0
|
||||||
|
BData::
|
||||||
|
LOAD FRAGMENT "RAM", WRAM0
|
||||||
|
BMem::
|
||||||
|
db 3, 4, 5, 6, 7
|
||||||
|
BMemEnd::
|
||||||
|
ENDL
|
||||||
|
BDataEnd::
|
||||||
|
dw BMem
|
||||||
|
|
||||||
|
SECTION "C", ROM0
|
||||||
|
CData::
|
||||||
|
LOAD FRAGMENT "RAM", WRAM0
|
||||||
|
CMem::
|
||||||
|
db 8, 9
|
||||||
|
CMemEnd::
|
||||||
|
ENDL
|
||||||
|
CDataEnd::
|
||||||
|
dw CMem
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
error: load-fragment.asm(2):
|
|
||||||
`LOAD FRAGMENT` is not allowed
|
|
||||||
error: Assembly aborted (1 error)!
|
|
||||||
BIN
test/asm/load-fragment.out.bin
Normal file
BIN
test/asm/load-fragment.out.bin
Normal file
Binary file not shown.
12
test/link/load-fragment-jr.asm
Normal file
12
test/link/load-fragment-jr.asm
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
SECTION "main", ROM0
|
||||||
|
LOAD FRAGMENT "test", SRAM
|
||||||
|
ENDL
|
||||||
|
|
||||||
|
; The RPN patch for 'jr Label' in section "alt" refers to section "test",
|
||||||
|
; but the object file puts section "test" after section "alt".
|
||||||
|
; This case needs to be handled when identifying patches' PC sections.
|
||||||
|
SECTION "alt", ROM0
|
||||||
|
LOAD FRAGMENT "test", SRAM
|
||||||
|
jr Label
|
||||||
|
Label:
|
||||||
|
ENDL
|
||||||
0
test/link/load-fragment-jr.out
Normal file
0
test/link/load-fragment-jr.out
Normal file
BIN
test/link/load-fragment-jr.out.bin
Normal file
BIN
test/link/load-fragment-jr.out.bin
Normal file
Binary file not shown.
9
test/link/load-fragment/base/a.asm
Normal file
9
test/link/load-fragment/base/a.asm
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
SECTION "Test", ROM0[0]
|
||||||
|
AA: db 1
|
||||||
|
LOAD FRAGMENT "RAM section", WRAM0[$c000]
|
||||||
|
BB: db 2
|
||||||
|
ENDL
|
||||||
|
CC: db 3
|
||||||
|
LOAD FRAGMENT "RAM section", WRAM0
|
||||||
|
DD: db 4
|
||||||
|
ENDL
|
||||||
1
test/link/load-fragment/base/ref.out.bin
Normal file
1
test/link/load-fragment/base/ref.out.bin
Normal file
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
5
test/link/load-fragment/base/ref.out.sym
Normal file
5
test/link/load-fragment/base/ref.out.sym
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
; File generated by rgblink
|
||||||
|
00:0000 AA
|
||||||
|
00:0002 CC
|
||||||
|
00:c000 BB
|
||||||
|
00:c001 DD
|
||||||
4
test/link/load-fragment/multiple-objects/a.asm
Normal file
4
test/link/load-fragment/multiple-objects/a.asm
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
SECTION "main", ROM0
|
||||||
|
LOAD FRAGMENT "test", SRAM
|
||||||
|
db 0
|
||||||
|
ENDL
|
||||||
6
test/link/load-fragment/multiple-objects/b.asm
Normal file
6
test/link/load-fragment/multiple-objects/b.asm
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
SECTION "SECTION2", ROM0
|
||||||
|
LOAD FRAGMENT "test", SRAM
|
||||||
|
jr Label
|
||||||
|
Label:
|
||||||
|
dw Label
|
||||||
|
ENDL
|
||||||
BIN
test/link/load-fragment/multiple-objects/ref.out.bin
Normal file
BIN
test/link/load-fragment/multiple-objects/ref.out.bin
Normal file
Binary file not shown.
8
test/link/load-fragment/section-fragment/a.asm
Normal file
8
test/link/load-fragment/section-fragment/a.asm
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
SECTION FRAGMENT "rom", ROM0
|
||||||
|
Part1::
|
||||||
|
LOAD FRAGMENT "ram", WRAM0
|
||||||
|
wPart1::
|
||||||
|
jr wPart1
|
||||||
|
jr wPart3
|
||||||
|
ENDL
|
||||||
|
Part1End::
|
||||||
4
test/link/load-fragment/section-fragment/b.asm
Normal file
4
test/link/load-fragment/section-fragment/b.asm
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
SECTION FRAGMENT "rom", ROM0
|
||||||
|
Part2::
|
||||||
|
db "Hello world!"
|
||||||
|
Part2End::
|
||||||
8
test/link/load-fragment/section-fragment/c.asm
Normal file
8
test/link/load-fragment/section-fragment/c.asm
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
SECTION FRAGMENT "rom", ROM0
|
||||||
|
Part3::
|
||||||
|
LOAD FRAGMENT "ram", WRAM0
|
||||||
|
wPart3::
|
||||||
|
jr wPart1
|
||||||
|
jr wPart3
|
||||||
|
ENDL
|
||||||
|
Part3End::
|
||||||
BIN
test/link/load-fragment/section-fragment/ref.out.bin
Normal file
BIN
test/link/load-fragment/section-fragment/ref.out.bin
Normal file
Binary file not shown.
24
test/link/load-fragment/section-fragment/ref.out.map
Normal file
24
test/link/load-fragment/section-fragment/ref.out.map
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
SUMMARY:
|
||||||
|
ROM0: 20 bytes used / 16364 free
|
||||||
|
WRAM0: 8 bytes used / 4088 free
|
||||||
|
|
||||||
|
ROM0 bank #0:
|
||||||
|
SECTION: $0000-$0013 ($0014 bytes) ["rom"]
|
||||||
|
$0000 = Part1
|
||||||
|
$0004 = Part1End
|
||||||
|
; Next fragment
|
||||||
|
$0010 = Part3
|
||||||
|
$0014 = Part3End
|
||||||
|
; Next fragment
|
||||||
|
$0004 = Part2
|
||||||
|
$0010 = Part2End
|
||||||
|
EMPTY: $0014-$3fff ($3fec bytes)
|
||||||
|
TOTAL EMPTY: $3fec bytes
|
||||||
|
|
||||||
|
WRAM0 bank #0:
|
||||||
|
SECTION: $c000-$c007 ($0008 bytes) ["ram"]
|
||||||
|
$c000 = wPart1
|
||||||
|
; Next fragment
|
||||||
|
$c004 = wPart3
|
||||||
|
EMPTY: $c008-$cfff ($0ff8 bytes)
|
||||||
|
TOTAL EMPTY: $0ff8 bytes
|
||||||
9
test/link/load-fragment/section-fragment/ref.out.sym
Normal file
9
test/link/load-fragment/section-fragment/ref.out.sym
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
; File generated by rgblink
|
||||||
|
00:0000 Part1
|
||||||
|
00:0004 Part1End
|
||||||
|
00:0004 Part2
|
||||||
|
00:0010 Part3
|
||||||
|
00:0010 Part2End
|
||||||
|
00:0014 Part3End
|
||||||
|
00:c000 wPart1
|
||||||
|
00:c004 wPart3
|
||||||
4
test/link/section-fragment/jr-offset-load/a.asm
Normal file
4
test/link/section-fragment/jr-offset-load/a.asm
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
SECTION FRAGMENT "output", ROM0
|
||||||
|
LOAD FRAGMENT "loaded", SRAM
|
||||||
|
ds 128
|
||||||
|
ENDL
|
||||||
6
test/link/section-fragment/jr-offset-load/b.asm
Normal file
6
test/link/section-fragment/jr-offset-load/b.asm
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
SECTION FRAGMENT "output", ROM0
|
||||||
|
LOAD FRAGMENT "loaded", SRAM
|
||||||
|
label:
|
||||||
|
jr nz, label2
|
||||||
|
label2:
|
||||||
|
ENDL
|
||||||
BIN
test/link/section-fragment/jr-offset-load/ref.out.bin
Normal file
BIN
test/link/section-fragment/jr-offset-load/ref.out.bin
Normal file
Binary file not shown.
@@ -172,6 +172,36 @@ rgblinkQuiet -o "$gbtemp2" "$outtemp"
|
|||||||
tryCmp "$gbtemp" "$gbtemp2"
|
tryCmp "$gbtemp" "$gbtemp2"
|
||||||
evaluateTest
|
evaluateTest
|
||||||
|
|
||||||
|
test="load-fragment/base"
|
||||||
|
startTest
|
||||||
|
"$RGBASM" -o "$otemp" "$test"/a.asm
|
||||||
|
continueTest
|
||||||
|
rgblinkQuiet -o "$gbtemp" -n "$outtemp" "$otemp"
|
||||||
|
tryCmpRom "$test"/ref.out.bin
|
||||||
|
tryDiff "$test"/ref.out.sym "$outtemp"
|
||||||
|
evaluateTest
|
||||||
|
|
||||||
|
test="load-fragment/multiple-objects"
|
||||||
|
startTest
|
||||||
|
"$RGBASM" -o "$otemp" "$test"/a.asm
|
||||||
|
"$RGBASM" -o "$gbtemp2" "$test"/b.asm
|
||||||
|
continueTest
|
||||||
|
rgblinkQuiet -o "$gbtemp" "$otemp" "$gbtemp2"
|
||||||
|
tryCmpRom "$test"/ref.out.bin
|
||||||
|
evaluateTest
|
||||||
|
|
||||||
|
test="load-fragment/section-fragment"
|
||||||
|
startTest
|
||||||
|
"$RGBASM" -o "$otemp" "$test"/a.asm
|
||||||
|
"$RGBASM" -o "$outtemp" "$test"/b.asm
|
||||||
|
"$RGBASM" -o "$outtemp2" "$test"/c.asm
|
||||||
|
continueTest
|
||||||
|
rgblinkQuiet -o "$gbtemp" -m "$outtemp3" -n "$gbtemp2" "$otemp" "$outtemp" "$outtemp2"
|
||||||
|
tryCmpRom "$test"/ref.out.bin
|
||||||
|
tryDiff "$test"/ref.out.map "$outtemp3"
|
||||||
|
tryDiff "$test"/ref.out.sym "$gbtemp2"
|
||||||
|
evaluateTest
|
||||||
|
|
||||||
test="map-file"
|
test="map-file"
|
||||||
startTest
|
startTest
|
||||||
"$RGBASM" -o "$otemp" "$test"/a.asm
|
"$RGBASM" -o "$otemp" "$test"/a.asm
|
||||||
@@ -257,6 +287,15 @@ rgblinkQuiet -o "$gbtemp" "$otemp" "$gbtemp2"
|
|||||||
tryCmpRom "$test"/ref.out.bin
|
tryCmpRom "$test"/ref.out.bin
|
||||||
evaluateTest
|
evaluateTest
|
||||||
|
|
||||||
|
test="section-fragment/jr-offset-load"
|
||||||
|
startTest
|
||||||
|
"$RGBASM" -o "$otemp" "$test"/a.asm
|
||||||
|
"$RGBASM" -o "$gbtemp2" "$test"/b.asm
|
||||||
|
continueTest
|
||||||
|
rgblinkQuiet -o "$gbtemp" "$otemp" "$gbtemp2"
|
||||||
|
tryCmpRom "$test"/ref.out.bin
|
||||||
|
evaluateTest
|
||||||
|
|
||||||
test="section-normal/same-name"
|
test="section-normal/same-name"
|
||||||
startTest
|
startTest
|
||||||
"$RGBASM" -o "$otemp" "$test"/a.asm
|
"$RGBASM" -o "$otemp" "$test"/a.asm
|
||||||
|
|||||||
Reference in New Issue
Block a user