//
-// RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
+// RMAC - Renamed Macro Assembler for all Atari computers
// SYMBOL.C - Symbol Handling
-// Copyright (C) 199x Landon Dyer, 2011-2012 Reboot and Friends
+// Copyright (C) 199x Landon Dyer, 2011-2021 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"
'a', 't', 'd', '!', 'b', SPACE, SPACE, SPACE
};
+// Internal function prototypes
+static uint16_t WriteLODSection(int, uint16_t);
+
//
// Initialize symbol table
symbol->sorder = NULL;
symbol->uid = currentUID++;
+ // Record filename the symbol is defined (for now only used by macro error reporting)
+ symbol->cfileno = cfileno;
+
// Install symbol in the symbol table
int hash = HashSymbol(name, envno);
symbol->snext = symbolTable[hash];
// Export vanilla labels (but don't make them global). An exception is
// made for equates, which are not exported unless they are referenced.
else if (sy->stype == LABEL && lsym_flag
- && (sy->sattr & (DEFINED | REFERENCED)) != 0
- && (!as68_flag || *sy->sname != 'L'))
+ && (sy->sattr & (DEFINED | REFERENCED)) != 0)
{
sy->senv = scount++;
}
}
- // For ELF object mode run through all symbols in reference order
- // and export all global-referenced labels. Not sure if this is
- // required but it's here nonetheless
-/* why?? when you have sy_assign_ELF ???
- if (obj_format == ELF)
- {
- for(sy=sdecl; sy!=NULL; sy=sy->sorder)
- {
- if ((sy->sattr == (GLOBAL | REFERENCED)) && (buf != NULL))
- {
- buf = (*construct)(buf, sy, 0);
- scount++;
- }
- }
- }*/
-
return scount;
}
{
uint16_t scount = 0;
-// if (construct == (uint8_t *(*)())constr_elfsymtab)
-// if (buf == NULL)
- {
- // Append all symbols not appearing on the .sdecl list to the end of
- // the .sdecl list
- for(SYM * sy=sorder; sy!=NULL; sy=sy->sorder)
- AddToSymbolDeclarationList(sy);
- }
+ // Append all symbols not appearing on the .sdecl list to the end of
+ // the .sdecl list
+ for(SYM * sy=sorder; sy!=NULL; sy=sy->sorder)
+ AddToSymbolDeclarationList(sy);
// Run through all symbols (now on the .sdecl list) and assign numbers to
// them. We also pick which symbols should be global or not here.
for(SYM * sy=sdecl; sy!=NULL; sy=sy->sdecl)
{
- // Export or import external references, and export COMMON blocks.
- //if ((sy->stype == LABEL)
- // && ((sy->sattr & (GLOBAL | DEFINED)) == (GLOBAL | DEFINED)
- // || (sy->sattr & (GLOBAL | REFERENCED)) == (GLOBAL | REFERENCED))
- // || (sy->sattr & COMMON))
- //{
- // sy->senv = (WORD)scount++;
- //
- // if (buf != NULL)
- // buf = (*construct)(buf, sy, 1);
- //}
// 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)
- //if (sy->stype == 0)
- // if (lsym_flag)
- // if ((sy->sattr & (DEFINED | REFERENCED)) != 0)
- // if ((!as68_flag || *sy->sname != 'L'))
+ && (sy->sattr & GLOBAL) == 0
+ && (sy->sattre & (EQUATEDREG | UNDEF_EQUR | EQUATEDCC | UNDEF_CC)) == 0)
{
sy->senv = scount++;
// and export all global-referenced labels. Not sure if this is
// required but it's here nonetheless
- //for(sy=sdecl; sy!=NULL; sy=sy->sorder)
for(SYM * sy=sdecl; sy!=NULL; sy=sy->sdecl)
{
if ((sy->stype == LABEL)
+ && (sy->sattre & (EQUATEDREG | UNDEF_EQUR | EQUATEDCC | UNDEF_CC)) == 0
&& ((sy->sattr & (GLOBAL | DEFINED)) == (GLOBAL | DEFINED)
|| (sy->sattr & (GLOBAL | REFERENCED)) == (GLOBAL | REFERENCED))
|| (sy->sattr & COMMON))
if (buf != NULL)
buf = construct(buf, sy, 1);
}
- else if ((sy->sattr == (GLOBAL | REFERENCED)) && (buf != NULL))
+ else if ((sy->sattr == (GLOBAL | REFERENCED)) && (buf != NULL) && (sy->sattre & (EQUATEDREG | UNDEF_EQUR | EQUATEDCC | UNDEF_CC)) == 0)
{
buf = construct(buf, sy, 0);
scount++;
}
+//
+// 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
//
//
int symtable(void)
{
- extern int pagelen;
int i;
int j;
SYM * q = NULL;
strcpy(ln2, "external");
else
{
- sprintf(ln2, "%08X", q->svalue);
+ sprintf(ln2, "%016lX", q->svalue);
ToUppercase(ln2);
}