As it turns out, this was not due to malice but because RMAC was set up
to squeeze out every label ever defined in the assembly. Hopefully,
with this patch, things should be a bit more sane. :-)
//
// RMAC - Renamed Macro Assembler for all Atari computers
// OBJECT.C - Writing Object Files
//
// RMAC - Renamed Macro Assembler for all Atari computers
// OBJECT.C - Writing Object Files
-// Copyright (C) 199x Landon Dyer, 2011-2021 Reboot and Friends
+// Copyright (C) 199x Landon Dyer, 2011-2022 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source utilised with the kind permission of Landon Dyer
//
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source utilised with the kind permission of Landon Dyer
//
static void WriteLOD(void);
static void WriteP56(void);
static void WriteLOD(void);
static void WriteP56(void);
//
// Add entry to symbol table (in ALCYON mode)
// If 'globflag' is 1, make the symbol global
//
// Add entry to symbol table (in ALCYON mode)
// If 'globflag' is 1, make the symbol global
//
// Add an entry to the BSD symbol table
//
//
// Add an entry to the BSD symbol table
//
z = 0x02000000; // Set equated flag
}
z = 0x02000000; // Set equated flag
}
- // If a symbol is both EQUd and flagged as TBD then we let
- // the later take precedence. Otherwise the linker will not even
- // bother trying to relocate the address during link time
+ // If a symbol is both EQUd and flagged as TBD then we let the latter take
+ // precedence. Otherwise the linker will not even bother trying to relocate
+ // the address during link time.
//
// Add entry to ELF symbol table; if `globflag' is 1, make the symbol global
//
//
// Add entry to ELF symbol table; if `globflag' is 1, make the symbol global
//
//
// Helper function for ELF output
//
//
// Helper function for ELF output
//
//
// Deposit an entry in the Section Header string table
//
//
// Deposit an entry in the Section Header string table
//
//
// Deposit a symbol table entry in the ELF Symbol Table
//
//
// Deposit a symbol table entry in the ELF Symbol Table
//
//
// Write an object file to the passed in file descriptor
// N.B.: Return value is ignored...
//
// Write an object file to the passed in file descriptor
// N.B.: Return value is ignored...
printf("Total : %d bytes\n", sect[TEXT].sloc + sect[DATA].sloc + sect[BSS].sloc);
}
printf("Total : %d bytes\n", sect[TEXT].sloc + sect[DATA].sloc + sect[BSS].sloc);
}
- sy_assign(NULL, NULL); // Assign index numbers to the symbols
+ AssignSymbolNos(NULL, NULL); // Assign index numbers to the symbols
tds = sect[TEXT].sloc + sect[DATA].sloc; // Get size of TEXT and DATA segment
tds = sect[TEXT].sloc + sect[DATA].sloc; // Get size of TEXT and DATA segment
- buf = malloc(0x800000); // Allocate 8MB object file image memory
+ buf = malloc(0x800000); // Allocate 8MB object file image memory
// Point to start of symbol table
p = buf + BSDHDRSIZE + tds + trsize + drsize;
// Point to start of symbol table
p = buf + BSDHDRSIZE + tds + trsize + drsize;
- sy_assign(p, AddBSDSymEntry); // Build symbol and string tables
+ AssignSymbolNos(p, AddBSDSymEntry); // Build symbol and string tables
chptr = buf + 0x10; // Point to sym table size hdr entry
D_long(symsize); // Write the symbol table size
chptr = buf + 0x10; // Point to sym table size hdr entry
D_long(symsize); // Write the symbol table size
// Assign index numbers to the symbols, get # of symbols (we assume
// that all symbols can potentially be extended, hence the x28)
// (To clarify: 28 bytes is the size of an extended symbol)
// Assign index numbers to the symbols, get # of symbols (we assume
// that all symbols can potentially be extended, hence the x28)
// (To clarify: 28 bytes is the size of an extended symbol)
- uint32_t symbolMaxSize = sy_assign(NULL, NULL) * 28;
+ uint32_t symbolMaxSize = AssignSymbolNos(NULL, NULL) * 28;
// Alloc memory for header + text + data, symbol and relocation
// information construction.
// Alloc memory for header + text + data, symbol and relocation
// information construction.
// Construct symbol table and update the header entry, if necessary
if (prg_flag > 1)
{
// Construct symbol table and update the header entry, if necessary
if (prg_flag > 1)
{
- // sy_assign with AddSymEntry updates symsize (stays 0 otherwise)
- sy_assign(buf + HDRSIZE + tds, AddSymEntry);
+ // AssignSymbolNos with AddSymEntry updates symsize (stays 0 otherwise)
+ AssignSymbolNos(buf + HDRSIZE + tds, AddSymEntry);
chptr = buf + 0x0E; // Point to symbol table size entry
D_long(symsize);
chptr = buf + 0x0E; // Point to symbol table size entry
D_long(symsize);
- int numSymbols = sy_assign_ELF(buf + elfSize, AddELFSymEntry);
+ int numSymbols = AssignSymbolNosELF(buf + elfSize, AddELFSymEntry);
elfSize += numSymbols * 0x10;
// String table
elfSize += numSymbols * 0x10;
// String table
if (buf == NULL)
return error("cannot allocate object file memory (in P56/LOD mode)");
if (buf == NULL)
return error("cannot allocate object file memory (in P56/LOD mode)");
-// objImage = buf; // Set global object image pointer
-
memset(buf, 0, 0x600000); // Clear allocated memory
// Iterate through DSP ram buffers
memset(buf, 0, 0x600000); // Clear allocated memory
// Iterate through DSP ram buffers
else if (obj_format == RAW)
{
if (!org68k_active)
else if (obj_format == RAW)
{
if (!org68k_active)
return error("cannot output absolute binary without a starting address (.org or command line)");
return error("cannot output absolute binary without a starting address (.org or command line)");
// Alloc memory for text + data construction.
tds = sect[TEXT].sloc + sect[DATA].sloc;
// Alloc memory for text + data construction.
tds = sect[TEXT].sloc + sect[DATA].sloc;
p = buf;
objImage = buf; // Set global object image pointer
p = buf;
objImage = buf; // Set global object image pointer
- for (i = TEXT; i <= DATA; i++)
+ for(i=TEXT; i<=DATA; i++)
- for (cp = sect[i].sfcode; cp != NULL; cp = cp->chnext)
+ for(cp=sect[i].sfcode; cp!=NULL; cp=cp->chnext)
{
memcpy(p, cp->chptr, cp->ch_size);
p += cp->ch_size;
{
memcpy(p, cp->chptr, cp->ch_size);
p += cp->ch_size;
static void WriteLOD(void)
{
D_printf("_START %s 0000 0000 0000 RMAC %01i.%01i.%01i\n\n", firstfname, MAJOR, MINOR, PATCH);
static void WriteLOD(void)
{
D_printf("_START %s 0000 0000 0000 RMAC %01i.%01i.%01i\n\n", firstfname, MAJOR, MINOR, PATCH);
D_printf("\n_END %.4X\n", dsp_orgmap[0].orgadr);
}
D_printf("\n_END %.4X\n", dsp_orgmap[0].orgadr);
}
static void WriteP56(void)
{
for(DSP_ORG * l=&dsp_orgmap[0]; l<dsp_currentorg; l++)
static void WriteP56(void)
{
for(DSP_ORG * l=&dsp_orgmap[0]; l<dsp_currentorg; l++)
SETBE24(p_buf_len, chunk_size / 3);
}
}
SETBE24(p_buf_len, chunk_size / 3);
}
}
//
// RMAC - Renamed Macro Assembler for all Atari computers
// OBJECT.H - Writing Object Files
//
// RMAC - Renamed Macro Assembler for all Atari computers
// OBJECT.H - Writing Object Files
-// Copyright (C) 199x Landon Dyer, 2011-2021 Reboot and Friends
+// Copyright (C) 199x Landon Dyer, 2011-2022 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source utilised with the kind permission of Landon Dyer
//
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source utilised with the kind permission of Landon Dyer
//
//
// RMAC - Renamed Macro Assembler for all Atari computers
// PROCLN.C - Line Processing
//
// RMAC - Renamed Macro Assembler for all Atari computers
// PROCLN.C - Line Processing
-// Copyright (C) 199x Landon Dyer, 2011-2021 Reboot and Friends
+// Copyright (C) 199x Landon Dyer, 2011-2022 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source utilised with the kind permission of Landon Dyer
//
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source utilised with the kind permission of Landon Dyer
//
M_FPSCR // 0123
}; // 0123 length
M_FPSCR // 0123
}; // 0123 length
// Function prototypes
int HandleLabel(char *, int);
// Function prototypes
int HandleLabel(char *, int);
//
// Initialize line processor
//
//
// Initialize line processor
//
//
// Handle the creation of labels
//
//
// Handle the creation of labels
//
//
// RMAC - Renamed Macro Assembler for all Atari computers
// PROCLN.H - Line Processing
//
// RMAC - Renamed Macro Assembler for all Atari computers
// PROCLN.H - Line Processing
-// Copyright (C) 199x Landon Dyer, 2011-2021 Reboot and Friends
+// Copyright (C) 199x Landon Dyer, 2011-2022 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source utilised with the kind permission of Landon Dyer
//
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source utilised with the kind permission of Landon Dyer
//
//
// RMAC - Renamed Macro Assembler for all Atari computers
// RMAC.C - Main Application Code
//
// RMAC - Renamed Macro Assembler for all Atari computers
// RMAC.C - Main Application Code
-// Copyright (C) 199x Landon Dyer, 2011-2021 Reboot and Friends
+// Copyright (C) 199x Landon Dyer, 2011-2022 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source utilised with the kind permission of Landon Dyer
//
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source utilised with the kind permission of Landon Dyer
//
int verb_flag; // Be verbose about what's going on
int m6502; // 1, assembling 6502 code
int glob_flag; // Assume undefined symbols are global
int verb_flag; // Be verbose about what's going on
int m6502; // 1, assembling 6502 code
int glob_flag; // Assume undefined symbols are global
-int lsym_flag; // Include local symbols in object file
+int lsym_flag; // Include local symbols in object file (ALWAYS true)
int optim_warn_flag; // Warn about possible short branches
int prg_flag; // !=0, produce .PRG executable (2=symbols)
int prg_extend; // !=0, output extended .PRG symbols
int optim_warn_flag; // Warn about possible short branches
int prg_flag; // !=0, produce .PRG executable (2=symbols)
int prg_extend; // !=0, output extended .PRG symbols
"| | | | | | | | (_| | (__ \n"
"|_| |_| |_| |_|\\__,_|\\___|\n"
"\nRenamed Macro Assembler\n"
"| | | | | | | | (_| | (__ \n"
"|_| |_| |_| |_|\\__,_|\\___|\n"
"\nRenamed Macro Assembler\n"
- "Copyright (C) 199x Landon Dyer, 2011-2021 Reboot and Friends\n"
+ "Copyright (C) 199x Landon Dyer, 2011-2022 Reboot and Friends\n"
"V%01i.%01i.%01i %s (%s)\n\n", MAJOR, MINOR, PATCH, __DATE__, PLATFORM);
}
"V%01i.%01i.%01i %s (%s)\n\n", MAJOR, MINOR, PATCH, __DATE__, PLATFORM);
}
//
// RMAC - Renamed Macro Assembler for all Atari computers
// RMAC.H - Main Application Code
//
// RMAC - Renamed Macro Assembler for all Atari computers
// RMAC.H - Main Application Code
-// Copyright (C) 199x Landon Dyer, 2011-2021 Reboot and Friends
+// Copyright (C) 199x Landon Dyer, 2011-2022 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source utilised with the kind permission of Landon Dyer
//
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source utilised with the kind permission of Landon Dyer
//
//
// RMAC - Renamed Macro Assembler for all Atari computers
// SYMBOL.C - Symbol Handling
//
// RMAC - Renamed Macro Assembler for all Atari computers
// SYMBOL.C - Symbol Handling
-// Copyright (C) 199x Landon Dyer, 2011-2021 Reboot and Friends
+// Copyright (C) 199x Landon Dyer, 2011-2022 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source utilised with the kind permission of Landon Dyer
//
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source utilised with the kind permission of Landon Dyer
//
// Internal function prototypes
static uint16_t WriteLODSection(int, uint16_t);
// Internal function prototypes
static uint16_t WriteLODSection(int, uint16_t);
//
// Initialize symbol table
//
//
// Initialize symbol table
//
//
// Hash the ASCII name and enviroment number
//
//
// Hash the ASCII name and enviroment number
//
return sum & (NBUCKETS - 1);
}
return sum & (NBUCKETS - 1);
}
//
// Make a new symbol of type 'type' in enviroment 'envno'
//
//
// Make a new symbol of type 'type' in enviroment 'envno'
//
//
// Look up the symbol name by its UID and return the pointer to the name.
// If it's not found, return NULL.
//
// Look up the symbol name by its UID and return the pointer to the name.
// If it's not found, return NULL.
//
// Lookup the symbol 'name', of the specified type, with the specified
// enviroment level
//
// Lookup the symbol 'name', of the specified type, with the specified
// enviroment level
//
// Put symbol on "order-of-declaration" list of symbols
//
//
// Put symbol on "order-of-declaration" list of symbols
//
//
// Make all referenced, undefined symbols global
//
//
// Make all referenced, undefined symbols global
//
//
// Assign numbers to symbols that are to be exported or imported. The symbol
// number is put in 'senv'. Returns the number of symbols that will be in the
//
// Assign numbers to symbols that are to be exported or imported. The symbol
// number is put in 'senv'. Returns the number of symbols that will be in the
// count of the # of symbols in the symbol table, and the second is to
// actually create it.
//
// count of the # of symbols in the symbol table, and the second is to
// actually create it.
//
-uint32_t sy_assign(uint8_t * buf, uint8_t *(* construct)())
+uint32_t AssignSymbolNos(uint8_t * buf, uint8_t *(* construct)())
// them. We also pick which symbols should be global or not here.
for(SYM * sy=sdecl; sy!=NULL; sy=sy->sdecl)
{
// them. We also pick which symbols should be global or not here.
for(SYM * sy=sdecl; sy!=NULL; sy=sy->sdecl)
{
+ // Skip non-labels
+ if (sy->stype != LABEL)
+ continue;
+
+ // Nuke equated register/CC symbols from orbit:
+ if (sy->sattre & (EQUATEDREG | UNDEF_EQUR | EQUATEDCC | UNDEF_CC))
+ continue;
+
// Export or import external references, and export COMMON blocks.
// 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))
+ // N.B.: This says to mark the symbol as global if either 1) the symbol
+ // is global AND the symbol is defined OR referenced, or 2) this
+ // symbol is a common symbol.
+ if (((sy->sattr & GLOBAL) && (sy->sattr & (DEFINED | REFERENCED)))
|| (sy->sattr & COMMON))
{
sy->senv = scount++;
|| (sy->sattr & COMMON))
{
sy->senv = scount++;
}
// Export vanilla labels (but don't make them global). An exception is
// made for equates, which are not exported unless they are referenced.
}
// 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)
+ // ^^^ The above just might be bullshit. ^^^
+ // N.B.: This says if the symbol is either defined OR referenced (but
+ // because of the above we know it *won't* be GLOBAL). And
+ // lsym_flag is always set true in Process() in rmac.c.
+ else if (lsym_flag && (sy->sattr & (DEFINED | REFERENCED)))
-// Custom version of sy_assign for ELF .o files.
+// Custom version of AssignSymbolNos for ELF .o files.
// The order that the symbols should be dumped is different.
// (globals must be explicitly at the end of the table)
//
// The order that the symbols should be dumped is different.
// (globals must be explicitly at the end of the table)
//
-// N.B.: It should be possible to merge this with sy_assign, as there's nothing
-// really ELF specific in here, other than the "globals go at the end of
-// the queue" thing, which doesn't break the others. :-P
-uint32_t sy_assign_ELF(uint8_t * buf, uint8_t *(* construct)())
+// N.B.: It should be possible to merge this with AssignSymbolNos, as there's
+// nothing really ELF specific in here, other than the "globals go at the
+// end of the queue" thing, which doesn't break the others. :-P
+uint32_t AssignSymbolNosELF(uint8_t * buf, uint8_t *(* construct)())
}
else if ((sy->sattr == (GLOBAL | REFERENCED)) && (buf != NULL) && (sy->sattre & (EQUATEDREG | UNDEF_EQUR | EQUATEDCC | UNDEF_CC)) == 0)
{
}
else if ((sy->sattr == (GLOBAL | REFERENCED)) && (buf != NULL) && (sy->sattre & (EQUATEDREG | UNDEF_EQUR | EQUATEDCC | UNDEF_CC)) == 0)
{
- buf = construct(buf, sy, 0);
+ buf = construct(buf, sy, 0); // <-- this creates a NON-global symbol...
//
// Helper function for dsp_lod_symbols
//
//
// Helper function for dsp_lod_symbols
//
//
// Dump LOD style symbols into the passed in buffer
//
//
// Dump LOD style symbols into the passed in buffer
//
//WriteLODSection(M56001?, count);
}
//WriteLODSection(M56001?, count);
}
//
// Convert string to uppercase
//
//
// Convert string to uppercase
//
//
// Generate symbol table for listing file
//
//
// Generate symbol table for listing file
//
//
// RMAC - Renamed Macro Assembler for all Atari computers
// SYMBOL.H - Symbol Handling
//
// RMAC - Renamed Macro Assembler for all Atari computers
// SYMBOL.H - Symbol Handling
-// Copyright (C) 199x Landon Dyer, 2011-2021 Reboot and Friends
+// Copyright (C) 199x Landon Dyer, 2011-2022 Reboot and Friends
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source utilised with the kind permission of Landon Dyer
//
// RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
// Source utilised with the kind permission of Landon Dyer
//
void AddToSymbolDeclarationList(SYM *);
void ForceUndefinedSymbolsGlobal(void);
int symtable(void);
void AddToSymbolDeclarationList(SYM *);
void ForceUndefinedSymbolsGlobal(void);
int symtable(void);
-uint32_t sy_assign(uint8_t *, uint8_t *(*)());
-uint32_t sy_assign_ELF(uint8_t *, uint8_t *(*)());
+uint32_t AssignSymbolNos(uint8_t *, uint8_t *(*)());
+uint32_t AssignSymbolNosELF(uint8_t *, uint8_t *(*)());
void DumpLODSymbols(void);
uint8_t * GetSymbolNameByUID(uint32_t);
void DumpLODSymbols(void);
uint8_t * GetSymbolNameByUID(uint32_t);
#define MAJOR 2 // Major version number
#define MINOR 2 // Minor version number
#define MAJOR 2 // Major version number
#define MINOR 2 // Minor version number
-#define PATCH 1 // Patch release number
+#define PATCH 2 // Patch release number