Here's a simple patch to add symbol file generation to uxnasm.
It might be preferable to hide it behind a command line argument to
avoid generating unwanted file clutter. Also, it shares enough code
with the review function that combining them might be worthwhile,
though that may just complicate the code.
-Dave
diff --git a/src/uxnasm.c b/src/uxnasm.c
index 050debb..8e5d418 100644
--- a/src/uxnasm.c
+++ b/src/uxnasm.c
@@ -448,6 +448,21 @@ review(char *filename)
p.mlen);
}
+static void
+writeSymbols(char *filename)
+{
+ char symFilename[0x40];
+ scat(scpy(filename, symFilename, spos(filename, '.')), ".sym");
+
+ FILE *fp = fopen(symFilename, "w");
+ int i;
+ if(fp != NULL) {
+ for(i = 0; i < p.llen; i++)
+ fprintf(fp, "%04x %s\n", p.labels[i].addr, p.labels[i].name);
+ }
+ 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]);
+ writeSymbols(argv[2]);
return 0;
}