From d4c55e2f481bccadbcb080de3fbe409b1524957f Mon Sep 17 00:00:00 2001 From: neauoire Date: Fri, 9 Dec 2022 12:30:04 -0800 Subject: [PATCH] Uxnasm now outputs a symbols file --- projects/utils/metadata.tal | 2 +- src/uxnasm.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/projects/utils/metadata.tal b/projects/utils/metadata.tal index b1fb140..42236bc 100644 --- a/projects/utils/metadata.tal +++ b/projects/utils/metadata.tal @@ -15,7 +15,7 @@ #f0af .System/g DEO2 #f0af .System/b DEO2 - #0130 .Screen/width DEO2 + #0150 .Screen/width DEO2 #0050 .Screen/height DEO2 ;await-src .Console/vector DEO2 diff --git a/src/uxnasm.c b/src/uxnasm.c index 050debb..8da9289 100644 --- a/src/uxnasm.c +++ b/src/uxnasm.c @@ -448,6 +448,21 @@ review(char *filename) p.mlen); } +static void +writesym(char *filename) +{ + char symdst[0x40]; + FILE *fp = fopen(scat(scpy(filename, symdst, slen(filename) + 1), ".sym"), "w"); + int i; + if(fp != NULL) { + for(i = 0; i < p.llen; i++) { + fwrite(&p.labels[i].addr, 2, 1, fp); + fwrite(p.labels[i].name, slen(p.labels[i].name) + 1, 1, fp); + } + } + fclose(fp); +} + int main(int argc, char *argv[]) { @@ -464,5 +479,6 @@ main(int argc, char *argv[]) return !error("Assembly", "Output rom is empty."); fwrite(p.data + TRIM, p.length - TRIM, 1, dst); review(argv[2]); + writesym(argv[2]); return 0; }