mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Reset LOAD offset when changing SECTIONs
This would cause spurious section overflow messages, since the load offset is added to the section's when computing its size.
This commit is contained in:
@@ -418,6 +418,7 @@ void sect_NewSection(char const *name, uint32_t type, uint32_t org,
|
|||||||
|
|
||||||
changeSection();
|
changeSection();
|
||||||
curOffset = mod == SECTION_UNION ? 0 : sect->size;
|
curOffset = mod == SECTION_UNION ? 0 : sect->size;
|
||||||
|
loadOffset = 0; // This is still used when checking for section size overflow!
|
||||||
currentSection = sect;
|
currentSection = sect;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -989,16 +990,15 @@ void sect_PopSection(void)
|
|||||||
if (currentLoadSection)
|
if (currentLoadSection)
|
||||||
fatalerror("Cannot change the section within a `LOAD` block!\n");
|
fatalerror("Cannot change the section within a `LOAD` block!\n");
|
||||||
|
|
||||||
struct SectionStackEntry *sect;
|
struct SectionStackEntry *entry = sectionStack;
|
||||||
|
|
||||||
sect = sectionStack;
|
|
||||||
changeSection();
|
changeSection();
|
||||||
currentSection = sect->section;
|
currentSection = entry->section;
|
||||||
currentLoadSection = sect->loadSection;
|
currentLoadSection = entry->loadSection;
|
||||||
sym_SetCurrentSymbolScope(sect->scope);
|
sym_SetCurrentSymbolScope(entry->scope);
|
||||||
curOffset = sect->offset;
|
curOffset = entry->offset;
|
||||||
loadOffset = sect->loadOffset;
|
loadOffset = entry->loadOffset;
|
||||||
|
|
||||||
sectionStack = sect->next;
|
sectionStack = entry->next;
|
||||||
free(sect);
|
free(entry);
|
||||||
}
|
}
|
||||||
|
|||||||
27
test/asm/load-pushs-load.asm
Normal file
27
test/asm/load-pushs-load.asm
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
|
||||||
|
SECTION "Output", ROM0[0]
|
||||||
|
dw Rom0Label1
|
||||||
|
dw Rom0Label2
|
||||||
|
dw SramLabel1
|
||||||
|
dw SramLabel2
|
||||||
|
dw RomxLabel1
|
||||||
|
dw RomxLabel2
|
||||||
|
dw HramLabel
|
||||||
|
|
||||||
|
|
||||||
|
SECTION "A", ROM0[$1324]
|
||||||
|
Rom0Label1:
|
||||||
|
LOAD "LA", SRAM[$BEAD]
|
||||||
|
SramLabel1:
|
||||||
|
PUSHS
|
||||||
|
; not inside a section or load section here yet
|
||||||
|
SECTION "B", ROMX[$4698]
|
||||||
|
RomxLabel1:
|
||||||
|
LOAD "LB", HRAM[$FF86]
|
||||||
|
HramLabel:
|
||||||
|
ENDL
|
||||||
|
RomxLabel2:
|
||||||
|
POPS
|
||||||
|
SramLabel2:
|
||||||
|
ENDL
|
||||||
|
Rom0Label2:
|
||||||
0
test/asm/load-pushs-load.err
Normal file
0
test/asm/load-pushs-load.err
Normal file
0
test/asm/load-pushs-load.out
Normal file
0
test/asm/load-pushs-load.out
Normal file
1
test/asm/load-pushs-load.out.bin
Normal file
1
test/asm/load-pushs-load.out.bin
Normal file
@@ -0,0 +1 @@
|
|||||||
|
$$<13><><EFBFBD><EFBFBD><EFBFBD>F<EFBFBD>F<EFBFBD><46>
|
||||||
15
test/asm/load-pushs.asm
Normal file
15
test/asm/load-pushs.asm
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
SECTION "Output", ROM0[0]
|
||||||
|
db SIZEOF("ROM CODE")
|
||||||
|
db SIZEOF("RAM CODE")
|
||||||
|
db SIZEOF("HRAM")
|
||||||
|
|
||||||
|
|
||||||
|
SECTION "ROM CODE",ROM0
|
||||||
|
ds $80
|
||||||
|
LOAD "RAM CODE",SRAM
|
||||||
|
PUSHS
|
||||||
|
SECTION "HRAM",HRAM
|
||||||
|
ds 1
|
||||||
|
POPS
|
||||||
|
ENDL
|
||||||
0
test/asm/load-pushs.err
Normal file
0
test/asm/load-pushs.err
Normal file
0
test/asm/load-pushs.out
Normal file
0
test/asm/load-pushs.out
Normal file
BIN
test/asm/load-pushs.out.bin
Normal file
BIN
test/asm/load-pushs.out.bin
Normal file
Binary file not shown.
Reference in New Issue
Block a user