This stemmed from the fact that EQUR symbols somehow made it on to the
symbol declaration list. If such symbol was later .equrundef'd, it would
find it's way back onto the the sdecl list *twice*, with the result
that any symbols that came after it would be summarily discarded into
the ether. Really, really bad mojo.
switch(*tok)
{
case STRING:
switch(*tok)
{
case STRING:
-// sprintf(prntstr, "%s", (char *)tok[1]);
sprintf(prntstr, "%s", string[tok[1]]);
printf("%s", prntstr);
sprintf(prntstr, "%s", string[tok[1]]);
printf("%s", prntstr);
error("syntax error; expected symbol");
return ERROR;
}
error("syntax error; expected symbol");
return ERROR;
}
-// ccname = lookup((char *)tok[1], LABEL, 0);
ccname = lookup(string[tok[1]], LABEL, 0);
// Make sure symbol is a valid ccdef
ccname = lookup(string[tok[1]], LABEL, 0);
// Make sure symbol is a valid ccdef
{
unsigned skip = (rgpu || rdsp ? orgaddr : sloc) & 0x01;
{
unsigned skip = (rgpu || rdsp ? orgaddr : sloc) & 0x01;
if (skip)
{
if ((scattr & SBSS) == 0)
if (skip)
{
if ((scattr & SBSS) == 0)
char buf[128];
char buf1[128];
char buf[128];
char buf1[128];
- if (*tok == STRING) // Leave strings ALONE
-#if 0
- fn = (char *)*++tok;
-#else
+ if (*tok == STRING) // Leave strings ALONE
-#endif
- else if (*tok == SYMBOL) // Try to append ".s" to symbols
+ else if (*tok == SYMBOL) // Try to append ".s" to symbols
-#if 0
- strcpy(buf, (char *)*++tok);
-#else
strcpy(buf, string[*++tok]);
strcpy(buf, string[*++tok]);
fext(buf, ".s", 0);
fn = &buf[0];
}
fext(buf, ".s", 0);
fn = &buf[0];
}
- else // Punt if no STRING or SYMBOL
+ else // Punt if no STRING or SYMBOL
return error("missing filename");
// Make sure the user didn't try anything like:
return error("missing filename");
// Make sure the user didn't try anything like:
if (*tok != SYMBOL)
return error("missing symbol");
if (*tok != SYMBOL)
return error("missing symbol");
p = string[tok[1]];
tok += 2;
p = string[tok[1]];
tok += 2;
-#if 0
- if (*p == '.')
- env = curenv; // Label is local
- else
- env = 0; // Label is global
-#else
// Set env to either local (dot prefixed) or global scope
env = (*p == '.' ? curenv : 0);
// Set env to either local (dot prefixed) or global scope
env = (*p == '.' ? curenv : 0);
symbol = lookup(p, LABEL, env);
if (symbol == NULL)
symbol = lookup(p, LABEL, env);
if (symbol == NULL)
return errors("multiply-defined label '%s'", p);
// Put symbol in "order of definition" list
return errors("multiply-defined label '%s'", p);
// Put symbol in "order of definition" list
- if (!(symbol->sattr & SDECLLIST))
- AddToSymbolOrderList(symbol);
+ AddToSymbolDeclarationList(symbol);
symbol->sattr |= (ABS | DEFINED | EQUATED);
symbol->svalue = eval;
symbol->sattr |= (ABS | DEFINED | EQUATED);
symbol->svalue = eval;
if (reglist(&rlist) < 0)
return 0;
if (reglist(&rlist) < 0)
return 0;
-// for(i=0; i++<16; rlist>>=1)
for(i=0; i<16; i++, rlist>>=1)
{
if (rlist & 1)
for(i=0; i<16; i++, rlist>>=1)
{
if (rlist & 1)
return errors("multiply-defined label '%s'", symbolName);
// Put symbol in "order of definition" list
return errors("multiply-defined label '%s'", symbolName);
// Put symbol in "order of definition" list
- if (!(symbol->sattr & SDECLLIST))
- AddToSymbolOrderList(symbol);
+ AddToSymbolDeclarationList(symbol);
j = (*p == '.' ? curenv : 0);
symbol = lookup(p, LABEL, j);
#if 0
j = (*p == '.' ? curenv : 0);
symbol = lookup(p, LABEL, j);
#if 0
-printf("eval: Looking up symbol [=%08X]\n", symbol);
+printf("eval: Looking up symbol (%s) [=%08X]\n", p, symbol);
if (symbol)
printf(" attr=%04X, attre=%08X, val=%i, name=%s\n", symbol->sattr, symbol->sattre, symbol->svalue, symbol->sname);
#endif
if (symbol)
printf(" attr=%04X, attre=%08X, val=%i, name=%s\n", symbol->sattr, symbol->sattre, symbol->svalue, symbol->sname);
#endif
*/
if (symbol->sattre & EQUATEDREG)
*a_value &= 0x1F;
*/
if (symbol->sattre & EQUATEDREG)
*a_value &= 0x1F;
*a_attr = (WORD)(symbol->sattr & ~GLOBAL);
if ((symbol->sattr & (GLOBAL | DEFINED)) == GLOBAL && a_esym != NULL)
*a_attr = (WORD)(symbol->sattr & ~GLOBAL);
if ((symbol->sattr & (GLOBAL | DEFINED)) == GLOBAL && a_esym != NULL)
{
//REALLY? sy->sattre |= ~UNDEF_EQUR;
sy->sattre &= ~UNDEF_EQUR;
{
//REALLY? sy->sattre |= ~UNDEF_EQUR;
sy->sattre &= ~UNDEF_EQUR;
}
else if ((equtyp == CCDEF) && (sy->sattre & UNDEF_CC))
{
}
else if ((equtyp == CCDEF) && (sy->sattre & UNDEF_CC))
{
- // Put symbol in "order of definition" list
- if (!(sy->sattr & SDECLLIST))
- AddToSymbolOrderList(sy);
+ // Put symbol in "order of definition" list if it's not already there
+ AddToSymbolDeclarationList(sy);
// Parse value to equate symbol to;
// o .equr
// Parse value to equate symbol to;
// o .equr
else if (symbol->sattr & DEFINED)
return errors("multiply-defined label '%s'", label);
else if (symbol->sattr & DEFINED)
return errors("multiply-defined label '%s'", label);
- // Put symbol in "order of definition" list
- if (!(symbol->sattr & SDECLLIST))
- AddToSymbolOrderList(symbol);
+ // Put symbol in "order of definition" list if it's not already in it
+ AddToSymbolDeclarationList(symbol);
break;
// Single operand instructions (Rd)
break;
// Single operand instructions (Rd)
- // ABS, MIRROR, NEG, NOT, PACK, RESMAC, SAT8, SAT16, SAT16S, SAT24, SAT32S, UNPACK
+ // ABS, MIRROR, NEG, NOT, PACK, RESMAC, SAT8, SAT16, SAT16S, SAT24, SAT32S,
+ // UNPACK
case RI_ONE:
reg2 = GetRegister(FU_REGTWO);
at_eol();
case RI_ONE:
reg2 = GetRegister(FU_REGTWO);
at_eol();
break;
// Two operand instructions (Rs,Rd)
break;
// Two operand instructions (Rs,Rd)
- // ADD, ADDC, AND, CMP, DIV, IMACN, IMULT, IMULTN, MOVEFA, MOVETA, MULT, MMULT,
- // MTOI, NORMI, OR, ROR, SH, SHA, SUB, SUBC, XOR
+ // ADD, ADDC, AND, CMP, DIV, IMACN, IMULT, IMULTN, MOVEFA, MOVETA, MULT,
+ // MMULT, MTOI, NORMI, OR, ROR, SH, SHA, SUB, SUBC, XOR
case RI_TWO:
if (parm == 37)
altbankok = 1; // MOVEFA
case RI_TWO:
if (parm == 37)
altbankok = 1; // MOVEFA
case RI_NUM_31:
// Numeric operand (n,Rd) where n = 1..32
case RI_NUM_31:
// Numeric operand (n,Rd) where n = 1..32
- // ADDQ, ADDQMOD, ADDQT, SHARQ, SHLQ, SHRQ, SUBQ, SUBQMOD, SUBQT, ROLQ, RORQ
+ // ADDQ, ADDQMOD, ADDQT, SHARQ, SHLQ, SHRQ, SUBQ, SUBQMOD, SUBQT, ROLQ,
+ // RORQ
case RI_NUM_32:
switch (type)
{
case RI_NUM_32:
switch (type)
{
-//printf("risca: Doing rmark for RI_MOVEI (tdb=$%X)...\n", eattr & TDB);
+//printf("RISCASM: Doing rmark for RI_MOVEI (tdb=$%X)...\n", eattr & TDB);
rmark(cursect, sloc + 2, (eattr & TDB), (MLONG | MMOVEI), NULL);
//}
}
rmark(cursect, sloc + 2, (eattr & TDB), (MLONG | MMOVEI), NULL);
//}
}
void DisplayVersion(void)
{
printf("\nReboot's Macro Assembler for Atari Jaguar\n"
void DisplayVersion(void)
{
printf("\nReboot's Macro Assembler for Atari Jaguar\n"
- "Copyright (C) 199x Landon Dyer, 2011 Reboot\n"
+ "Copyright (C) 199x Landon Dyer, 2011-2015 Reboot\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);
}
MakeSection(i, 0);
// Construct default sections, make TEXT the current section
MakeSection(i, 0);
// Construct default sections, make TEXT the current section
- MakeSection(ABS, SUSED | SABS | SBSS); // ABS
- MakeSection(TEXT, SUSED | TEXT ); // TEXT
- MakeSection(DATA, SUSED | DATA ); // DATA
- MakeSection(BSS, SUSED | BSS | SBSS); // BSS
+ MakeSection(ABS, SUSED | SABS | SBSS); // ABS
+ MakeSection(TEXT, SUSED | TEXT ); // TEXT
+ MakeSection(DATA, SUSED | DATA ); // DATA
+ MakeSection(BSS, SUSED | BSS | SBSS); // BSS
// MakeSection(M6502, SUSED | TEXT ); // 6502 code section
// Switch to TEXT for starters
// MakeSection(M6502, SUSED | TEXT ); // 6502 code section
// Switch to TEXT for starters
// NYAN !
if ((attr & FUMASKRISC) == FU_JR)
{
// NYAN !
if ((attr & FUMASKRISC) == FU_JR)
{
+//printf("AddFixup: ((attr & FUMASKRISC) == FU_JR)\n");
// i = 18;
// i = FIXUP_BASE_SIZE + (sizeof(LONG) * 2);
i = FIXUP_BASE_SIZE + sizeof(SYM *) + sizeof(LONG);
}
else
{
// i = 18;
// i = FIXUP_BASE_SIZE + (sizeof(LONG) * 2);
i = FIXUP_BASE_SIZE + sizeof(SYM *) + sizeof(LONG);
}
else
{
+//printf("AddFixup: ((attr & FUMASKRISC) == FU_JR) ELSE\n");
// i = 14;
i = FIXUP_BASE_SIZE + sizeof(SYM *);
}
}
else
{
// i = 14;
i = FIXUP_BASE_SIZE + sizeof(SYM *);
}
}
else
{
+//printf("AddFixup: !SYMBOL\n");
attr |= FU_EXPR;
for(len=0; fexpr[len]!=ENDEXPR; len++)
attr |= FU_EXPR;
for(len=0; fexpr[len]!=ENDEXPR; len++)
i = FIXUP_BASE_SIZE + sizeof(WORD) + (len * sizeof(TOKEN));
}
i = FIXUP_BASE_SIZE + sizeof(WORD) + (len * sizeof(TOKEN));
}
- // Maybe alloc another fixup chunk for this one to fit in
+ // Alloc another fixup chunk for this one to fit in if necessary
if ((fchalloc - fchsize) < i)
{
p = §[cursect];
if ((fchalloc - fchsize) < i)
{
p = §[cursect];
{
// *fchptr.lp++ = (LONG)fexpr[1];
*fchptr.sy++ = symbolPtr[fexpr[1]];
{
// *fchptr.lp++ = (LONG)fexpr[1];
*fchptr.sy++ = symbolPtr[fexpr[1]];
+//printf("AddFixup: adding symbol (%s) [%08X]\n", symbolPtr[fexpr[1]]->sname, symbolPtr[fexpr[1]]->sattr);
}
// SCPCD : correct bit mask for attr (else other FU_xxx will match) NYAN !
}
// SCPCD : correct bit mask for attr (else other FU_xxx will match) NYAN !
//
int ResolveFixups(int sno)
{
//
int ResolveFixups(int sno)
{
- PTR fup; // Current fixup
- WORD * fuend; // End of last fixup (in this chunk)
- WORD w; // Fixup word (type+modes+flags)
- char * locp; // Location to fix (in cached chunk)
- LONG loc; // Location to fixup
- VALUE eval; // Expression value
- WORD eattr; // Expression attrib
- SYM * esym; // External symbol involved in expr
- SYM * sy; // (Temp) pointer to a symbol
- WORD i; // (Temp) word
- WORD tdb; // eattr & TDB
+ PTR fup; // Current fixup
+ WORD * fuend; // End of last fixup (in this chunk)
+ WORD w; // Fixup word (type+modes+flags)
+ char * locp; // Location to fix (in cached chunk)
+ LONG loc; // Location to fixup
+ VALUE eval; // Expression value
+ WORD eattr; // Expression attrib
+ SYM * esym; // External symbol involved in expr
+ SYM * sy; // (Temp) pointer to a symbol
+ WORD i; // (Temp) word
+ WORD tdb; // eattr & TDB
LONG oaddr;
int reg2;
WORD flags;
LONG oaddr;
int reg2;
WORD flags;
if ((eattr & (GLOBAL | DEFINED)) == GLOBAL)
esym = sy;
if ((eattr & (GLOBAL | DEFINED)) == GLOBAL)
esym = sy;
+printf("DoFixups: found symbol (%s) [%08X]\n", sy->sname, sy->sattr);
}
tdb = (WORD)(eattr & TDB);
}
tdb = (WORD)(eattr & TDB);
- interror(4); // Bad fixup type
+ // Bad fixup type--this should *never* happen!
+ interror(4);
// NOTREACHED
}
continue;
// NOTREACHED
}
continue;
//
// Put symbol on "order-of-declaration" list of symbols
//
//
// Put symbol on "order-of-declaration" list of symbols
//
-//void sym_decl(SYM * symbol)
-void AddToSymbolOrderList(SYM * symbol)
+void AddToSymbolDeclarationList(SYM * symbol)
- if (symbol->sattr & SDECLLIST)
- return; // Already on list
+ // Don't add if already on list, or it's an equated register/CC
+ if ((symbol->sattr & SDECLLIST)
+ || (symbol->sattre & (EQUATEDREG | UNDEF_EQUR | EQUATEDCC | UNDEF_CC)))
+ return;
- symbol->sattr |= SDECLLIST; // Mark "already on list"
+ // Mark as "on .sdecl list"
+ symbol->sattr |= SDECLLIST;
- sdecl = symbol; // First on decl-list
+ sdecl = symbol; // First on decl-list
- sdecltail->sdecl = symbol; // Add to end of list
+ sdecltail->sdecl = symbol; // Add to end of list
- symbol->sdecl = NULL; // Fix up list's tail
+ // Fix up list's tail
+ symbol->sdecl = NULL;
// Append all symbols not appearing on the .sdecl list to the end of
// the .sdecl list
for(sy=sorder; sy!=NULL; sy=sy->sorder)
// Append all symbols not appearing on the .sdecl list to the end of
// the .sdecl list
for(sy=sorder; sy!=NULL; sy=sy->sorder)
- {
- // Essentially the same as 'sym_decl()' above:
- if (sy->sattr & SDECLLIST)
- continue; // Already on list
-
- sy->sattr |= SDECLLIST; // Mark "on the list"
-
- if (sdecl == NULL)
- sdecl = sy; // First on decl-list
- else
- sdecltail->sdecl = sy; // Add to end of list
-
- sy->sdecl = NULL; // Fix up list's tail
- sdecltail = sy;
- }
+ 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(sy=sdecl; sy!=NULL; sy=sy->sdecl)
{
}
// 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(sy=sdecl; sy!=NULL; sy=sy->sdecl)
{
- if (sy->sattre & UNDEF_EQUR)
- continue; // Don't want undefined on our list
+ // Don't want register/CC or undefined on our list
+//these should already be rejected above...
+// if (sy->sattre & (EQUATEDREG | UNDEF_EQUR | EQUATEDCC | UNDEF_CC)))
+// continue;
- if (sy->sattre & UNDEF_CC)
- continue;
-
// Export or import external references, and export COMMON blocks.
if ((sy->stype == LABEL)
&& ((sy->sattr & (GLOBAL | DEFINED)) == (GLOBAL | DEFINED)
// Export or import external references, and export COMMON blocks.
if ((sy->stype == LABEL)
&& ((sy->sattr & (GLOBAL | DEFINED)) == (GLOBAL | DEFINED)
&& (!as68_flag || *sy->sname != 'L'))
{
sy->senv = (WORD)scount++;
&& (!as68_flag || *sy->sname != 'L'))
{
sy->senv = (WORD)scount++;
- if (buf != NULL) buf = (*constr)(buf, sy, 0);
+
+ if (buf != NULL)
+ buf = (*constr)(buf, sy, 0);
SYM * lookup(char *, int, int);
void InitSymbolTable(void);
SYM * NewSymbol(char *, int, int);
SYM * lookup(char *, int, int);
void InitSymbolTable(void);
SYM * NewSymbol(char *, int, int);
-void AddToSymbolOrderList(SYM *);
+void AddToSymbolDeclarationList(SYM *);
void ForceUndefinedSymbolsGlobal(void);
int symtable(void);
int sy_assign(char *, char *(*)());
void ForceUndefinedSymbolsGlobal(void);
int symtable(void);
int sy_assign(char *, char *(*)());
#define MAJOR 1 // Major version number
#define MINOR 3 // Minor version number
#define MAJOR 1 // Major version number
#define MINOR 3 // Minor version number
-#define PATCH 2 // Patch release number
+#define PATCH 3 // Patch release number