For mlb files .section will use the address (set via .org) present at the time of
invoking .section as an offset address.
+ For mlb files ulas offers a few pre-defined section names that get translated to their
+ respective mlb names (wram == GbWorkRam; prgrom == GbPrgRom).
+
.SH SEE ALSO
ulas(1) for a rference on how to use ulas.
return rc;
}
+/**
+ * pre-defined mlb mappings
+ */
+#define ULAS_MLB_SECTION_PRGROM "prgrom"
+#define ULAS_MLB_SECTION_WORKRAM "wram"
+
int ulas_symbolout_mlbloc(FILE *dst, long addr) {
if (ulas.section[0] != '\0') {
- fprintf(dst, "%s:", ulas.section);
+ const char *section = ulas.section;
+
+ // statically map some ulas section names to mlb sections
+ if (strncmp(ULAS_MLB_SECTION_PRGROM, ulas.section, ULAS_SECTIONMAX) == 0) {
+ section = "GbPrgRom";
+ } else if (strncmp(ULAS_MLB_SECTION_WORKRAM, ulas.section,
+ ULAS_SECTIONMAX) == 0) {
+ section = "GbWorkRam";
+ }
+
+ fprintf(dst, "%s:", section);
return (int)ulas.section_address;
}
return 0;
}
- // TODO: maybe allow the user to define this by using
- // .section and just trust the label location in the source
- // is correct
+ // fallback
+ // if no previous section was declared we fall back to the
+ // old default output
switch (ulas.arch.type) {
case ULAS_ARCH_SM83:
if (addr >= 0x0000 && addr <= 0x7FFF) {
int ulas_asmdirsection(FILE *dst, FILE *src, const char **line,
unsigned long n) {
ulas_tok(&ulas.tok, line, n);
- if (!ulas_isname(ulas.tok.buf,
- MIN(strlen(ulas.tok.buf), ulas.tok.maxlen))) {
+ if (!ulas_isname(ulas.tok.buf, MIN(strlen(ulas.tok.buf), ulas.tok.maxlen))) {
ULASERR("Unexpected token '%s'\n", ulas.tok.buf);
return -1;
}