Avoid performing invalid actions on LOAD errors

These are rejected because they could lead to incorrect behavior,
so then don't do it...
This commit is contained in:
ISSOtm
2021-05-02 23:42:53 +02:00
parent 8397b3d8ec
commit 02cb5a0526
2 changed files with 13 additions and 5 deletions

View File

@@ -417,11 +417,15 @@ void out_SetLoadSection(char const *name, uint32_t type, uint32_t org,
if (!checkcodesection())
return;
if (currentLoadSection)
fatalerror("`LOAD` blocks cannot be nested\n");
if (currentLoadSection) {
error("`LOAD` blocks cannot be nested\n");
return;
}
if (sect_HasData(type))
if (sect_HasData(type)) {
error("`LOAD` blocks cannot create a ROM section\n");
return;
}
struct Section *sect = getSection(name, type, org, attribs, mod);
@@ -433,8 +437,10 @@ void out_SetLoadSection(char const *name, uint32_t type, uint32_t org,
void out_EndLoadSection(void)
{
if (!currentLoadSection)
if (!currentLoadSection) {
error("Found `ENDL` outside of a `LOAD` block\n");
return;
}
changeSection();
curOffset += loadOffset;

View File

@@ -1,3 +1,5 @@
ERROR: load-rom.asm(3):
`LOAD` blocks cannot create a ROM section
error: Assembly aborted (1 error)!
ERROR: load-rom.asm(5):
Found `ENDL` outside of a `LOAD` block
error: Assembly aborted (2 errors)!