]> Shamusworld >> Repos - rmac/blobdiff - symbol.c
Long forgotten helper script which is used to create tables for VS builds
[rmac] / symbol.c
index 87f90c048d80952a5a0cb18aec48035ae5905c36..c1abfab58693aa0427abb641a9451c6929c6db4d 100644 (file)
--- a/symbol.c
+++ b/symbol.c
@@ -1,12 +1,13 @@
 //
 // RMAC - Reboot's Macro Assembler for all Atari computers
 // SYMBOL.C - Symbol Handling
-// Copyright (C) 199x Landon Dyer, 2011-2018 Reboot and Friends
+// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends
 // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
 // Source utilised with the kind permission of Landon Dyer
 //
 
 #include "symbol.h"
+#include "dsp56k.h"
 #include "error.h"
 #include "listing.h"
 #include "object.h"
@@ -35,6 +36,9 @@ static uint8_t tdb_text[8] = {
    'a', 't', 'd', '!', 'b', SPACE, SPACE, SPACE
 };
 
+// Internal function prototypes
+static uint16_t WriteLODSection(int, uint16_t);
+
 
 //
 // Initialize symbol table
@@ -332,6 +336,53 @@ uint32_t sy_assign_ELF(uint8_t * buf, uint8_t *(* construct)())
 }
 
 
+//
+// Helper function for dsp_lod_symbols
+//
+static uint16_t WriteLODSection(int section, uint16_t symbolCount)
+{
+       for(SYM * sy=sdecl; sy!=NULL; sy=sy->sdecl)
+       {
+               // Export vanilla labels (but don't make them global). An exception is
+               // made for equates, which are not exported unless they are referenced.
+               if (sy->stype == LABEL && lsym_flag
+                       && (sy->sattr & (DEFINED | REFERENCED)) != 0
+                       && (*sy->sname != '.')
+                       && (sy->sattr & GLOBAL) == 0
+                       && (sy->sattr & (section)))
+               {
+                       sy->senv = symbolCount++;
+                       D_printf("%-19s   I %.6" PRIX64 "\n", sy->sname, sy->svalue);
+               }
+       }
+
+       return symbolCount;
+}
+
+
+//
+// Dump LOD style symbols into the passed in buffer
+//
+void DumpLODSymbols(void)
+{
+       D_printf("_SYMBOL P\n");
+       uint16_t count = WriteLODSection(M56001P, 0);
+
+       D_printf("_SYMBOL X\n");
+       count = WriteLODSection(M56001X, count);
+
+       D_printf("_SYMBOL Y\n");
+       count = WriteLODSection(M56001Y, count);
+
+       D_printf("_SYMBOL L\n");
+       count = WriteLODSection(M56001L, count);
+
+       // TODO: I've seen _SYMBOL N in there but no idea what symbols it needs...
+       //D_printf("_SYMBOL N\n");
+       //WriteLODSection(M56001?, count);
+}
+
+
 //
 // Convert string to uppercase
 //