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

@@ -18,7 +18,8 @@ struct Expression;
struct Section {
char *pzName;
enum SectionType nType;
uint32_t nPC;
bool isUnion;
uint32_t size;
uint32_t nOrg;
uint32_t nBank;
uint32_t nAlign;
@@ -28,25 +29,26 @@ struct Section {
};
struct SectionSpec {
int32_t bank;
int32_t alignment;
uint32_t bank;
uint32_t alignment;
};
struct Section *out_FindSectionByName(const char *pzName);
void out_NewSection(char const *pzName, uint32_t secttype, int32_t org,
struct SectionSpec const *attributes);
void out_SetLoadSection(char const *name, uint32_t secttype, int32_t org,
void out_NewSection(char const *pzName, uint32_t secttype, uint32_t org,
struct SectionSpec const *attributes, bool isUnion);
void out_SetLoadSection(char const *name, uint32_t secttype, uint32_t org,
struct SectionSpec const *attributes);
void out_EndLoadSection(void);
struct Section *sect_GetSymbolSection(void);
uint32_t sect_GetOutputOffset(void);
void out_AbsByte(uint8_t b);
void out_AbsByteGroup(uint8_t const *s, int32_t length);
void out_Skip(int32_t skip);
void out_String(char const *s);
void out_RelByte(struct Expression *expr);
void out_RelBytes(struct Expression *expr, int32_t n);
void out_RelBytes(struct Expression *expr, uint32_t n);
void out_RelWord(struct Expression *expr);
void out_RelLong(struct Expression *expr);
void out_PCRelByte(struct Expression *expr);