//
zpreq = 0;
- switch (tok.u32[0])
+ switch (tok[0])
{
case EOL:
amode = A65_IMPL;
break;
case '#':
- tok.u32++;
+ tok++;
- if (*tok.u32 == '>')
+ if (*tok == '>')
{
- tok.u32++;
+ tok++;
if (expr(exprbuf, &eval, &eattr, NULL) < 0)
return;
amode = A65_IMMEDH;
break;
}
- else if (*tok.u32 == '<')
+ else if (*tok == '<')
{
- tok.u32++;
+ tok++;
if (expr(exprbuf, &eval, &eattr, NULL) < 0)
return;
break;
case '(':
- tok.u32++;
+ tok++;
if (expr(exprbuf, &eval, &eattr, NULL) < 0)
return;
- if (*tok.u32 == ')')
+ if (*tok == ')')
{
// (foo) or (foo),y
- if (*++tok.u32 == ',')
+ if (*++tok == ',')
{
// (foo),y
- tok.u32++;
- p = string[tok.u32[1]];
+ tok++;
+ p = string[tok[1]];
- // Sleazo tolower() ---------------------vvvvvvvvvvv
- if (*tok.u32 != SYMBOL || p[1] != EOS || (*p | 0x20) != 'y')
+ // Sleazo tolower() -----------------vvvvvvvvvvv
+ if (*tok != SYMBOL || p[1] != EOS || (*p | 0x20) != 'y')
goto badmode;
- tok.u32 += 2;
+ tok += 2;
amode = A65_INDY;
}
else
amode = A65_IND;
}
- else if (*tok.u32 == ',')
+ else if (*tok == ',')
{
// (foo,x)
- tok.u32++;
- p = string[tok.u32[1]];
+ tok++;
+ p = string[tok[1]];
- // Sleazo tolower() ---------------------vvvvvvvvvvv
- if (*tok.u32 != SYMBOL || p[1] != EOS || (*p | 0x20) != 'x')
+ // Sleazo tolower() -----------------vvvvvvvvvvv
+ if (*tok != SYMBOL || p[1] != EOS || (*p | 0x20) != 'x')
goto badmode;
- tok.u32 += 2;
+ tok += 2;
- if (*tok.u32++ != ')')
+ if (*tok++ != ')')
goto badmode;
amode = A65_INDX;
break;
case '@':
- tok.u32++;
+ tok++;
if (expr(exprbuf, &eval, &eattr, NULL) < 0)
return;
- if (*tok.u32 == '(')
+ if (*tok == '(')
{
- tok.u32++;
- p = string[tok.u32[1]];
+ tok++;
+ p = string[tok[1]];
- if (*tok.u32 != SYMBOL || p[1] != EOS || tok.u32[2] != ')' || tok.u32[3] != EOL)
+ if (*tok != SYMBOL || p[1] != EOS || tok[2] != ')' || tok[3] != EOL)
goto badmode;
i = (*p | 0x20); // Sleazo tolower()
else
goto badmode;
- tok.u32 += 3; // Past SYMBOL <string> ')' EOL
+ tok += 3; // Past SYMBOL <string> ')' EOL
zpreq = 1; // Request zeropage optimization
}
- else if (*tok.u32 == EOL)
+ else if (*tok == EOL)
amode = A65_IND;
else
goto badmode;
// x,foo
// y,foo
//
- p = string[tok.u32[1]];
+ p = string[tok[1]];
// ggn: the following code is effectively disabled as it would make
// single letter labels not work correctly (would not identify the
// label properly). And from what I understand it's something to
zpreq = 1;
- if (*tok.u32 == EOL)
+ if (*tok == EOL)
amode = A65_ABS;
- else if (*tok.u32 == ',')
+ else if (*tok == ',')
{
- tok.u32++;
- p = string[tok.u32[1]];
+ tok++;
+ p = string[tok[1]];
- if (*tok.u32 != SYMBOL || p[1] != EOS)
+ if (*tok != SYMBOL || p[1] != EOS)
goto badmode;
- tok.u32 += 2;
+ tok += 2;
//
// Check for X or Y index register;
if (sloc > 0x10000L)
fatal("6502 code pointer > 64K");
- if (*tok.u32 != EOL)
+ if (*tok != EOL)
error(extra_stuff);
}
bf0esym = NULL;
// If at EOL, then no addr modes at all
- if (*tok.u32 == EOL)
+ if (*tok == EOL)
return 0;
// Parse first addressing mode
#define AnREG a0reg
#define AnIXREG a0ixreg
#define AnIXSIZ a0ixsiz
- #define AnEXPR (TOKENPTR)a0expr
+ #define AnEXPR a0expr
#define AnEXVAL a0exval
#define AnEXATTR a0exattr
- #define AnOEXPR (TOKENPTR)a0oexpr
+ #define AnOEXPR a0oexpr
#define AnOEXVAL a0oexval
#define AnOEXATTR a0oexattr
#define AnESYM a0esym
#define AMn_IX0 am0_ix0
#define AMn_IXN am0_ixn
#define CHK_FOR_DISPn CheckForDisp0
- #define AnBEXPR (TOKENPTR)a0bexpr
+ #define AnBEXPR a0bexpr
#define AnBEXVAL a0bexval
#define AnBEXATTR a0bexattr
#define AnBZISE a0bsize
// it's a bitfield instruction--check the parameters inside the {} block
// for validity
- if (*tok.u32 == '{')
+ if (*tok == '{')
if (check030bf() == ERROR)
return ERROR;
- if ((acount == 0) || (*tok.u32 != ','))
+ if ((acount == 0) || (*tok != ','))
return 1;
// Eat the comma
- tok.u32++;
+ tok++;
// Parse second addressing mode
#define AnOK a1ok
#define AnREG a1reg
#define AnIXREG a1ixreg
#define AnIXSIZ a1ixsiz
- #define AnEXPR (TOKENPTR)a1expr
+ #define AnEXPR a1expr
#define AnEXVAL a1exval
#define AnEXATTR a1exattr
- #define AnOEXPR (TOKENPTR)a1oexpr
+ #define AnOEXPR a1oexpr
#define AnOEXVAL a1oexval
#define AnOEXATTR a1oexattr
#define AnESYM a1esym
#define AMn_IX0 am1_ix0
#define AMn_IXN am1_ixn
#define CHK_FOR_DISPn CheckForDisp1
- #define AnBEXPR (TOKENPTR)a1bexpr
+ #define AnBEXPR a1bexpr
#define AnBEXVAL a1bexval
#define AnBEXATTR a1bexattr
#define AnBZISE a1bsize
// It's a bitfield instruction--check the parameters inside the {} block
// for validity
- if (*tok.u32 == '{')
+ if (*tok == '{')
if (check030bf() == ERROR)
return ERROR;
// At this point, it is legal for 020+ to have a ':'. For example divu.l
// d0,d2:d3
- if (*tok.u32 == ':')
+ if (*tok == ':')
{
if ((activecpu & (CPU_68020 | CPU_68030 | CPU_68040)) == 0)
return error(unsupport);
// TODO: protect this from combinations like Dx:FPx etc :)
- tok.u32++; //eat the colon
+ tok++; //eat the colon
- if ((*tok.u32 >= KW_D0) && (*tok.u32 <= KW_D7))
+ if ((*tok >= KW_D0) && (*tok <= KW_D7))
{
- a2reg = (*tok.u32 - KW_D0);
+ a2reg = (*tok - KW_D0);
mulmode = 1 << 10;
}
- else if ((*tok.u32 >= KW_FP0) && (*tok.u32 <= KW_FP7))
+ else if ((*tok >= KW_FP0) && (*tok <= KW_FP7))
{
- a2reg = (*tok.u32 - KW_FP0);
+ a2reg = (*tok - KW_FP0);
mulmode = 1 << 10;
}
else
return error("a data or FPU register must follow a :");
- *tok.u32++;
+ *tok++;
}
else
{
for(;;)
{
- if ((*tok.u32 >= KW_D0) && (*tok.u32 <= KW_A7))
- r = *tok.u32++ & 0x0F;
+ if ((*tok >= KW_D0) && (*tok <= KW_A7))
+ r = *tok++ & 0x0F;
else
break;
- if (*tok.u32 == '-')
+ if (*tok == '-')
{
- tok.u32++;
+ tok++;
- if ((*tok.u32 >= KW_D0) && (*tok.u32 <= KW_A7))
- cnt = *tok.u32++ & 0x0F;
+ if ((*tok >= KW_D0) && (*tok <= KW_A7))
+ cnt = *tok++ & 0x0F;
else
return error("register list syntax");
while (cnt-- >= 0)
rmask |= msktab[r++];
- if (*tok.u32 != '/')
+ if (*tok != '/')
break;
- tok.u32++;
+ tok++;
}
*a_rmask = rmask;
for(;;)
{
- if ((*tok.u32 >= KW_FP0) && (*tok.u32 <= KW_FP7))
- r = *tok.u32++ & 0x07;
+ if ((*tok >= KW_FP0) && (*tok <= KW_FP7))
+ r = *tok++ & 0x07;
else
break;
- if (*tok.u32 == '-')
+ if (*tok == '-')
{
- tok.u32++;
+ tok++;
- if ((*tok.u32 >= KW_FP0) && (*tok.u32 <= KW_FP7))
- cnt = *tok.u32++ & 0x07;
+ if ((*tok >= KW_FP0) && (*tok <= KW_FP7))
+ cnt = *tok++ & 0x07;
else
return error("register list syntax");
while (cnt-- >= 0)
rmask |= msktab_minus[r++];
- if (*tok.u32 != '/')
+ if (*tok != '/')
break;
- tok.u32++;
+ tok++;
}
*a_rmask = rmask;
for(;;)
{
- if ((*tok.u32 >= KW_FP0) && (*tok.u32 <= KW_FP7))
- r = *tok.u32++ & 0x07;
+ if ((*tok >= KW_FP0) && (*tok <= KW_FP7))
+ r = *tok++ & 0x07;
else
break;
- if (*tok.u32 == '-')
+ if (*tok == '-')
{
- tok.u32++;
+ tok++;
- if ((*tok.u32 >= KW_FP0) && (*tok.u32 <= KW_FP7))
- cnt = *tok.u32++ & 0x07;
+ if ((*tok >= KW_FP0) && (*tok <= KW_FP7))
+ cnt = *tok++ & 0x07;
else
return error("register list syntax");
while (cnt-- >= 0)
rmask |= msktab_plus[r++];
- if (*tok.u32 != '/')
+ if (*tok != '/')
break;
- tok.u32++;
+ tok++;
}
*a_rmask = rmask;
//
int check030bf(void)
{
+ PTR tp;
CHECK00;
- tok.u32++;
+ tok++;
- if (*tok.u32 == CONST)
+ if (*tok == CONST)
{
- tok.u32++;
-// bfval1 = (int)*(uint64_t *)tok.u32;
- bfval1 = (int)*tok.u64;
+ tp.u32 = tok + 1;
+ bfval1 = (int)*tp.u64++;
+ tok = tp.u32;
// Do=0, offset=immediate - shift it to place
bfparam1 = (0 << 11);
-// tok.u32++;
-// tok.u32++;
- tok.u64++;
}
- else if (*tok.u32 == SYMBOL)
+ else if (*tok == SYMBOL)
{
- if (expr((TOKENPTR)bf0expr, &bf0exval, &bf0exattr, &bf0esym) != OK)
+ if (expr(bf0expr, &bf0exval, &bf0exattr, &bf0esym) != OK)
return ERROR;
if (!(bf0exattr & DEFINED))
// Do=0, offset=immediate - shift it to place
bfparam1 = (0 << 11);
}
- else if ((*tok.u32 >= KW_D0) && (*tok.u32 <= KW_D7))
+ else if ((*tok >= KW_D0) && (*tok <= KW_D7))
{
// Do=1, offset=data register - shift it to place
bfparam1 = (1 << 11);
- bfval1 = (*(int *)tok.u32 - 128);
- tok.u32++;
+ bfval1 = (*(int *)tok - 128);
+ tok++;
}
else
return ERROR;
// Eat the ':', if any
- if (*tok.u32 == ':')
- tok.u32++;
+ if (*tok == ':')
+ tok++;
- if (*tok.u32 == '}' && tok.u32[1] == EOL)
+ if (*tok == '}' && tok[1] == EOL)
{
// It is ok to have }, EOL here - it might be "fmove fpn,<ea> {dx}"
- tok.u32++;
+ tok++;
return OK;
}
- if (*tok.u32 == CONST)
+ if (*tok == CONST)
{
- tok.u32++;
-// bfval2 = (int)*(uint64_t *)tok.u32;
- bfval2 = (int)*tok.u64;
+ tp.u32 = tok + 1;
+ bfval2 = (int)*tp.u64++;
+ tok = tp.u32;
// Do=0, offset=immediate - shift it to place
bfparam2 = (0 << 5);
-// tok.u32++;
-// tok.u32++;
- tok.u64++;
}
- else if (*tok.u32 == SYMBOL)
+ else if (*tok == SYMBOL)
{
- if (expr((TOKENPTR)bf0expr, &bf0exval, &bf0exattr, &bf0esym) != OK)
+ if (expr(bf0expr, &bf0exval, &bf0exattr, &bf0esym) != OK)
return ERROR;
bfval2 = (int)bf0exval;
// Do=0, offset=immediate - shift it to place
bfparam2 = (0 << 5);
}
- else if ((*tok.u32 >= KW_D0) && (*tok.u32 <= KW_D7))
+ else if ((*tok >= KW_D0) && (*tok <= KW_D7))
{
// Do=1, offset=data register - shift it to place
- bfval2 = ((*(int *)tok.u32 - 128));
+ bfval2 = (*(int *)tok - 128);
bfparam2 = (1 << 5);
- tok.u32++;
+ tok++;
}
else
return ERROR;
- tok.u32++; // Eat the '}'
+ tok++; // Eat the '}'
return OK;
}
static int siztab[4] = { 3, 5, 9, 9 };
+static PTR tp;
//
//
// Print expression, return ptr to just past the ENDEXPR
//
-TOKEN * printexpr(TOKEN * tp)
+TOKEN * printexpr(TOKEN * tokenptr)
{
- if (tp != NULL)
+ if (tokenptr != NULL)
{
- while (*tp != ENDEXPR)
+ while (*tokenptr != ENDEXPR)
{
- switch ((int)*tp++)
+ switch ((int)*tokenptr++)
{
case SYMBOL:
- printf("'%s' ", symbolPtr[*tp]->sname);
- tp++;
+ printf("'%s' ", symbolPtr[*tokenptr]->sname);
+ tokenptr++;
break;
case CONST:
- printf("$%lX ", ((uint64_t)tp[0] << 32) | (uint64_t)tp[1]);
- tp += 2;
+ tp.u32 = tokenptr;
+ printf("$%lX ", *tp.u64++);
+ tokenptr = tp.u32;
break;
case ACONST:
- printf("ACONST=($%X,$%X) ", *tp, tp[1]);
- tp += 2;
+ printf("ACONST=($%X,$%X) ", *tokenptr, tokenptr[1]);
+ tokenptr += 2;
break;
default:
- printf("%c ", (char)tp[-1]);
+ printf("%c ", (char)tokenptr[-1]);
break;
}
}
}
- return tp + 1;
+ return tokenptr + 1;
}
{
uint16_t esiz = *p.wp++;
printf("(%d long) ", (int)esiz);
- p.tk.u32 = printexpr(p.tk.u32);
+ p.tk = printexpr(p.tk);
}
else
{
switch (flg & 3)
{
case 0:
- printf("%02X ", start[i] & 0xff);
+ printf("%02X ", start[i] & 0xFF);
i++;
break;
case 1:
- printf("%02X%02X ", start[i] & 0xff, start[i+1] & 0xff);
+ printf("%02X%02X ", start[i] & 0xFF, start[i+1] & 0xFF);
i += 2;
break;
case 2:
- printf("%02X%02X%02X%02X ", start[i] & 0xff, start[i+1] & 0xff,
- start[i+2] & 0xff, start[i+3] & 0xff);
+ printf("%02X%02X%02X%02X ", start[i] & 0xFF, start[i+1] & 0xFF,
+ start[i+2] & 0xFF, start[i+3] & 0xFF);
i += 4;
break;
case 3:
switch ((int)*tk++)
{
case CONST: // CONST <value>
- printf("CONST=%lu", ((uint64_t)tk[0] << 32) | (uint64_t)tk[1]);
- tk += 2;
+ tp.u32 = tk;
+ printf("CONST=%lu", *tp.u64++);
+ tk = tp.u32;
break;
case STRING: // STRING <address>
printf("STRING='%s'", string[*tk++]);
printf("[COLON]");
else if (*t == CONST)
{
- printf("[CONST: $%lX]", ((uint64_t)t[1] << 32) | (uint64_t)t[2]);
+ tp.u32 = t + 1;
+ printf("[CONST: $%lX]", *tp.u64);
t += 2;
}
else if (*t == ACONST)
#define DEF_KW
#include "kwtab.h"
-// N.B.: It's perfectly fine to keep exprbuf as an array of TOKENS and to cast
-// to a TOKENPTR where needed. But this works too. :-P
-TOKEN _exprbuf[128]; // Expression buffer
-TOKENPTR exprbuf = (TOKENPTR)_exprbuf; // Expression buffer point
+
+TOKEN exprbuf[128]; // Expression buffer
SYM * symbolPtr[1000000]; // Symbol pointers table
static long unused; // For supressing 'write' warnings
char buffer[256]; // Scratch buffer for messages
//
int d_error(char *str)
{
- if (*tok.u32 == EOL)
+ if (*tok == EOL)
return error("error directive encountered - aborting assembling");
else
{
- switch(*tok.u32)
+ switch(*tok)
{
case STRING:
- return error(string[tok.u32[1]]);
+ return error(string[tok[1]]);
break;
default:
return error("error directive encountered--aborting assembly");
//
int d_warn(char *str)
{
- if (*tok.u32 == EOL)
+ if (*tok == EOL)
return warn("WARNING WARNING WARNING");
else
{
- switch(*tok.u32)
+ switch(*tok)
{
case STRING:
- return warn(string[tok.u32[1]]);
+ return warn(string[tok[1]]);
break;
default:
return warn("WARNING WARNING WARNING");
SYM * esym; // External symbol involved in expr.
TOKEN r_expr[EXPRSIZE];
- while (*tok.u32 != EOL)
+ while (*tok != EOL)
{
- switch(*tok.u32)
+ switch(*tok)
{
case STRING:
- sprintf(prntstr, "%s", string[tok.u32[1]]);
+ sprintf(prntstr, "%s", string[tok[1]]);
printf("%s", prntstr);
if (list_fd)
unused = write(list_fd, prntstr, (LONG)strlen(prntstr));
- tok.u32 += 2;
+ tok += 2;
break;
case '/':
formatting = 1;
- if (tok.u32[1] != SYMBOL)
+ if (tok[1] != SYMBOL)
goto token_err;
-// strcpy(prntstr, (char *)tok.u32[2]);
- strcpy(prntstr, string[tok.u32[2]]);
+// strcpy(prntstr, (char *)tok[2]);
+ strcpy(prntstr, string[tok[2]]);
switch(prntstr[0])
{
return ERROR;
}
- tok.u32 += 3;
+ tok += 3;
break;
case ',':
- tok.u32++;
+ tok++;
break;
default:
- if (expr((TOKENPTR)r_expr, &eval, &eattr, &esym) != OK)
+ if (expr(r_expr, &eval, &eattr, &esym) != OK)
goto token_err;
else
{
return ERROR;
}
- if (*tok.u32 != SYMBOL)
+ if (*tok != SYMBOL)
{
error("syntax error; expected symbol");
return ERROR;
}
- ccname = lookup(string[tok.u32[1]], LABEL, 0);
+ ccname = lookup(string[tok[1]], LABEL, 0);
// Make sure symbol is a valid ccdef
if (!ccname || !(ccname->sattre & EQUATEDCC))
if (!rgpu && !rdsp)
return error(".equrundef/.regundef must be defined in .gpu/.dsp section");
- while (*tok.u32 != EOL)
+ while (*tok != EOL)
{
// Skip preceeding or seperating commas (if any)
- if (*tok.u32 == ',')
- tok.u32++;
+ if (*tok == ',')
+ tok++;
// Check we are dealing with a symbol
- if (*tok.u32 != SYMBOL)
+ if (*tok != SYMBOL)
return error("syntax error; expected symbol");
// Lookup and undef if equated register
- regname = lookup(string[tok.u32[1]], LABEL, 0);
+ regname = lookup(string[tok[1]], LABEL, 0);
if (regname && (regname->sattre & EQUATEDREG))
{
}
// Skip over symbol token and address
- tok.u32 += 2;
+ tok += 2;
}
return 0;
// Check to see if we're in BSS, and, if so, throw an error
if (scattr & SBSS)
{
- error("cannot include binary file \"%s\" in BSS section", string[tok.u32[1]]);
+ error("cannot include binary file \"%s\" in BSS section", string[tok[1]]);
return ERROR;
}
- if (*tok.u32 != STRING)
+ if (*tok != STRING)
{
error("syntax error; string missing");
return ERROR;
// Attempt to open the include file in the current directory, then (if that
// failed) try list of include files passed in the enviroment string or by
// the "-d" option.
- if ((fd = open(string[tok.u32[1]], _OPEN_INC)) < 0)
+ if ((fd = open(string[tok[1]], _OPEN_INC)) < 0)
{
for(i=0; nthpath("RMACPATH", i, buf1)!=0; i++)
{
if (fd > 0 && buf1[fd - 1] != SLASHCHAR)
strcat(buf1, SLASHSTRING);
- strcat(buf1, string[tok.u32[1]]);
+ strcat(buf1, string[tok[1]]);
if ((fd = open(buf1, _OPEN_INC)) >= 0)
goto allright;
}
- return error("cannot open: \"%s\"", string[tok.u32[1]]);
+ return error("cannot open: \"%s\"", string[tok[1]]);
}
allright:
pos = lseek(fd, 0L, SEEK_SET);
chcheck(size);
- DEBUG { printf("INCBIN: File '%s' is %li bytes.\n", string[tok.u32[1]], size); }
+ DEBUG { printf("INCBIN: File '%s' is %li bytes.\n", string[tok[1]], size); }
char * fileBuffer = (char *)malloc(size);
bytesRead = read(fd, fileBuffer, size);
if (bytesRead != size)
{
- error("was only able to read %li bytes from binary file (%s, %li bytes)", bytesRead, string[tok.u32[1]], size);
+ error("was only able to read %li bytes from binary file (%s, %li bytes)", bytesRead, string[tok[1]], size);
return ERROR;
}
for(;;)
{
- if (*tok.u32 != SYMBOL)
+ if (*tok != SYMBOL)
return error(em);
- if ((*func)(string[tok.u32[1]]) != OK)
+ if ((*func)(string[tok[1]]) != OK)
break;
- tok.u32 += 2;
+ tok += 2;
- if (*tok.u32 == EOL)
+ if (*tok == EOL)
break;
- if (*tok.u32 != ',')
+ if (*tok != ',')
return error(em);
- tok.u32++;
+ tok++;
}
return 0;
char buf[128];
char buf1[128];
- if (*tok.u32 == STRING) // Leave strings ALONE
- fn = string[*++tok.u32];
- else if (*tok.u32 == SYMBOL) // Try to append ".s" to symbols
+ if (*tok == STRING) // Leave strings ALONE
+ fn = string[*++tok];
+ else if (*tok == SYMBOL) // Try to append ".s" to symbols
{
- strcpy(buf, string[*++tok.u32]);
+ strcpy(buf, string[*++tok]);
fext(buf, ".s", 0);
fn = &buf[0];
}
// Make sure the user didn't try anything like:
// .include equates.s
- if (*++tok.u32 != EOL)
+ if (*++tok != EOL)
return error("extra stuff after filename--enclose it in quotes");
// Attempt to open the include file in the current directory, then (if that
WORD eattr;
uint64_t eval;
- for(; expr(exprbuf, &eval, &eattr, NULL)==OK; ++tok.u32)
+ for(; expr(exprbuf, &eval, &eattr, NULL)==OK; ++tok)
{
if (!(eattr & DEFINED))
return error("forward or undefined .assert");
if (!eval)
return error("assert failure");
- if (*tok.u32 != ',')
+ if (*tok != ',')
break;
}
{
uint64_t eval;
- if (*tok.u32 == EOL)
+ if (*tok == EOL)
return error("PRGFLAGS requires value");
else if (abs_expr(&eval) == OK)
{
SaveSection();
- if (*tok.u32 == EOL)
+ if (*tok == EOL)
eval = 0;
else if (abs_expr(&eval) != OK)
return 0;
}
else
{
- dep_block(eval, siz, 0, (WORD)(DEFINED | ABS), (TOKENPTR){NULL});
+ dep_block(eval, siz, 0, (WORD)(DEFINED | ABS), NULL);
}
at_eol();
|| (rdsp && (orgaddr >= 0xF1B000) && (orgaddr <= 0xF1CFFFF))))
warn("depositing LONGs on a non-long address in local RAM");
- for(;; tok.u32++)
+ for(;; tok++)
{
// dc.b 'string' [,] ...
- if (siz == SIZB && (*tok.u32 == STRING || *tok.u32 == STRINGA8) && (tok.u32[2] == ',' || tok.u32[2] == EOL))
+ if (siz == SIZB && (*tok == STRING || *tok == STRINGA8) && (tok[2] == ',' || tok[2] == EOL))
{
- uint32_t i = strlen(string[tok.u32[1]]);
+ uint32_t i = strlen(string[tok[1]]);
if ((challoc - ch_size) < i)
chcheck(i);
- if (*tok.u32 == STRING)
+ if (*tok == STRING)
{
- for(p=string[tok.u32[1]]; *p!=EOS; p++)
+ for(p=string[tok[1]]; *p!=EOS; p++)
D_byte(*p);
}
- else if(*tok.u32 == STRINGA8)
+ else if(*tok == STRINGA8)
{
- for(p=string[tok.u32[1]]; *p!=EOS; p++)
+ for(p=string[tok[1]]; *p!=EOS; p++)
D_byte(strtoa8[*p]);
}
else
error("String format not supported... yet");
}
- tok.u32 += 2;
+ tok += 2;
goto comma;
}
int movei = 0; // MOVEI flag for dc.i
- if (*tok.u32 == DOTI)
+ if (*tok == DOTI)
{
movei = 1;
- tok.u32++;
+ tok++;
siz = SIZL;
}
}
comma:
- if (*tok.u32 != ',')
+ if (*tok != ',')
break;
}
if (abs_expr(&evalc) != OK)
return 0;
- if (*tok.u32++ != ',')
+ if (*tok++ != ',')
return error("missing comma");
if (expr(exprbuf, &eval, &eattr, NULL) < 0)
for(;;)
{
// Get repeat count (defaults to 1)
- if (*tok.u32 == '#')
+ if (*tok == '#')
{
- tok.u32++;
+ tok++;
if (abs_expr(&count) != OK)
return 0;
- if (*tok.u32++ != ',')
+ if (*tok++ != ',')
return error(comma_error);
}
else
if (expr(exprbuf, &eval, &eattr, NULL) < 0)
return 0;
- switch (*tok.u32++)
+ switch (*tok++)
{ // Determine size of object to deposit
case DOTB: siz = SIZB; break;
case DOTW: siz = SIZB; break;
case DOTL: siz = SIZL; break;
default:
siz = def_siz;
- tok.u32--;
+ tok--;
break;
}
dep_block((uint32_t)count, siz, (uint32_t)eval, eattr, exprbuf);
- switch (*tok.u32)
+ switch (*tok)
{
case EOL:
return 0;
case ',':
- tok.u32++;
+ tok++;
continue;
default:
return error(comma_error);
//
// Deposit 'count' values of size 'siz' in the current (non-BSS) segment
//
-int dep_block(uint32_t count, WORD siz, uint32_t eval, WORD eattr, TOKENPTR exprbuf)
+int dep_block(uint32_t count, WORD siz, uint32_t eval, WORD eattr, TOKEN * exprbuf)
{
WORD tdb;
WORD defined;
if (m6502)
return error(in_6502mode);
- if (*tok.u32 != SYMBOL)
+ if (*tok != SYMBOL)
return error("missing symbol");
- p = string[tok.u32[1]];
- tok.u32 += 2;
+ p = string[tok[1]];
+ tok += 2;
if (*p == '.') // Cannot .comm a local symbol
return error(locgl_error);
sym->sattr = GLOBAL | COMMON | BSS;
- if (*tok.u32++ != ',')
+ if (*tok++ != ',')
return error(comma_error);
if (abs_expr(&eval) != OK) // Parse size of common region
if (rgpu || rdsp)
return error("directive forbidden in gpu/dsp mode");
- if (*tok.u32 == '#')
+ if (*tok == '#')
{
- tok.u32++;
+ tok++;
if (abs_expr(&eval) != OK)
return 0;
// Eat the comma, if it's there
- if (*tok.u32 == ',')
- tok.u32++;
+ if (*tok == ',')
+ tok++;
}
for(;;)
{
- if (*tok.u32 == SYMBOL)
+ if (*tok == SYMBOL)
{
- p = string[tok.u32[1]];
+ p = string[tok[1]];
// Set env to either local (dot prefixed) or global scope
env = (*p == '.' ? curenv : 0);
symbol->sattr |= (ABS | DEFINED | EQUATED);
symbol->svalue = (uint32_t)eval;
- tok.u32 += 2;
+ tok += 2;
// What this does is eat any dot suffixes attached to a symbol. If
// it's a .L, it adds 4 to eval; if it's .W or .B, it adds 2. If
// there is no dot suffix, it assumes a size of 2.
- switch ((int)*tok.u32)
+ switch ((int)*tok)
{
case DOTL:
eval += 2;
case DOTB:
case DOTW:
- tok.u32++;
+ tok++;
}
eval += 2;
}
- else if (*tok.u32 >= KW_D0 && *tok.u32 <= KW_A7)
+ else if (*tok >= KW_D0 && *tok <= KW_A7)
{
if (reglist(&rlist) < 0)
return 0;
}
else
{
- switch ((int)*tok.u32)
+ switch ((int)*tok)
{
case KW_USP:
case KW_SSP:
case KW_SR:
case KW_CCR:
eval += 2;
- tok.u32++;
+ tok++;
break;
case EOL:
return 0;
}
// Eat commas in between each argument, if they exist
- if (*tok.u32 == ',')
- tok.u32++;
+ if (*tok == ',')
+ tok++;
}
}
if (rgpu || rdsp)
return error("directive forbidden in gpu/dsp mode");
- if (*tok.u32 == '#')
+ if (*tok == '#')
{
- tok.u32++;
+ tok++;
if (abs_expr(&eval) != OK)
return 0;
// Eat the comma, if it's there
- if (*tok.u32 == ',')
- tok.u32++;
+ if (*tok == ',')
+ tok++;
}
for(;;)
{
- if (*tok.u32 == SYMBOL)
+ if (*tok == SYMBOL)
{
- symbolName = string[tok.u32[1]];
+ symbolName = string[tok[1]];
// Set env to either local (dot prefixed) or global scope
env = (symbolName[0] == '.' ? curenv : 0);
// Put symbol in "order of definition" list
AddToSymbolDeclarationList(symbol);
- tok.u32 += 2;
+ tok += 2;
// Adjust label start address if it's a word or a long, as a byte
// label might have left us on an odd address.
- switch ((int)*tok.u32)
+ switch ((int)*tok)
{
case DOTW:
case DOTL:
// Check for dot suffixes and adjust space accordingly (longs and
// words on an odd boundary get bumped to the next word aligned
// address). If no suffix, then throw an error.
- switch ((int)*tok.u32)
+ switch ((int)*tok)
{
case DOTL:
eval += 4;
return error("Symbol missing dot suffix in .cstruct construct");
}
- tok.u32++;
+ tok++;
}
- else if (*tok.u32 >= KW_D0 && *tok.u32 <= KW_A7)
+ else if (*tok >= KW_D0 && *tok <= KW_A7)
{
if (reglist(&rlist) < 0)
return 0;
}
else
{
- switch ((int)*tok.u32)
+ switch ((int)*tok)
{
case KW_USP:
case KW_SSP:
case KW_SR:
case KW_CCR:
eval += 2;
- tok.u32++;
+ tok++;
break;
case EOL:
return 0;
}
// Eat commas in between each argument, if they exist
- if (*tok.u32 == ',')
- tok.u32++;
+ if (*tok == ',')
+ tok++;
}
}
//
int d_opt(void)
{
- while (*tok.u32 != EOL)
+ while (*tok != EOL)
{
- if (*tok.u32 == STRING)
+ if (*tok == STRING)
{
- tok.u32++;
- char * tmpstr = string[*tok.u32++];
+ tok++;
+ char * tmpstr = string[*tok++];
if (ParseOptimization(tmpstr) != OK)
return error("unknown optimization flag '%s'", tmpstr);
#include "token.h"
// Exported variables
-extern TOKENPTR exprbuf;
+extern TOKEN exprbuf[];
extern SYM * symbolPtr[];
extern int (* dirtab[])();
extern int largestAlign[];
// Exported functions
void auto_even(void);
-int dep_block(uint32_t, WORD, uint32_t, WORD, TOKENPTR);
+int dep_block(uint32_t, WORD, uint32_t, WORD, TOKEN *);
int eject(void);
int abs_expr(uint64_t *);
int symlist(int(*)());
#define amN am0
#define aNexattr a0exattr
#define aNexval a0exval
-#define aNexpr (TOKENPTR)a0expr
+#define aNexpr a0expr
#define aNixreg a0ixreg
#define aNixsiz a0ixsiz
#define AnESYM a0esym
#define aNexten a0extension
-#define aNbexpr (TOKENPTR)a0bexpr
+#define aNbexpr a0bexpr
#define aNbdexval a0bexval
#define aNbdexattr a0bexattr
#include "eagen0.c"
#define amN am1
#define aNexattr a1exattr
#define aNexval a1exval
-#define aNexpr (TOKENPTR)a1expr
+#define aNexpr a1expr
#define aNixreg a1ixreg
#define aNixsiz a1ixsiz
#define AnESYM a1esym
#define aNexten a1extension
-#define aNbexpr (TOKENPTR)a1bexpr
+#define aNbexpr a1bexpr
#define aNbdexval a1bexval
#define aNbdexattr a1bexattr
#include "eagen0.c"
//
int at_eol(void)
{
- if (*tok.u32 != EOL)
+ if (*tok != EOL)
{
- error("syntax error. expected EOL, found $%X ('%c')", *tok.u32, *tok.u32);
+ error("syntax error. expected EOL, found $%X ('%c')", *tok, *tok);
printf("Token = ");
- DumpToken(*tok.u32);
+ DumpToken(*tok);
printf("\n");
DumpTokenBuffer();
}
const char str_error[] = "missing symbol or string";
// Convert expression to postfix
-static TOKENPTR evalTokenBuffer; // Deposit tokens here (this is really a
- // pointer to exprbuf from direct.c)
- // (Can also be from others, like
- // riscasm.c)
-static int symbolNum; // Pointer to the entry in symbolPtr[]
+static PTR evalTokenBuffer; // Deposit tokens here (this is really a
+ // pointer to exprbuf from direct.c)
+ // (Can also be from others, like
+ // riscasm.c)
+static int symbolNum; // Pointer to the entry in symbolPtr[]
//
//
int expr0(void)
{
- TOKEN t;
-
if (expr1() != OK)
return ERROR;
- while (tokenClass[*tok.u32] >= MULT)
+ while (tokenClass[*tok] >= MULT)
{
- t = *tok.u32++;
+ TOKEN t = *tok++;
if (expr1() != OK)
return ERROR;
//
int expr1(void)
{
- int class;
TOKEN t;
SYM * sy;
char * p, * p2;
WORD w;
int j;
- class = tokenClass[*tok.u32];
+ int class = tokenClass[*tok];
- if (*tok.u32 == '-' || *tok.u32 == '+' || class == UNARY)
+ if (*tok == '-' || *tok == '+' || class == UNARY)
{
- t = *tok.u32++;
+ t = *tok++;
if (expr2() != OK)
return ERROR;
}
else if (class == SUNARY)
{
- switch (*tok.u32++)
+ switch (*tok++)
{
case CR_ABSCOUNT:
*evalTokenBuffer.u32++ = CONST;
*evalTokenBuffer.u64++ = dos_date();
break;
case CR_MACDEF: // ^^macdef <macro-name>
- if (*tok.u32++ != SYMBOL)
+ if (*tok++ != SYMBOL)
return error(missym_error);
- p = string[*tok.u32++];
+ p = string[*tok++];
w = (lookup(p, MACRO, 0) == NULL ? 0 : 1);
*evalTokenBuffer.u32++ = CONST;
*evalTokenBuffer.u64++ = (uint64_t)w;
case CR_REFERENCED:
w = REFERENCED;
getsym:
- if (*tok.u32++ != SYMBOL)
+ if (*tok++ != SYMBOL)
return error(missym_error);
- p = string[*tok.u32++];
+ p = string[*tok++];
j = (*p == '.' ? curenv : 0);
w = ((sy = lookup(p, LABEL, j)) != NULL && (sy->sattr & w) ? 1 : 0);
*evalTokenBuffer.u32++ = CONST;
*evalTokenBuffer.u64++ = (uint64_t)w;
break;
case CR_STREQ:
- if (*tok.u32 != SYMBOL && *tok.u32 != STRING)
+ if (*tok != SYMBOL && *tok != STRING)
return error(str_error);
- p = string[tok.u32[1]];
- tok.u32 +=2;
+ p = string[tok[1]];
+ tok +=2;
- if (*tok.u32++ != ',')
+ if (*tok++ != ',')
return error(comma_error);
- if (*tok.u32 != SYMBOL && *tok.u32 != STRING)
+ if (*tok != SYMBOL && *tok != STRING)
return error(str_error);
- p2 = string[tok.u32[1]];
- tok.u32 += 2;
+ p2 = string[tok[1]];
+ tok += 2;
w = (WORD)(!strcmp(p, p2));
*evalTokenBuffer.u32++ = CONST;
char * p;
SYM * sy;
int j;
+ PTR ptk;
- switch (*tok.u32++)
+ switch (*tok++)
{
case CONST:
- *evalTokenBuffer.u32++ = CONST;
- *evalTokenBuffer.u64++ = *tok.u64++;
- break;
case FCONST:
- *evalTokenBuffer.u32++ = FCONST;
- *evalTokenBuffer.u64++ = *tok.u64++;
+ ptk.u32 = tok;
+ *evalTokenBuffer.u32++ = CONST;
+ *evalTokenBuffer.u64++ = *ptk.u64++;
+ tok = ptk.u32;
break;
case SYMBOL:
- p = string[*tok.u32++];
+ p = string[*tok++];
j = (*p == '.' ? curenv : 0);
sy = lookup(p, LABEL, j);
break;
case STRING:
*evalTokenBuffer.u32++ = CONST;
- *evalTokenBuffer.u64++ = str_value(string[*tok.u32++]);
+ *evalTokenBuffer.u64++ = str_value(string[*tok++]);
break;
case '(':
if (expr0() != OK)
return ERROR;
- if (*tok.u32++ != ')')
+ if (*tok++ != ')')
return error("missing closing parenthesis ')'");
break;
if (expr0() != OK)
return ERROR;
- if (*tok.u32++ != ']')
+ if (*tok++ != ']')
return error("missing closing bracket ']'");
+ break;
+ case '{':
+ if (expr0() != OK) // Eat up first parameter (register or immediate)
+ return ERROR;
+
+ if (*tok++ != ':') // Demand a ':' there
+ return error("missing colon ':'");
+
+ if (expr0() != OK) // Eat up second parameter (register or immediate)
+ return ERROR;
+
+ if (*tok++ != '}')
+ return error("missing closing brace '}'");
+
break;
case '$':
*evalTokenBuffer.u32++ = ACONST; // Attributed const
*evalTokenBuffer.u32++ = (orgactive ? orgaddr : pcloc);
// '*' takes attributes of current section, not ABS!
*evalTokenBuffer.u32++ = cursect | DEFINED;
- break;
- case '{':
- if (expr0() != OK) // Eat up first parameter (register or immediate)
- return ERROR;
-
- if (*tok.u32++ != ':') // Demand a ':' there
- return error("missing colon ':'");
-
- if (expr0() != OK) // Eat up second parameter (register or immediate)
- return ERROR;
-
- if (*tok.u32++ != '}')
- return error("missing closing brace '}'");
-
break;
default:
return error("bad expression");
//
// Recursive-descent expression analyzer (with some simple speed hacks)
//
-int expr(TOKENPTR otk, uint64_t * a_value, WORD * a_attr, SYM ** a_esym)
+int expr(TOKEN * otk, uint64_t * a_value, WORD * a_attr, SYM ** a_esym)
{
// Passed in values (once derefenced, that is) can all be zero. They are
// there so that the expression analyzer can fill them in as needed. The
SYM * symbol;
char * p;
int j;
+ PTR ptk;
- evalTokenBuffer = otk; // Set token pointer to 'exprbuf' (direct.c)
+ evalTokenBuffer.u32 = otk; // Set token pointer to 'exprbuf' (direct.c)
// Also set in various other places too (riscasm.c,
// e.g.)
-//printf("expr(): tokens 0-2: %i %i %i (%c %c %c); tc[2] = %i\n", tok.u32[0], tok.u32[1], tok.u32[2], tok.u32[0], tok.u32[1], tok.u32[2], tokenClass[tok.u32[2]]);
+//printf("expr(): tokens 0-2: %i %i %i (%c %c %c); tc[2] = %i\n", tok[0], tok[1], tok[2], tok[0], tok[1], tok[2], tokenClass[tok[2]]);
// Optimize for single constant or single symbol.
// Shamus: Subtle bug here. EOL token is 101; if you have a constant token
// followed by the value 101, it will trigger a bad evaluation here.
// This is probably a really bad assumption to be making here...!
- // (assuming tok.u32[1] == EOL is a single token that is)
+ // (assuming tok[1] == EOL is a single token that is)
// Seems that even other tokens (SUNARY type) can fuck this up too.
#if 0
-// if ((tok.u32[1] == EOL)
- if ((tok.u32[1] == EOL && ((tok.u32[0] != CONST || tok.u32[0] != FCONST) && tokenClass[tok.u32[0]] != SUNARY))
-// || (((*tok.u32 == CONST || *tok.u32 == FCONST || *tok.u32 == SYMBOL) || (*tok.u32 >= KW_R0 && *tok.u32 <= KW_R31))
-// && (tokenClass[tok.u32[2]] < UNARY)))
- || (((tok.u32[0] == SYMBOL) || (tok.u32[0] >= KW_R0 && tok.u32[0] <= KW_R31))
- && (tokenClass[tok.u32[2]] < UNARY))
- || ((tok.u32[0] == CONST || tok.u32[0] == FCONST) && (tokenClass[tok.u32[3]] < UNARY))
+// if ((tok[1] == EOL)
+ if ((tok[1] == EOL && ((tok[0] != CONST || tok[0] != FCONST) && tokenClass[tok[0]] != SUNARY))
+// || (((*tok == CONST || *tok == FCONST || *tok == SYMBOL) || (*tok >= KW_R0 && *tok <= KW_R31))
+// && (tokenClass[tok[2]] < UNARY)))
+ || (((tok[0] == SYMBOL) || (tok[0] >= KW_R0 && tok[0] <= KW_R31))
+ && (tokenClass[tok[2]] < UNARY))
+ || ((tok[0] == CONST || tok[0] == FCONST) && (tokenClass[tok[3]] < UNARY))
)
#else
// Shamus: Seems to me that this could be greatly simplified by 1st checking if the first token is a multibyte token, *then* checking if there's an EOL after it depending on the actual length of the token (multiple vs. single). Otherwise, we have the horror show that is the following:
- if ((tok.u32[1] == EOL
- && (tok.u32[0] != CONST && tokenClass[tok.u32[0]] != SUNARY))
- || (((tok.u32[0] == SYMBOL)
- || (tok.u32[0] >= KW_R0 && tok.u32[0] <= KW_R31))
- && (tokenClass[tok.u32[2]] < UNARY))
- || ((tok.u32[0] == CONST) && (tokenClass[tok.u32[3]] < UNARY))
+ if ((tok[1] == EOL
+ && (tok[0] != CONST && tokenClass[tok[0]] != SUNARY))
+ || (((tok[0] == SYMBOL)
+ || (tok[0] >= KW_R0 && tok[0] <= KW_R31))
+ && (tokenClass[tok[2]] < UNARY))
+ || ((tok[0] == CONST) && (tokenClass[tok[3]] < UNARY))
)
-// Shamus: Yes, you can parse that out and make some kind of sense of it, but damn, it takes a while to get it and understand the subtle bugs that result from not being careful about what you're checking; especially vis-a-vis niavely checking tok.u32[1] for an EOL. O_o
+// Shamus: Yes, you can parse that out and make some kind of sense of it, but damn, it takes a while to get it and understand the subtle bugs that result from not being careful about what you're checking; especially vis-a-vis niavely checking tok[1] for an EOL. O_o
#endif
{
- if (*tok.u32 >= KW_R0 && *tok.u32 <= KW_R31)
+ if (*tok >= KW_R0 && *tok <= KW_R31)
{
*evalTokenBuffer.u32++ = CONST;
- *evalTokenBuffer.u64++ = *a_value = (*tok.u32 - KW_R0);
+ *evalTokenBuffer.u64++ = *a_value = (*tok - KW_R0);
*a_attr = ABS | DEFINED;
if (a_esym != NULL)
*a_esym = NULL;
- tok.u32++;
+ tok++;
}
- else if (*tok.u32 == CONST)
+ else if (*tok == CONST)
{
- *evalTokenBuffer.u32++ = *tok.u32++;
- *evalTokenBuffer.u64++ = *a_value = *tok.u64++;
+ ptk.u32 = tok;
+ *evalTokenBuffer.u32++ = *ptk.u32++;
+ *evalTokenBuffer.u64++ = *a_value = *ptk.u64++;
*a_attr = ABS | DEFINED;
+ tok = ptk.u32;
if (a_esym != NULL)
*a_esym = NULL;
-//printf("Quick eval in expr(): CONST = %i, tokenClass[tok.u32[2]] = %i\n", *a_value, tokenClass[*tok.u32]);
+//printf("Quick eval in expr(): CONST = %i, tokenClass[tok[2]] = %i\n", *a_value, tokenClass[*tok]);
}
// Not sure that removing float constant here is going to break anything and/or
// make things significantly slower, but having this here seems to cause the
// complexity of the check to get to this part of the parse to go through the
// roof, and dammit, I just don't feel like fighting that fight ATM. :-P
#if 0
- else if (*tok.u32 == FCONST)
+ else if (*tok == FCONST)
{
- *evalTokenBuffer.u32++ = *tok.u32++;
+ *evalTokenBuffer.u32++ = *tok++;
*evalTokenBuffer.u64++ = *a_value = *tok.u64++;
*a_attr = ABS | DEFINED | FLOAT;
if (a_esym != NULL)
*a_esym = NULL;
-//printf("Quick eval in expr(): CONST = %i, tokenClass[tok.u32[2]] = %i\n", *a_value, tokenClass[*tok.u32]);
+//printf("Quick eval in expr(): CONST = %i, tokenClass[tok[2]] = %i\n", *a_value, tokenClass[*tok]);
}
#endif
- else if (*tok.u32 == '*')
+ else if (*tok == '*')
{
*evalTokenBuffer.u32++ = CONST;
if (a_esym != NULL)
*a_esym = NULL;
- tok.u32++;
+ tok++;
}
- else if (*tok.u32 == STRING || *tok.u32 == SYMBOL)
+ else if (*tok == STRING || *tok == SYMBOL)
{
- p = string[tok.u32[1]];
+ p = string[tok[1]];
j = (*p == '.' ? curenv : 0);
symbol = lookup(p, LABEL, j);
#if 0
&& a_esym != NULL)
*a_esym = symbol;
- tok.u32 += 2;
+ tok += 2;
}
else
{
// Unknown type here... Alert the user!,
error("undefined RISC register in expression");
// Prevent spurious error reporting...
- tok.u32++;
+ tok++;
return ERROR;
}
// UNDEFINED, but it's value includes everything but the symbol value, and
// 'a_esym' is set to the external symbol.
//
-int evexpr(TOKENPTR tk, uint64_t * a_value, WORD * a_attr, SYM ** a_esym)
+int evexpr(TOKEN * _tk, uint64_t * a_value, WORD * a_attr, SYM ** a_esym)
{
WORD attr, attr2;
SYM * sy;
WORD * sattr = evattr;
SYM * esym = NULL; // No external symbol involved
WORD sym_seg = 0;
+ PTR tk;
+ tk.u32 = _tk;
while (*tk.u32 != ENDEXPR)
{
void InitExpression(void);
int expr1(void);
int expr2(void);
-int expr(TOKENPTR, uint64_t *, WORD *, SYM **);
-int evexpr(TOKENPTR, uint64_t *, WORD *, SYM **);
+int expr(TOKEN *, uint64_t *, WORD *, SYM **);
+int evexpr(TOKEN *, uint64_t *, WORD *, SYM **);
#endif // __EXPR_H__
int ejectok;
ejectok = 1;
- if (*tok.u32 == '-')
+ if (*tok == '-')
{
ejectok = 0;
- ++tok.u32;
+ ++tok;
}
- if (*tok.u32 != STRING)
+ if (*tok != STRING)
return error("missing string");
-// strcpy(subttl, (char *)tok.u32[1]);
- strcpy(subttl, string[tok.u32[1]]);
+// strcpy(subttl, (char *)tok[1]);
+ strcpy(subttl, string[tok[1]]);
- tok.u32 += 2;
+ tok += 2;
// Always eject on pages 2+
if (ejectok && (subflag || pageno > 1))
//
int d_title(void)
{
- if (*tok.u32 != STRING)
+ if (*tok != STRING)
return error("missing string");
-// strcpy(title, (char*)tok.u32[1]);
- strcpy(title, string[tok.u32[1]]);
- tok.u32 += 2;
+// strcpy(title, (char*)tok[1]);
+ strcpy(title, string[tok[1]]);
+ tok += 2;
if (pageno > 1)
{
}
else
{
- AddFixup(FU_QUICK, sloc, (TOKENPTR)a0expr);
+ AddFixup(FU_QUICK, sloc, a0expr);
D_word(inst);
}
}
else
{
- AddFixup(FU_WORD | FU_PCREL | FU_ISBRA, sloc, (TOKENPTR)a1expr);
+ AddFixup(FU_WORD | FU_PCREL | FU_ISBRA, sloc, a1expr);
D_word(0);
}
// Arrange for future fixup
if (!(a0exattr & DEFINED))
{
- AddFixup(FU_BYTE | FU_SEXT, sloc + 1, (TOKENPTR)a0expr);
+ AddFixup(FU_BYTE | FU_SEXT, sloc + 1, a0expr);
a0exval = 0;
}
else if ((uint32_t)a0exval + 0x100 >= 0x200)
if (siz == SIZB || siz == SIZS)
{
// .B
- AddFixup(FU_BBRA | FU_PCREL | FU_SEXT, sloc, (TOKENPTR)a0expr);
+ AddFixup(FU_BBRA | FU_PCREL | FU_SEXT, sloc, a0expr);
D_word(inst);
return OK;
}
{
// .W
D_word(inst);
- AddFixup(FU_WORD | FU_PCREL | FU_LBRA | FU_ISBRA, sloc, (TOKENPTR)a0expr);
+ AddFixup(FU_WORD | FU_PCREL | FU_LBRA | FU_ISBRA, sloc, a0expr);
D_word(0);
}
}
else
{
- AddFixup(FU_QUICK, sloc, (TOKENPTR)a0expr);
+ AddFixup(FU_QUICK, sloc, a0expr);
D_word(inst);
}
if (siz == SIZL)
inst |= 0x0040;
- if (*tok.u32 == '#')
+ if (*tok == '#')
{
// Handle #<expr>, ea
- tok.u32++;
+ tok++;
if (abs_expr(&eval) != OK)
return OK;
goto immed1;
}
- if ((*tok.u32 >= KW_D0) && (*tok.u32 <= KW_A7))
+ if ((*tok >= KW_D0) && (*tok <= KW_A7))
{
// <rlist>, ea
if (reglist(&rmask) < 0)
return OK;
immed1:
- if (*tok.u32++ != ',')
+ if (*tok++ != ',')
return error("missing comma");
if (amode(0) < 0)
inst |= 0x0400 | am0 | a0reg;
- if (*tok.u32++ != ',')
+ if (*tok++ != ',')
return error("missing comma");
- if (*tok.u32 == EOL)
+ if (*tok == EOL)
return error("missing register list");
- if (*tok.u32 == '#')
+ if (*tok == '#')
{
// ea, #<expr>
- tok.u32++;
+ tok++;
if (abs_expr(&eval) != OK)
return OK;
else
{
// .L
- AddFixup(FU_LONG | FU_PCREL | FU_SEXT, sloc, (TOKENPTR)a0expr);
+ AddFixup(FU_LONG | FU_PCREL | FU_SEXT, sloc, a0expr);
D_word(inst);
return OK;
}
}
// Dc
- if ((*tok.u32 < KW_D0) && (*tok.u32 > KW_D7))
+ if ((*tok < KW_D0) && (*tok > KW_D7))
return error("CAS accepts only data registers");
- inst2 = (*tok.u32++) & 7;
+ inst2 = (*tok++) & 7;
- if (*tok.u32++ != ',')
+ if (*tok++ != ',')
return error("missing comma");
// Du
- if ((*tok.u32 < KW_D0) && (*tok.u32 > KW_D7))
+ if ((*tok < KW_D0) && (*tok > KW_D7))
return error("CAS accepts only data registers");
- inst2 |= ((*tok.u32++) & 7) << 6;
+ inst2 |= ((*tok++) & 7) << 6;
- if (*tok.u32++ != ',')
+ if (*tok++ != ',')
return error("missing comma");
// ea
if (modes > 1)
return error("too many ea fields");
- if (*tok.u32 != EOL)
+ if (*tok != EOL)
return error("extra (unexpected) text found");
// Reject invalud ea modes
}
// Dc1
- if ((*tok.u32 < KW_D0) && (*tok.u32 > KW_D7))
+ if ((*tok < KW_D0) && (*tok > KW_D7))
return error("CAS2 accepts only data registers for Dx1:Dx2 pairs");
- inst2 = (*tok.u32++) & 7;
+ inst2 = (*tok++) & 7;
- if (*tok.u32++ != ':')
+ if (*tok++ != ':')
return error("missing colon");
// Dc2
- if ((*tok.u32 < KW_D0) && (*tok.u32 > KW_D7))
+ if ((*tok < KW_D0) && (*tok > KW_D7))
return error("CAS2 accepts only data registers for Dx1:Dx2 pairs");
- inst3 = (*tok.u32++) & 7;
+ inst3 = (*tok++) & 7;
- if (*tok.u32++ != ',')
+ if (*tok++ != ',')
return error("missing comma");
// Du1
- if ((*tok.u32 < KW_D0) && (*tok.u32 > KW_D7))
+ if ((*tok < KW_D0) && (*tok > KW_D7))
return error("CAS2 accepts only data registers for Dx1:Dx2 pairs");
- inst2 |= ((*tok.u32++) & 7) << 6;
+ inst2 |= ((*tok++) & 7) << 6;
- if (*tok.u32++ != ':')
+ if (*tok++ != ':')
return error("missing colon");
// Du2
- if ((*tok.u32 < KW_D0) && (*tok.u32 > KW_D7))
+ if ((*tok < KW_D0) && (*tok > KW_D7))
return error("CAS2 accepts only data registers for Dx1:Dx2 pairs");
- inst3 |= ((*tok.u32++) & 7) << 6;
+ inst3 |= ((*tok++) & 7) << 6;
- if (*tok.u32++ != ',')
+ if (*tok++ != ',')
return error("missing comma");
// Rn1
- if (*tok.u32++ != '(')
+ if (*tok++ != '(')
return error("missing (");
- if ((*tok.u32 >= KW_D0) && (*tok.u32 <= KW_D7))
- inst2 |= (((*tok.u32++) & 7) << 12) | (0 << 15);
- else if ((*tok.u32 >= KW_A0) && (*tok.u32 <= KW_A7))
- inst2 |= (((*tok.u32++) & 7) << 12) | (1 << 15);
+ if ((*tok >= KW_D0) && (*tok <= KW_D7))
+ inst2 |= (((*tok++) & 7) << 12) | (0 << 15);
+ else if ((*tok >= KW_A0) && (*tok <= KW_A7))
+ inst2 |= (((*tok++) & 7) << 12) | (1 << 15);
else
return error("CAS accepts either data or address registers for Rn1:Rn2 pair");
- if (*tok.u32++ != ')')
+ if (*tok++ != ')')
return error("missing (");
- if (*tok.u32++ != ':')
+ if (*tok++ != ':')
return error("missing colon");
// Rn2
- if (*tok.u32++ != '(')
+ if (*tok++ != '(')
return error("missing (");
- if ((*tok.u32 >= KW_D0) && (*tok.u32 <= KW_D7))
- inst3 |= (((*tok.u32++) & 7) << 12) | (0 << 15);
- else if ((*tok.u32 >= KW_A0) && (*tok.u32 <= KW_A7))
- inst3 |= (((*tok.u32++) & 7) << 12) | (1 << 15);
+ if ((*tok >= KW_D0) && (*tok <= KW_D7))
+ inst3 |= (((*tok++) & 7) << 12) | (0 << 15);
+ else if ((*tok >= KW_A0) && (*tok <= KW_A7))
+ inst3 |= (((*tok++) & 7) << 12) | (1 << 15);
else
return error("CAS accepts either data or address registers for Rn1:Rn2 pair");
- if (*tok.u32++ != ')')
+ if (*tok++ != ')')
return error("missing (");
- if (*tok.u32 != EOL)
+ if (*tok != EOL)
return error("extra (unexpected) text found");
D_word(inst);
{
// .L
D_word(inst);
- AddFixup(FU_LONG | FU_PCREL | FU_SEXT, sloc, (TOKENPTR)a0expr);
+ AddFixup(FU_LONG | FU_PCREL | FU_SEXT, sloc, a0expr);
D_long(0);
return OK;
}
{
// .W
D_word(inst);
- AddFixup(FU_WORD | FU_PCREL | FU_SEXT, sloc, (TOKENPTR)a0expr);
+ AddFixup(FU_WORD | FU_PCREL | FU_SEXT, sloc, a0expr);
D_word(0);
}
}
else
{
- AddFixup(FU_WORD | FU_PCREL | FU_ISBRA, sloc, (TOKENPTR)a1expr);
+ AddFixup(FU_WORD | FU_PCREL | FU_ISBRA, sloc, a1expr);
D_word(0);
}
if (siz != SIZN)
return error("bad size suffix");
- if (*tok.u32 >= KW_D0 && *tok.u32 <= KW_D7)
+ if (*tok >= KW_D0 && *tok <= KW_D7)
{
// Dx,Dy,#<adjustment>
inst |= (0 << 3); // R/M
- inst |= (*tok.u32++ & 7);
+ inst |= (*tok++ & 7);
- if (*tok.u32 != ',' && tok.u32[2] != ',')
+ if (*tok != ',' && tok[2] != ',')
return error("missing comma");
- if (tok.u32[1] < KW_D0 && tok.u32[1] > KW_D7)
+ if (tok[1] < KW_D0 && tok[1] > KW_D7)
return error(syntax_error);
- inst |= ((tok.u32[1] & 7)<<9);
- tok.u32 = tok.u32 + 3;
+ inst |= ((tok[1] & 7)<<9);
+ tok = tok + 3;
D_word(inst);
// Fall through for adjustment (common in both valid cases)
}
- else if (*tok.u32 == '-')
+ else if (*tok == '-')
{
// -(Ax),-(Ay),#<adjustment>
inst |= (1 << 3); // R/M
- tok.u32++; // eat the minus
+ tok++; // eat the minus
- if ((*tok.u32 != '(') && (tok.u32[2]!=')') && (tok.u32[3]!=',') && (tok.u32[4] != '-') && (tok.u32[5] != '(') && (tok.u32[7] != ')') && (tok.u32[8] != ','))
+ if ((*tok != '(') && (tok[2]!=')') && (tok[3]!=',') && (tok[4] != '-') && (tok[5] != '(') && (tok[7] != ')') && (tok[8] != ','))
return error(syntax_error);
- if (tok.u32[1] < KW_A0 && tok.u32[1] > KW_A7)
+ if (tok[1] < KW_A0 && tok[1] > KW_A7)
return error(syntax_error);
- if (tok.u32[5] < KW_A0 && tok.u32[6] > KW_A7)
+ if (tok[5] < KW_A0 && tok[6] > KW_A7)
return error(syntax_error);
- inst |= ((tok.u32[1] & 7) << 0);
- inst |= ((tok.u32[6] & 7) << 9);
- tok.u32 = tok.u32 + 9;
+ inst |= ((tok[1] & 7) << 0);
+ inst |= ((tok[6] & 7) << 9);
+ tok = tok + 9;
D_word(inst);
// Fall through for adjustment (common in both valid cases)
}
else
return error("invalid syntax");
- if ((*tok.u32 != CONST) && (*tok.u32 != SYMBOL) && (*tok.u32 != '-'))
+ if ((*tok != CONST) && (*tok != SYMBOL) && (*tok != '-'))
return error(syntax_error);
- if (expr((TOKENPTR)a0expr, &a0exval, &a0exattr, &a0esym) == ERROR)
+ if (expr(a0expr, &a0exval, &a0exattr, &a0esym) == ERROR)
return ERROR;
if ((a0exattr & DEFINED) == 0)
if (a0exval + 0x8000 > 0x10000)
return error("");
- if (*tok.u32 != EOL)
+ if (*tok != EOL)
return error(extra_stuff);
D_word((a0exval & 0xFFFF));
// PFLUSH FC, MASK, < ea >
WORD mask, fc;
- switch ((int)*tok.u32)
+ switch ((int)*tok)
{
case '#':
- tok.u32++;
+ tok++;
- if (*tok.u32 != CONST && *tok.u32 != SYMBOL)
+ if (*tok != CONST && *tok != SYMBOL)
return error("function code should be an expression");
- if (expr((TOKENPTR)a0expr, &a0exval, &a0exattr, &a0esym) == ERROR)
+ if (expr(a0expr, &a0exval, &a0exattr, &a0esym) == ERROR)
return ERROR;
if ((a0exattr & DEFINED) == 0)
case KW_D5:
case KW_D6:
case KW_D7:
- fc = (1 << 4) | (*tok.u32++ & 7);
+ fc = (1 << 4) | (*tok++ & 7);
break;
case KW_SFC:
fc = 0;
- tok.u32++;
+ tok++;
break;
case KW_DFC:
fc = 1;
- tok.u32++;
+ tok++;
break;
default:
return error(syntax_error);
}
- if (*tok.u32++ != ',')
+ if (*tok++ != ',')
return error("comma exptected");
- if (*tok.u32++ != '#')
+ if (*tok++ != '#')
return error("mask should be an immediate value");
- if (*tok.u32 != CONST && *tok.u32 != SYMBOL)
+ if (*tok != CONST && *tok != SYMBOL)
return error("mask is supposed to be immediate");
- if (expr((TOKENPTR)a0expr, &a0exval, &a0exattr, &a0esym) == ERROR)
+ if (expr(a0expr, &a0exval, &a0exattr, &a0esym) == ERROR)
return ERROR;
if ((a0exattr & DEFINED) == 0)
mask = (uint16_t)a0exval << 5;
- if (*tok.u32 == EOL)
+ if (*tok == EOL)
{
// PFLUSH FC, MASK
D_word(inst);
D_word(inst);
return OK;
}
- else if (*tok.u32 == ',')
+ else if (*tok == ',')
{
// PFLUSH FC, MASK, < ea >
- tok.u32++;
+ tok++;
if (amode(0) == ERROR)
return ERROR;
- if (*tok.u32 != EOL)
+ if (*tok != EOL)
return error(extra_stuff);
if (am0 == AIND || am0 == ABSW || am0 == ABSL || am0 == ADISP || am0 == ADISP || am0 == AINDEXED || am0 == ABASE || am0 == MEMPOST || am0 == MEMPRE)
{
// PFLUSH(An)
// PFLUSHN(An)
- if (*tok.u32 != '(' && tok.u32[2] != ')')
+ if (*tok != '(' && tok[2] != ')')
return error(syntax_error);
- if (tok.u32[1] < KW_A0 && tok.u32[1] > KW_A7)
+ if (tok[1] < KW_A0 && tok[1] > KW_A7)
return error("expected (An)");
if ((inst & 7) == 7)
// pflushn inside 68ktab and detect it here.
inst = (inst & 0xff8) | 8;
- inst |= (tok.u32[1] & 7) | (5 << 8);
+ inst |= (tok[1] & 7) | (5 << 8);
- if (tok.u32[3] != EOL)
+ if (tok[3] != EOL)
return error(extra_stuff);
D_word(inst);
}
else
{
- AddFixup(FU_WORD | FU_PCREL | FU_ISBRA, sloc, (TOKENPTR)a1expr);
+ AddFixup(FU_WORD | FU_PCREL | FU_ISBRA, sloc, a1expr);
D_word(0);
}
if (siz == SIZX || siz==SIZN)
{
- if ((*tok.u32 >= KW_FP0) && (*tok.u32 <= KW_FP7))
+ if ((*tok >= KW_FP0) && (*tok <= KW_FP7))
{
//fmovem.x <rlist>,ea
if (fpu_reglist_left(®mask) < 0)
return OK;
- if (*tok.u32++ != ',')
+ if (*tok++ != ',')
return error("missing comma");
if (amode(0) < 0)
ea0gen(siz);
return OK;
}
- else if ((*tok.u32 >= KW_D0) && (*tok.u32 <= KW_D7))
+ else if ((*tok >= KW_D0) && (*tok <= KW_D7))
{
// fmovem.x Dn,ea
- datareg = (*tok.u32++ & 7) << 10;
+ datareg = (*tok++ & 7) << 10;
- if (*tok.u32++ != ',')
+ if (*tok++ != ',')
return error("missing comma");
if (amode(0) < 0)
inst |= am0 | a0reg;
- if (*tok.u32++ != ',')
+ if (*tok++ != ',')
return error("missing comma");
- if ((*tok.u32 >= KW_FP0) && (*tok.u32 <= KW_FP7))
+ if ((*tok >= KW_FP0) && (*tok <= KW_FP7))
{
//fmovem.x ea,<rlist>
if (fpu_reglist_right(®mask) < 0)
else
{
// fmovem.x ea,Dn
- datareg = (*tok.u32++ & 7) << 10;
+ datareg = (*tok++ & 7) << 10;
D_word(inst);
inst = (1 << 15) | (1 << 14) | (0 << 13) | (3 << 11) | (datareg << 4);
D_word(inst);
}
else if (siz == SIZL)
{
- if ((*tok.u32 == KW_FPCR) || (*tok.u32 == KW_FPSR) || (*tok.u32 == KW_FPIAR))
+ if ((*tok == KW_FPCR) || (*tok == KW_FPSR) || (*tok == KW_FPIAR))
{
//fmovem.l <rlist>,ea
regmask = (1 << 15) | (1 << 13);
fmovem_loop_1:
- if (*tok.u32 == KW_FPCR)
+ if (*tok == KW_FPCR)
{
regmask |= (1 << 12);
- tok.u32++;
+ tok++;
goto fmovem_loop_1;
}
- if (*tok.u32 == KW_FPSR)
+ if (*tok == KW_FPSR)
{
regmask |= (1 << 11);
- tok.u32++;
+ tok++;
goto fmovem_loop_1;
}
- if (*tok.u32 == KW_FPIAR)
+ if (*tok == KW_FPIAR)
{
regmask |= (1 << 10);
- tok.u32++;
+ tok++;
goto fmovem_loop_1;
}
- if ((*tok.u32 == '/') || (*tok.u32 == '-'))
+ if ((*tok == '/') || (*tok == '-'))
{
- tok.u32++;
+ tok++;
goto fmovem_loop_1;
}
- if (*tok.u32++ != ',')
+ if (*tok++ != ',')
return error("missing comma");
if (amode(0) < 0)
inst |= am0 | a0reg;
- if (*tok.u32++ != ',')
+ if (*tok++ != ',')
return error("missing comma");
regmask = (1 << 15) | (0 << 13);
fmovem_loop_2:
- if (*tok.u32 == KW_FPCR)
+ if (*tok == KW_FPCR)
{
regmask |= (1 << 12);
- tok.u32++;
+ tok++;
goto fmovem_loop_2;
}
- if (*tok.u32 == KW_FPSR)
+ if (*tok == KW_FPSR)
{
regmask |= (1 << 11);
- tok.u32++;
+ tok++;
goto fmovem_loop_2;
}
- if (*tok.u32 == KW_FPIAR)
+ if (*tok == KW_FPIAR)
{
regmask |= (1 << 10);
- tok.u32++;
+ tok++;
goto fmovem_loop_2;
}
- if ((*tok.u32 == '/') || (*tok.u32 == '-'))
+ if ((*tok == '/') || (*tok == '-'))
{
- tok.u32++;
+ tok++;
goto fmovem_loop_2;
}
- if (*tok.u32 != EOL)
+ if (*tok != EOL)
return error("extra (unexpected) text found");
inst |= am0 | a0reg;
// Setup entry in symbol table, make sure the macro isn't a duplicate
// entry, and that it doesn't override any processor mnemonic or assembler
// directive.
- if (*tok.u32++ != SYMBOL)
+ if (*tok++ != SYMBOL)
return error("missing symbol");
- char * name = string[*tok.u32++];
+ char * name = string[*tok++];
if (lookup(name, MACRO, 0) != NULL)
return error("duplicate macro definition");
curmac->sattr = (WORD)(macnum++);
// Parse and define formal arguments in symbol table
- if (*tok.u32 != EOL)
+ if (*tok != EOL)
{
argno = 0;
symlist(defmac2);
char * p = NULL;
int k = -1;
- if (*tok.u32 == SYMBOL)
+ if (*tok == SYMBOL)
{
// A string followed by a colon or double colon is a symbol and
// *not* a directive, see if we can find the directive after it
- if ((tok.u32[2] == ':' || tok.u32[2] == DCOLON))
+ if ((tok[2] == ':' || tok[2] == DCOLON))
{
- if (tok.u32[3] == SYMBOL)
- p = string[tok.u32[4]];
+ if (tok[3] == SYMBOL)
+ p = string[tok[4]];
}
else
{
// Otherwise, just grab the directive
- p = string[tok.u32[1]];
+ p = string[tok[1]];
}
}
//
int InvokeMacro(SYM * mac, WORD siz)
{
- DEBUG { printf("InvokeMacro: arguments="); DumpTokens(tok.u32); }
+ DEBUG { printf("InvokeMacro: arguments="); DumpTokens(tok); }
INOBJ * inobj = a_inobj(SRC_IMACRO); // Alloc and init IMACRO
IMACRO * imacro = inobj->inobj.imacro;
// Chop up the arguments, if any (tok comes from token.c, which at this
// point points at the macro argument token stream)
- if (*tok.u32 != EOL)
+ if (*tok != EOL)
{
// Parse out the arguments and set them up correctly
TOKEN * p = imacro->argument[nargs].token;
int stringNum = 0;
- while (*tok.u32 != EOL)
+ while (*tok != EOL)
{
- if (*tok.u32 == ACONST)
+ if (*tok == ACONST)
{
for(int i=0; i<3; i++)
- *p++ = *tok.u32++;
+ *p++ = *tok++;
}
- else if (*tok.u32 == CONST) // Constants are 64-bits
+ else if (*tok == CONST) // Constants are 64-bits
{
- *p++ = *tok.u32++; // Token
+ *p++ = *tok++; // Token
uint64_t *p64 = (uint64_t *)p;
- uint64_t *tok64 = (uint64_t *)tok.u32;
+ uint64_t *tok64 = (uint64_t *)tok;
*p64++ = *tok64++;
- tok.u32 = (TOKEN *)tok64;
+ tok = (TOKEN *)tok64;
p = (uint32_t *)p64;
}
- else if ((*tok.u32 == STRING) || (*tok.u32 == SYMBOL))
+ else if ((*tok == STRING) || (*tok == SYMBOL))
{
- *p++ = *tok.u32++;
- imacro->argument[nargs].string[stringNum] = strdup(string[*tok.u32++]);
+ *p++ = *tok++;
+ imacro->argument[nargs].string[stringNum] = strdup(string[*tok++]);
*p++ = stringNum++;
}
- else if (*tok.u32 == ',')
+ else if (*tok == ',')
{
// Comma delimiter was found, so set up for next argument
*p++ = EOL;
- tok.u32++;
+ tok++;
stringNum = 0;
nargs++;
p = imacro->argument[nargs].token;
}
else
{
- *p++ = *tok.u32++;
+ *p++ = *tok++;
}
}
// Dn
// An
// # expression
- if ((*tok.u32 >= KW_D0) && (*tok.u32 <= KW_D7))
+ if ((*tok >= KW_D0) && (*tok <= KW_D7))
{
AMn = DREG;
- AnREG = *tok.u32++ & 7;
+ AnREG = *tok++ & 7;
}
- else if ((*tok.u32 >= KW_A0) && (*tok.u32 <= KW_A7))
+ else if ((*tok >= KW_A0) && (*tok <= KW_A7))
{
AMn = AREG;
- AnREG = *tok.u32++ & 7;
+ AnREG = *tok++ & 7;
}
- else if (*tok.u32 == '#')
+ else if (*tok == '#')
{
- tok.u32++;
+ tok++;
if (expr(AnEXPR, &AnEXVAL, &AnEXATTR, &AnESYM) != OK)
return ERROR;
// ([bd,An,Xn],od)
// ([bd,PC],Xn,od)
// ([bd,PC,Xn],od)
- else if (*tok.u32 == '(')
+ else if (*tok == '(')
{
- tok.u32++;
+ tok++;
- if ((*tok.u32 >= KW_A0) && (*tok.u32 <= KW_A7))
+ if ((*tok >= KW_A0) && (*tok <= KW_A7))
{
- AnREG = *tok.u32++ & 7;
+ AnREG = *tok++ & 7;
- if (*tok.u32 == ')')
+ if (*tok == ')')
{
- tok.u32++;
+ tok++;
- if (*tok.u32 == '+')
+ if (*tok == '+')
{
- tok.u32++;
+ tok++;
AMn = APOSTINC;
}
else
AMn = AINDEXED;
goto AMn_IX0; // Handle ",Xn[.siz][*scale])"
}
- else if ((*tok.u32 >= KW_D0) && (*tok.u32 <= KW_D7))
+ else if ((*tok >= KW_D0) && (*tok <= KW_D7))
{
//Since index register isn't used here, store register number in this field
- AnIXREG = *tok.u32++ & 7; // (Dn)
+ AnIXREG = *tok++ & 7; // (Dn)
- if (*tok.u32 == ')')
+ if (*tok == ')')
{
- tok.u32++;
+ tok++;
AnEXTEN |= EXT_FULLWORD; // Definitely using full extension format, so set bit 8
AnEXTEN |= EXT_BS; // Base register suppressed
AnEXTEN |= EXT_BDSIZE0; // Base displacement null
AnREG = 6 << 3; // stuff 110 to mode field
goto AnOK;
}
- else if (*tok.u32 == 'L')
+ else if (*tok == 'L')
{
// TODO: does DINDL gets used at all?
AMn = DINDL; // (Dn.l)
AnEXTEN = 1 << 1; // Long index size
- tok.u32++;
+ tok++;
}
- else if (*tok.u32 == 'W') // (Dn.w)
+ else if (*tok == 'W') // (Dn.w)
{
// TODO: does DINDW gets used at all?
AMn = DINDW;
AnEXTEN = 1 << 1; // Word index size
- tok.u32++;
+ tok++;
}
- else if (*tok.u32 == ',')
+ else if (*tok == ',')
{
// ([bd,An],Xn..) without bd, An
// Base displacement is suppressed
AnEXTEN |= EXT_BS; // Base register suppressed
AnEXTEN |= EXT_BDSIZE0;
AnREG = 6 << 3; // stuff 110 to mode field
- tok.u32++;
+ tok++;
goto CHECKODn;
}
else
return error("(Dn) error");
}
- if (*tok.u32 == '*')
+ if (*tok == '*')
{ // scale: *1, *2, *4, *8
- tok.u32++;
+ tok++;
- if (*tok.u32 == SYMBOL)
+ if (*tok == SYMBOL)
{
if (expr(AnEXPR, &AnEXVAL, &AnEXATTR, &AnESYM) != OK)
return error("scale factor expression must evaluate");
goto badmode;
}
}
- else if (*tok.u32++ != CONST || *tok.u32 > 8)
+ else if (*tok++ != CONST || *tok > 8)
goto badmode;
else
{
- switch ((int)*tok.u32++)
+ switch ((int)*tok++)
{
case 1:
break;
}
}
- if (*tok.u32 == ')')
+ if (*tok == ')')
{
- tok.u32++;
+ tok++;
AnEXTEN |= EXT_FULLWORD; // Definitely using full extension format, so set bit 8
AnEXTEN |= EXT_BS; // Base register suppressed
AnEXTEN |= EXT_BDSIZE0; // Base displacement null
AMn = MEMPOST;
goto AnOK;
}
- else if (*tok.u32 == ',')
+ else if (*tok == ',')
{
- tok.u32++; // eat the comma
+ tok++; // eat the comma
// It might be (Dn[.wl][*scale],od)
// Maybe this is wrong and we have to write some code here
// instead of reusing that path...
else
return error("unhandled so far");
}
- else if (*tok.u32 == KW_PC)
+ else if (*tok == KW_PC)
{ // (PC,Xn[.siz][*scale])
- tok.u32++;
+ tok++;
AMn = PCINDEXED;
// Common index handler; enter here with 'tok' pointing at the
AMn_IXN: // Handle any indexed (tok -> a comma)
- if (*tok.u32++ != ',')
+ if (*tok++ != ',')
goto badmode;
- if (*tok.u32 < KW_D0 || *tok.u32 > KW_A7)
+ if (*tok < KW_D0 || *tok > KW_A7)
goto badmode;
- AnIXREG = *tok.u32++ & 15;
+ AnIXREG = *tok++ & 15;
- switch ((int)*tok.u32)
+ switch ((int)*tok)
{ // Index reg size: <empty> | .W | .L
case DOTW:
- tok.u32++;
+ tok++;
default:
AnIXSIZ = 0;
break;
case DOTL:
AnIXSIZ = 0x0800;
- tok.u32++;
+ tok++;
break;
case DOTB: // .B not allowed here...
goto badmode;
}
- if (*tok.u32 == '*')
+ if (*tok == '*')
{ // scale: *1, *2, *4, *8
- tok.u32++;
+ tok++;
- if (*tok.u32 == SYMBOL)
+ if (*tok == SYMBOL)
{
if (expr(AnEXPR, &AnEXVAL, &AnEXATTR, &AnESYM) != OK)
return error("scale factor expression must evaluate");
goto badmode;
}
}
- else if (*tok.u32++ != CONST || *tok.u32 > 8)
+ else if (*tok++ != CONST || *tok > 8)
goto badmode;
else
{
- switch ((int)*tok.u32++)
+ switch ((int)*tok++)
{
case 1:
break;
}
}
- if (*tok.u32 == ',')
+ if (*tok == ',')
{
// If we got here we didn't get any [] stuff
// so let's suppress base displacement before
// branching off
- tok.u32++;
+ tok++;
AnEXTEN |= EXT_BDSIZE0; // Base displacement null - suppressed
goto CHECKODn;
}
- if (*tok.u32++ != ')') // final ")"
+ if (*tok++ != ')') // final ")"
goto badmode;
goto AnOK;
}
- else if (*tok.u32 == '[')
+ else if (*tok == '[')
{ // ([...
- tok.u32++;
+ tok++;
AnEXTEN |= EXT_FULLWORD; // Definitely using full extension format, so set bit 8
// Check to see if base displacement is present
- if (*tok.u32 != CONST && *tok.u32 != SYMBOL)
+ if (*tok != CONST && *tok != SYMBOL)
{
AnEXTEN |= EXT_BDSIZE0;
}
// bd=0 so let's optimise it out
AnEXTEN|=EXT_BDSIZE0;
}
- else if (*tok.u32 == DOTL)
+ else if (*tok == DOTL)
{ // ([bd.l,...
AnEXTEN |= EXT_BDSIZEL;
- tok.u32++;
+ tok++;
}
else
{ // ([bd[.w],... or ([bd,...
// Is .W forced here?
- if (*tok.u32 == DOTW)
+ if (*tok == DOTW)
{
AnEXTEN |= EXT_BDSIZEW;
- tok.u32++;
+ tok++;
}
else
{
}
}
- if (*tok.u32 == ',')
- tok.u32++;
+ if (*tok == ',')
+ tok++;
//else
// return error("Comma expected after base displacement");
}
// Check for address register or PC, suppress base register
// otherwise
- if (*tok.u32 == KW_PC)
+ if (*tok == KW_PC)
{ // ([bd,PC,...
AnREG = (7 << 3) | 3; // PC is special case - stuff 011 to register field and 111 to the mode field
- tok.u32++;
+ tok++;
}
- else if ((*tok.u32 >= KW_A0) && (*tok.u32 <= KW_A7))
+ else if ((*tok >= KW_A0) && (*tok <= KW_A7))
{ // ([bd,An,...
- AnREG = (6 << 3) | *tok.u32 & 7;
- tok.u32++;
+ AnREG = (6 << 3) | *tok & 7;
+ tok++;
}
- else if ((*tok.u32 >= KW_D0) && (*tok.u32 <= KW_D7))
+ else if ((*tok >= KW_D0) && (*tok <= KW_D7))
{
// ([bd,Dn,...
AnREG = (6 << 3);
- AnEXTEN |= ((*tok.u32 & 7) << 12);
+ AnEXTEN |= ((*tok & 7) << 12);
AnEXTEN |= EXT_D;
AnEXTEN |= EXT_BS; // Oh look, a data register! Which means that base register is suppressed
- tok.u32++;
+ tok++;
// Check for size
{
// ([bd,An/PC],Xn.W/L...)
- switch ((int)*tok.u32)
+ switch ((int)*tok)
{
// Index reg size: <empty> | .W | .L
case DOTW:
- tok.u32++;
+ tok++;
break;
default:
break;
case DOTL:
AnEXTEN |= EXT_L;
- tok.u32++;
+ tok++;
break;
case DOTB:
// .B not allowed here...
}
// Check for scale
- if (*tok.u32 == '*') // ([bd,An/PC],Xn*...)
+ if (*tok == '*') // ([bd,An/PC],Xn*...)
{ // scale: *1, *2, *4, *8
- tok.u32++;
+ tok++;
- if (*tok.u32 == SYMBOL)
+ if (*tok == SYMBOL)
{
if (expr(AnEXPR, &AnEXVAL, &AnEXATTR, &AnESYM) != OK)
return error("scale factor expression must evaluate");
goto badmode;
}
}
- else if (*tok.u32++ != CONST || *tok.u32 > 8)
+ else if (*tok++ != CONST || *tok > 8)
goto badmode;
else
{
- switch ((int)*tok.u32++)
+ switch ((int)*tok++)
{
case 1:
break;
}
}
}
- if (*tok.u32 == ']') // ([bd,Dn]...
+ if (*tok == ']') // ([bd,Dn]...
{
- tok.u32++;
+ tok++;
goto IS_SUPPRESSEDn;
}
}
- else if (*tok.u32 == ']')
+ else if (*tok == ']')
{
// PC and Xn is suppressed
AnREG = 6 << 3; // stuff 110 to mode field
}
// At a crossroads here. We can accept either ([bd,An/PC],... or ([bd,An/PC,Xn*scale],...
- if (*tok.u32 == ']')
+ if (*tok == ']')
{
//([bd,An/PC],Xn,od)
// Check for Xn
- tok.u32++;
+ tok++;
- if (*tok.u32 == ')')
+ if (*tok == ')')
{
//Xn and od are non existent, get out of jail free card
- tok.u32++;
+ tok++;
AMn = MEMPRE; // ([bc,An,Xn],od) with no Xn and od
AnEXTEN |= EXT_IS | EXT_IISPREN; //Suppress Xn and od
goto AnOK;
}
- else if (*tok.u32 != ',')
+ else if (*tok != ',')
return error("comma expected after ]");
else
- tok.u32++; // eat the comma
+ tok++; // eat the comma
- if ((*tok.u32 >= KW_A0) && (*tok.u32 <= KW_A7))
+ if ((*tok >= KW_A0) && (*tok <= KW_A7))
{
- AnIXREG = ((*tok.u32 & 7) << 12);
+ AnIXREG = ((*tok & 7) << 12);
AnEXTEN |= EXT_A;
- tok.u32++;
+ tok++;
}
- else if ((*tok.u32 >= KW_D0) && (*tok.u32 <= KW_D7))
+ else if ((*tok >= KW_D0) && (*tok <= KW_D7))
{
- AnEXTEN |= ((*tok.u32 & 7) << 12);
+ AnEXTEN |= ((*tok & 7) << 12);
AnEXTEN |= EXT_D;
- tok.u32++;
+ tok++;
}
else
{
//No index found, suppress it
AnEXTEN |= EXT_IS;
- tok.u32--; // Rewind tok to point to the comma
+ tok--; // Rewind tok to point to the comma
goto IS_SUPPRESSEDn; // https://xkcd.com/292/ - what does he know anyway?
}
// Check for size
{
// ([bd,An/PC],Xn.W/L...)
- switch ((int)*tok.u32)
+ switch ((int)*tok)
{
// Index reg size: <empty> | .W | .L
case DOTW:
- tok.u32++;
+ tok++;
break;
default:
break;
case DOTL:
AnEXTEN |= EXT_L;
- tok.u32++;
+ tok++;
break;
case DOTB:
// .B not allowed here...
}
// Check for scale
- if (*tok.u32 == '*') // ([bd,An/PC],Xn*...)
+ if (*tok == '*') // ([bd,An/PC],Xn*...)
{ // scale: *1, *2, *4, *8
- tok.u32++;
+ tok++;
- if (*tok.u32 == SYMBOL)
+ if (*tok == SYMBOL)
{
if (expr(AnEXPR, &AnEXVAL, &AnEXATTR, &AnESYM) != OK)
return error("scale factor expression must evaluate");
goto badmode;
}
}
- else if (*tok.u32++ != CONST || *tok.u32 > 8)
+ else if (*tok++ != CONST || *tok > 8)
goto badmode;
else
{
- switch ((int)*tok.u32++)
+ switch ((int)*tok++)
{
case 1:
break;
}
// Check for od
- if (*tok.u32 == ')') // ([bd,An/PC],Xn)
+ if (*tok == ')') // ([bd,An/PC],Xn)
{
//od is non existant, get out of jail free card
AMn = MEMPOST; // let's say it's ([bd,An],Xn,od) with od=0 then
AnEXTEN |= EXT_IISPOSN; // No outer displacement
- tok.u32++;
+ tok++;
goto AnOK;
}
- else if (*tok.u32 != ',')
+ else if (*tok != ',')
return error("comma expected");
else
- tok.u32++; // eat the comma
+ tok++; // eat the comma
CHECKODn:
if (expr(AnEXPR, &AnEXVAL, &AnEXATTR, &AnESYM) != OK)
// od=0 so optimise it out
AMn = MEMPOST; // let's say it's ([bd,An],Xn,od) with od=0 then
AnEXTEN |= EXT_IISPOSN; // No outer displacement
- tok.u32++;
+ tok++;
goto AnOK;
}
// ([bd,An/PC],Xn,od)
- if (*tok.u32 == DOTL)
+ if (*tok == DOTL)
{
// expr.L
AnEXTEN |= EXT_IISPOSL; // Long outer displacement
AMn = MEMPOST;
- tok.u32++;
+ tok++;
// Defined, absolute values from $FFFF8000..$00007FFF get
// optimized to absolute short
AMn = MEMPOST;
// Is .W forced here?
- if (*tok.u32 == DOTW)
+ if (*tok == DOTW)
{
- tok.u32++;
+ tok++;
}
}
// Check for final closing parenthesis
- if (*tok.u32 == ')')
+ if (*tok == ')')
{
- tok.u32++;
+ tok++;
goto AnOK;
}
else
IS_SUPPRESSEDn:
// Check for od
- if (*tok.u32 == ')') // ([bd,An/PC],Xn)
+ if (*tok == ')') // ([bd,An/PC],Xn)
{
//od is non existant, get out of jail free card
AMn = MEMPOST; // let's say it's ([bd,An],Xn,od) with od=0 then
AnEXTEN |= EXT_IISNOIN; // No outer displacement
- tok.u32++;
+ tok++;
goto AnOK;
}
- else if (*tok.u32!=',')
+ else if (*tok!=',')
return error("comma expected");
else
- tok.u32++; // eat the comma
+ tok++; // eat the comma
- if ((*tok.u32 != CONST) && (*tok.u32 != SYMBOL))
+ if ((*tok != CONST) && (*tok != SYMBOL))
goto badmode;
expr(AnEXPR, &AnEXVAL, &AnEXATTR, &AnESYM);
// od=0 so optimise it out
AMn = MEMPOST; // let's say it's ([bd,An],Xn,od) with od=0 then
AnEXTEN |= EXT_IISNOIN; // No outer displacement
- tok.u32++;
+ tok++;
goto AnOK;
}
// ([bd,An/PC],Xn,od)
- if (*tok.u32 == DOTL)
+ if (*tok == DOTL)
{
// expr.L
- tok.u32++;
+ tok++;
AMn = MEMPOST;
AnEXTEN |= EXT_IISNOIL; // Long outer displacement with IS suppressed
}
AnEXTEN |= EXT_IISNOIW; // Word outer displacement with IS suppressed
AMn = MEMPRE;
- if (*tok.u32 == DOTW)
+ if (*tok == DOTW)
{
//AnEXTEN|=EXT_IISNOIW; // Word outer displacement
AMn = MEMPOST;
- tok.u32++;
+ tok++;
}
// Defined, absolute values from $FFFF8000..$00007FFF get
// optimized to absolute short
}
// Check for final closing parenthesis
- if (*tok.u32 == ')')
+ if (*tok == ')')
{
- tok.u32++;
+ tok++;
goto AnOK;
}
else
return error("Closing parenthesis missing on addressing mode");
}
- else if (*tok.u32 == ',')
+ else if (*tok == ',')
{
- *tok.u32++; // ([bd,An,Xn.size*scale],od)
+ *tok++; // ([bd,An,Xn.size*scale],od)
//Check for Xn
- if ((*tok.u32 >= KW_A0) && (*tok.u32 <= KW_A7))
+ if ((*tok >= KW_A0) && (*tok <= KW_A7))
{
- AnEXTEN |= ((*tok.u32 & 7) << 12);
+ AnEXTEN |= ((*tok & 7) << 12);
AnEXTEN |= EXT_A;
- tok.u32++;
+ tok++;
}
- else if ((*tok.u32 >= KW_D0) && (*tok.u32 <= KW_D7))
+ else if ((*tok >= KW_D0) && (*tok <= KW_D7))
{
- AnEXTEN |= ((*tok.u32 & 7) << 12);
+ AnEXTEN |= ((*tok & 7) << 12);
AnEXTEN |= EXT_D;
- tok.u32++;
+ tok++;
}
// Check for size
{
// ([bd,An/PC],Xn.W/L...)
- switch ((int)*tok.u32)
+ switch ((int)*tok)
{
// Index reg size: <empty> | .W | .L
case DOTW:
- tok.u32++;
+ tok++;
break;
default:
break;
case DOTL:
- tok.u32++;
+ tok++;
AnEXTEN |= EXT_L;
break;
case DOTB:
}
// Check for scale
- if (*tok.u32 == '*') // ([bd,An/PC],Xn*...)
+ if (*tok == '*') // ([bd,An/PC],Xn*...)
{ // scale: *1, *2, *4, *8
- tok.u32++;
+ tok++;
- if (*tok.u32 == SYMBOL)
+ if (*tok == SYMBOL)
{
if (expr(AnEXPR, &AnEXVAL, &AnEXATTR, &AnESYM) != OK)
return error("scale factor expression must evaluate");
goto badmode;
}
}
- else if (*tok.u32++ != CONST || *tok.u32 > 8)
+ else if (*tok++ != CONST || *tok > 8)
goto badmode;
else
{
- switch ((int)*tok.u32++)
+ switch ((int)*tok++)
{
case 1:
break;
}
//Check for ]
- if (*tok.u32 != ']')
+ if (*tok != ']')
return error("Expected closing bracket ]");
- tok.u32++; // Eat the bracket
+ tok++; // Eat the bracket
//Check for od
- if (*tok.u32 == ')') // ([bd,An/PC,Xn]...
+ if (*tok == ')') // ([bd,An/PC,Xn]...
{
//od is non existant, get out of jail free card
//AnEXVAL=0; // zero outer displacement
AMn = MEMPRE; // let's say it's ([bd,An,Xn],od) with od suppressed then
AnEXTEN |= EXT_IISPREN; // No outer displacement
- tok.u32++;
+ tok++;
goto AnOK;
}
- else if (*tok.u32++ != ',')
+ else if (*tok++ != ',')
return error("comma expected after ]");
- if (*tok.u32 == SYMBOL || *tok.u32 == CONST)
+ if (*tok == SYMBOL || *tok == CONST)
{
if (expr(AnEXPR, &AnEXVAL, &AnEXATTR, &AnESYM) != OK)
goto badmode;
// od=0 so optimise it out
AMn = MEMPRE; // let's say it's ([bd,An],Xn,od) with od=0 then
AnEXTEN |= EXT_IISPRE0; // No outer displacement
- tok.u32++;
+ tok++;
goto AnOK;
}
}
// ([bd,An/PC,Xn],od)
- if (*tok.u32 == DOTL)
+ if (*tok == DOTL)
{
// expr.L
AMn = MEMPRE;
- tok.u32++;
+ tok++;
AnEXTEN |= EXT_IISPREL;
}
else
AnEXTEN |= expr_size; // Assume we have a .w value
// Is .W forced here?
- if (*tok.u32 == DOTW)
+ if (*tok == DOTW)
{
- tok.u32++;
+ tok++;
if (expr_size == EXT_IISPREL)
return error("outer displacement value does not fit in .w size");
}
// Check for final closing parenthesis
- if (*tok.u32 == ')')
+ if (*tok == ')')
{
- tok.u32++;
+ tok++;
goto AnOK;
}
else
// It could be that this is really just an expression prefixing a
// register as a displacement...
- if (*tok.u32 == ')')
+ if (*tok == ')')
{
- tok.u32++;
+ tok++;
goto CHK_FOR_DISPn;
}
// Otherwise, check for PC & etc displacements...
- if (*tok.u32++ != ',')
+ if (*tok++ != ',')
goto badmode;
- if ((*tok.u32 >= KW_A0) && (*tok.u32 <= KW_A7))
+ if ((*tok >= KW_A0) && (*tok <= KW_A7))
{
- AnREG = *tok.u32 & 7;
- tok.u32++;
+ AnREG = *tok & 7;
+ tok++;
- if (*tok.u32 == ',')
+ if (*tok == ',')
{
AMn = AINDEXED;
goto AMn_IXN;
}
- else if (*tok.u32 == ')')
+ else if (*tok == ')')
{
AMn = ADISP;
- tok.u32++;
+ tok++;
goto AnOK;
}
else
goto badmode;
}
- else if (*tok.u32 == KW_PC)
+ else if (*tok == KW_PC)
{
- if (*++tok.u32 == ',')
+ if (*++tok == ',')
{ // expr(PC,Xn...)
AMn = PCINDEXED;
goto AMn_IXN;
}
- else if (*tok.u32 == ')')
+ else if (*tok == ')')
{
AMn = PCDISP; // expr(PC)
- tok.u32++;
+ tok++;
goto AnOK;
}
else
goto badmode;
}
}
- else if (*tok.u32 == '-' && tok.u32[1] == '(' && ((tok.u32[2] >= KW_A0) && (tok.u32[2] <= KW_A7)) && tok.u32[3] == ')')
+ else if (*tok == '-' && tok[1] == '(' && ((tok[2] >= KW_A0) && (tok[2] <= KW_A7)) && tok[3] == ')')
{
AMn = APREDEC;
- AnREG = tok.u32[2] & 7;
- tok.u32 += 4;
+ AnREG = tok[2] & 7;
+ tok += 4;
}
- else if (*tok.u32 == KW_CCR)
+ else if (*tok == KW_CCR)
{
AMn = AM_CCR;
- tok.u32++;
+ tok++;
goto AnOK;
}
- else if (*tok.u32 == KW_SR)
+ else if (*tok == KW_SR)
{
AMn = AM_SR;
- tok.u32++;
+ tok++;
goto AnOK;
}
- else if (*tok.u32 == KW_USP)
+ else if (*tok == KW_USP)
{
AMn = AM_USP;
- tok.u32++;
+ tok++;
AnREG = 2; //Added this for the case of USP used in movec (see CREGlut in mach.c). Hopefully nothing gets broken!
goto AnOK;
}
- else if ((*tok.u32 >= KW_IC40) && (*tok.u32 <= KW_BC40))
+ else if ((*tok >= KW_IC40) && (*tok <= KW_BC40))
{
AMn = CACHES;
- AnREG = *tok.u32++ - KW_IC40;
+ AnREG = *tok++ - KW_IC40;
// After a cache keyword only a comma or EOL is allowed
- if ((*tok.u32 != ',') && (*tok.u32 != EOL))
+ if ((*tok != ',') && (*tok != EOL))
return ERROR;
goto AnOK;
}
- else if ((*tok.u32 >= KW_SFC) && (*tok.u32 <= KW_CRP))
+ else if ((*tok >= KW_SFC) && (*tok <= KW_CRP))
{
AMn = CREG;
- AnREG = (*tok.u32++) - KW_SFC;
+ AnREG = (*tok++) - KW_SFC;
goto AnOK;
}
- else if ((*tok.u32 >= KW_FP0) && (*tok.u32 <= KW_FP7))
+ else if ((*tok >= KW_FP0) && (*tok <= KW_FP7))
{
AMn = FREG;
- AnREG = (*tok.u32++ & 7);
+ AnREG = (*tok++ & 7);
}
- else if ((*tok.u32 >= KW_FPIAR) && (*tok.u32 <= KW_FPCR))
+ else if ((*tok >= KW_FPIAR) && (*tok <= KW_FPCR))
{
AMn = FPSCR;
- AnREG = (1 << ((*tok.u32++) - KW_FPIAR + 10));
+ AnREG = (1 << ((*tok++) - KW_FPIAR + 10));
}
// expr
// expr.w
return ERROR;
CHK_FOR_DISPn:
- if (*tok.u32 == DOTW)
+ if (*tok == DOTW)
{
// expr.W
- tok.u32++;
+ tok++;
AMn = ABSW;
if (((AnEXATTR & (TDB | DEFINED)) == DEFINED) && (AnEXVAL < 0x10000))
goto AnOK;
}
- else if (*tok.u32 != '(')
+ else if (*tok != '(')
{
// expr[.L]
AMn = ABSL;
}
// Is .L forced here?
- if (*tok.u32 == DOTL)
+ if (*tok == DOTL)
{
- tok.u32++;
+ tok++;
AMn = ABSL;
}
goto AnOK;
}
- tok.u32++;
+ tok++;
- if ((*tok.u32 >= KW_A0) && (*tok.u32 <= KW_A7))
+ if ((*tok >= KW_A0) && (*tok <= KW_A7))
{
- AnREG = *tok.u32++ & 7;
+ AnREG = *tok++ & 7;
- if (*tok.u32 == ')')
+ if (*tok == ')')
{
AMn = ADISP;
- tok.u32++;
+ tok++;
goto AnOK;
}
AMn = AINDEXED;
goto AMn_IXN;
}
- else if (*tok.u32 == KW_PC)
+ else if (*tok == KW_PC)
{
- if (*++tok.u32 == ')')
+ if (*++tok == ')')
{
AMn = PCDISP;
- tok.u32++;
+ tok++;
goto AnOK;
}
label = NULL; // No label
lab_sym = NULL; // No (exported) label
equate = NULL; // No equate
- tk = tok.u32; // Save first token in line
+ tk = tok; // Save first token in line
pcloc = (uint32_t)sloc; // Set beginning-of-line PC
loop1: // Internal line processing loop
- if (*tok.u32 == EOL) // Restart loop if end-of-line
+ if (*tok == EOL) // Restart loop if end-of-line
goto loop;
// First token MUST be a symbol (Shamus: not sure why :-/)
- if (*tok.u32 != SYMBOL)
+ if (*tok != SYMBOL)
{
- if ((*tok.u32 >= KW_D0) && (*tok.u32 <= KW_R31))
+ if ((*tok >= KW_D0) && (*tok <= KW_R31))
error("cannot use reserved keyword as label name or .equ");
else
error("syntax error; expected symbol");
goto loop;
}
- j = (int)tok.u32[2]; // Skip equates (normal statements)
+ j = (int)tok[2]; // Skip equates (normal statements)
if (j == '=' || j == DEQUALS || j == SET || j == REG || j == EQUREG || j == CCDEF)
{
- equate = string[tok.u32[1]];
+ equate = string[tok[1]];
equtyp = j;
- tok.u32 += 3;
+ tok += 3;
goto normal;
}
if (j == ':' || j == DCOLON)
{
as68label:
- label = string[tok.u32[1]]; // Get label name
- labtyp = tok.u32[2]; // Get label type
- tok.u32 += 3; // Go to next line token
+ label = string[tok[1]]; // Get label name
+ labtyp = tok[2]; // Get label type
+ tok += 3; // Go to next line token
// AS68 MODE:
// Looks like another label follows the previous one, so handle
// the previous one until there aren't any more
- if (as68_flag && (*tok.u32 == SYMBOL && tok.u32[2] == ':'))
+ if (as68_flag && (*tok == SYMBOL && tok[2] == ':'))
{
if (HandleLabel(label, labtyp) != 0)
goto loop;
}
// EOL is legal here...
- if (*tok.u32 == EOL)
+ if (*tok == EOL)
goto normal;
// First token MUST be a symbol (if we get here, tok didn't advance)
- if (*tok.u32++ != SYMBOL)
+ if (*tok++ != SYMBOL)
{
error("syntax error; expected symbol");
goto loop;
}
- opname = p = string[*tok.u32++];
+ opname = p = string[*tok++];
// Check to see if the SYMBOL is a keyword (a mnemonic or directive).
// On output, `state' will have one of the values:
// Check for ".b" ".w" ".l" after directive, macro or mnemonic.
siz = SIZN;
- switch (*tok.u32)
+ switch (*tok)
{
- case DOTW: siz = SIZW, tok.u32++; break;
- case DOTL: siz = SIZL, tok.u32++; break;
- case DOTB: siz = SIZB, tok.u32++; break;
- case DOTD: siz = SIZD, tok.u32++; break;
- case DOTP: siz = SIZP, tok.u32++; break;
- case DOTQ: siz = SIZQ, tok.u32++; break;
- case DOTS: siz = SIZS, tok.u32++; break;
- case DOTX: siz = SIZX, tok.u32++; break;
+ case DOTW: siz = SIZW, tok++; break;
+ case DOTL: siz = SIZL, tok++; break;
+ case DOTB: siz = SIZB, tok++; break;
+ case DOTD: siz = SIZD, tok++; break;
+ case DOTP: siz = SIZP, tok++; break;
+ case DOTQ: siz = SIZQ, tok++; break;
+ case DOTS: siz = SIZS, tok++; break;
+ case DOTX: siz = SIZX, tok++; break;
}
// Do special directives (500..999) (These must be handled in "real time")
goto loop;
}
- if (*tok.u32++ != ',')
+ if (*tok++ != ',')
{
error(comma_error);
goto loop;
}
// Check for register to equate to
- if ((*tok.u32 >= KW_R0) && (*tok.u32 <= KW_R31))
+ if ((*tok >= KW_R0) && (*tok <= KW_R31))
{
// sy->sattre = EQUATEDREG | RISCSYM; // Mark as equated register
sy->sattre = EQUATEDREG; // Mark as equated register
- riscreg = (*tok.u32 - KW_R0);
+ riscreg = (*tok - KW_R0);
//is there any reason to do this, since we're putting this in svalue?
//i'm thinking, no. Let's test that out! :-D
// sy->sattre |= (riscreg << 8); // Store register number
#endif
// Check for ",<bank #>" override notation
- if ((tok.u32[1] == ',') && (tok.u32[2] == CONST))
+ if ((tok[1] == ',') && (tok[2] == CONST))
{
// Advance token pointer to the constant
- tok.u32 += 3;
+ tok += 3;
// Anything other than a 0 or a 1 will result in "No Bank"
- if (*(uint64_t *)tok.u32 == 0)
+ if (*(uint64_t *)tok == 0)
registerbank = BANK_0;
- else if (*(uint64_t *)tok.u32 == 1)
+ else if (*(uint64_t *)tok == 1)
registerbank = BANK_1;
}
// & what does this $80000080 constant mean???
// eval = 0x80000080 + (riscreg) + (registerbank << 8);
eval = riscreg;
- tok.u32++;
+ tok++;
}
// Checking for a register symbol
- else if (tok.u32[0] == SYMBOL)
+ else if (tok[0] == SYMBOL)
{
- sy2 = lookup(string[tok.u32[1]], LABEL, j);
+ sy2 = lookup(string[tok[1]], LABEL, j);
// Make sure symbol is a valid equreg
if (!sy2 || !(sy2->sattre & EQUATEDREG))
eattr = ABS | DEFINED | GLOBAL; // Copy symbols attributes
sy->sattre = sy2->sattre;
eval = (sy2->svalue & 0xFFFFF0FF);
- tok.u32 += 2;
+ tok += 2;
}
}
else
sy->sattre |= EQUATEDCC;
eattr = ABS | DEFINED | GLOBAL;
- if (tok.u32[0] == SYMBOL)
+ if (tok[0] == SYMBOL)
{
- sy2 = lookup(string[tok.u32[1]], LABEL, j);
+ sy2 = lookup(string[tok[1]], LABEL, j);
if (!sy2 || !(sy2->sattre & EQUATEDCC))
{
eattr = ABS | DEFINED | GLOBAL;
sy->sattre = sy2->sattre;
eval = sy2->svalue;
- tok.u32 += 2;
+ tok += 2;
}
}
else if (expr(exprbuf, &eval, &eattr, &esym) != OK)
goto loop;
}
//equ a equr
- else if (*tok.u32 == SYMBOL)
+ else if (*tok == SYMBOL)
{
- sy2 = lookup(string[tok.u32[1]], LABEL, j);
+ sy2 = lookup(string[tok[1]], LABEL, j);
if (sy2 && (sy2->sattre & EQUATEDREG))
{
if (amode(1) < 0) // Parse 0, 1 or 2 addr modes
goto loop;
- if (*tok.u32 != EOL)
+ if (*tok != EOL)
error(extra_stuff);
amsk0 = amsktab[am0];
TOKEN r_expr[EXPRSIZE]; // Expression token list
// Evaluate what's in the global "tok" buffer
- if (expr((TOKENPTR)r_expr, &eval, &eattr, &esym) != OK)
+ if (expr(r_expr, &eval, &eattr, &esym) != OK)
return ERROR;
if ((challoc - ch_size) < 4)
if (!(eattr & DEFINED))
{
- AddFixup((WORD)(FU_WORD | rattr), sloc, (TOKENPTR)r_expr);
+ AddFixup((WORD)(FU_WORD | rattr), sloc, r_expr);
return 0;
}
if (parm & SUB32)
attrflg |= FU_SUB32;
- if (*tok.u32 != '#')
+ if (*tok != '#')
return MalformedOpcode(0x01);
- tok.u32++;
+ tok++;
riscImmTokenSeen = 1;
- if (expr((TOKENPTR)r_expr, &eval, &eattr, &esym) != OK)
+ if (expr(r_expr, &eval, &eattr, &esym) != OK)
return MalformedOpcode(0x02);
if ((challoc - ch_size) < 4)
if (!(eattr & DEFINED))
{
- AddFixup((WORD)(FU_WORD | attrflg), sloc, (TOKENPTR)r_expr);
+ AddFixup((WORD)(FU_WORD | attrflg), sloc, r_expr);
reg1 = 0;
}
else
// Move Immediate--n,Rn--n in Second Word
case RI_MOVEI:
- if (*tok.u32 != '#')
+ if (*tok != '#')
return MalformedOpcode(0x03);
- tok.u32++;
+ tok++;
riscImmTokenSeen = 1;
// Check for equated register after # and return error if so
- if (*tok.u32 == SYMBOL)
+ if (*tok == SYMBOL)
{
- sy = lookup(string[tok.u32[1]], LABEL, 0);
+ sy = lookup(string[tok[1]], LABEL, 0);
if (sy && (sy->sattre & EQUATEDREG))
return error("equated register in 1st operand of MOVEI instruction");
}
- if (expr((TOKENPTR)r_expr, &eval, &eattr, &esym) != OK)
+ if (expr(r_expr, &eval, &eattr, &esym) != OK)
return MalformedOpcode(0x04);
if (lastOpcode == RI_JUMP || lastOpcode == RI_JR)
if (!(eattr & DEFINED))
{
- AddFixup(FU_LONG | FU_MOVEI, sloc + 2, (TOKENPTR)r_expr);
+ AddFixup(FU_LONG | FU_MOVEI, sloc + 2, r_expr);
eval = 0;
}
else
// PC,Rd or Rs,Rd
case RI_MOVE:
- if (*tok.u32 == KW_PC)
+ if (*tok == KW_PC)
{
parm = 51;
reg1 = 0;
- tok.u32++;
+ tok++;
}
else
{
indexed = 0;
parm = 41;
- if (*tok.u32 != '(')
+ if (*tok != '(')
return MalformedOpcode(0x05);
- tok.u32++;
+ tok++;
- if ((*(tok.u32 + 1) == '+') || (*(tok.u32 + 1) == '-')) {
+ if ((*(tok + 1) == '+') || (*(tok + 1) == '-')) {
// Trying to make indexed call
- if ((*tok.u32 == KW_R14 || *tok.u32 == KW_R15)) {
- indexed = (*tok.u32 - KW_R0);
+ if ((*tok == KW_R14 || *tok == KW_R15)) {
+ indexed = (*tok - KW_R0);
} else {
- return IllegalIndexedRegister(*tok.u32);
+ return IllegalIndexedRegister(*tok);
}
}
- if (*tok.u32 == SYMBOL)
+ if (*tok == SYMBOL)
{
-// sy = lookup((char *)tok.u32[1], LABEL, 0);
- sy = lookup(string[tok.u32[1]], LABEL, 0);
+// sy = lookup((char *)tok[1], LABEL, 0);
+ sy = lookup(string[tok[1]], LABEL, 0);
if (!sy)
{
if (sy->sattre & EQUATEDREG)
{
- if ((*(tok.u32 + 2) == '+') || (*(tok.u32 + 2) == '-')) {
+ if ((*(tok + 2) == '+') || (*(tok + 2) == '-')) {
if ((sy->svalue & 0x1F) == 14 || (sy->svalue & 0x1F) == 15) {
indexed = (sy->svalue & 0x1F);
- tok.u32++;
+ tok++;
} else {
return IllegalIndexedRegisterEqur(sy);
}
{
reg1 = indexed;
indexed = 0;
- tok.u32++;
+ tok++;
- if (*tok.u32 == '+')
+ if (*tok == '+')
{
parm = (WORD)(reg1 - 14 + 58);
- tok.u32++;
+ tok++;
- if (*tok.u32 >= KW_R0 && *tok.u32 <= KW_R31)
+ if (*tok >= KW_R0 && *tok <= KW_R31)
indexed = 1;
- if (*tok.u32 == SYMBOL)
+ if (*tok == SYMBOL)
{
-// sy = lookup((char *)tok.u32[1], LABEL, 0);
- sy = lookup(string[tok.u32[1]], LABEL, 0);
+// sy = lookup((char *)tok[1], LABEL, 0);
+ sy = lookup(string[tok[1]], LABEL, 0);
if (!sy)
{
}
else
{
- if (expr((TOKENPTR)r_expr, &eval, &eattr, &esym) != OK)
+ if (expr(r_expr, &eval, &eattr, &esym) != OK)
return MalformedOpcode(0x06);
if ((challoc - ch_size) < 4)
}
}
- if (*tok.u32 != ')')
+ if (*tok != ')')
return MalformedOpcode(0x07);
- tok.u32++;
+ tok++;
CHECK_COMMA;
reg2 = GetRegister(FU_REGTWO);
at_eol();
reg1 = GetRegister(FU_REGONE);
CHECK_COMMA;
- if (*tok.u32 != '(')
+ if (*tok != '(')
return MalformedOpcode(0x08);
- tok.u32++;
+ tok++;
indexed = 0;
- if ((*tok.u32 == KW_R14 || *tok.u32 == KW_R15) && (*(tok.u32 + 1) != ')'))
- indexed = (*tok.u32 - KW_R0);
+ if ((*tok == KW_R14 || *tok == KW_R15) && (*(tok + 1) != ')'))
+ indexed = (*tok - KW_R0);
- if (*tok.u32 == SYMBOL)
+ if (*tok == SYMBOL)
{
- sy = lookup(string[tok.u32[1]], LABEL, 0);
+ sy = lookup(string[tok[1]], LABEL, 0);
if (!sy)
{
if (sy->sattre & EQUATEDREG)
{
if (((sy->svalue & 0x1F) == 14 || (sy->svalue & 0x1F) == 15)
- && (*(tok.u32 + 2) != ')'))
+ && (*(tok + 2) != ')'))
{
indexed = (sy->svalue & 0x1F);
- tok.u32++;
+ tok++;
}
}
}
{
reg2 = indexed;
indexed = 0;
- tok.u32++;
+ tok++;
- if (*tok.u32 == '+')
+ if (*tok == '+')
{
parm = (WORD)(reg2 - 14 + 60);
- tok.u32++;
+ tok++;
- if (*tok.u32 >= KW_R0 && *tok.u32 <= KW_R31)
+ if (*tok >= KW_R0 && *tok <= KW_R31)
indexed = 1;
- if (*tok.u32 == SYMBOL)
+ if (*tok == SYMBOL)
{
- sy = lookup(string[tok.u32[1]], LABEL, 0);
+ sy = lookup(string[tok[1]], LABEL, 0);
if (!sy)
{
}
else
{
- if (expr((TOKENPTR)r_expr, &eval, &eattr, &esym) != OK)
+ if (expr(r_expr, &eval, &eattr, &esym) != OK)
return MalformedOpcode(0x09);
if ((challoc - ch_size) < 4)
if (!(eattr & DEFINED))
{
- AddFixup(FU_WORD | FU_REGTWO, sloc, (TOKENPTR)r_expr);
+ AddFixup(FU_WORD | FU_REGTWO, sloc, r_expr);
reg2 = 0;
}
else
}
}
- if (*tok.u32 != ')')
+ if (*tok != ')')
return MalformedOpcode(0x0A);
- tok.u32++;
+ tok++;
at_eol();
BuildRISCIntructionWord(parm, reg2, reg1);
break;
// LOADB/LOADP/LOADW (Rn),Rn
case RI_LOADN:
- if (*tok.u32 != '(')
+ if (*tok != '(')
return MalformedOpcode(0x0B);
- tok.u32++;
+ tok++;
reg1 = GetRegister(FU_REGONE);
- if (*tok.u32 != ')')
+ if (*tok != ')')
return MalformedOpcode(0x0C);
- tok.u32++;
+ tok++;
CHECK_COMMA;
reg2 = GetRegister(FU_REGTWO);
at_eol();
reg1 = GetRegister(FU_REGONE);
CHECK_COMMA;
- if (*tok.u32 != '(')
+ if (*tok != '(')
return MalformedOpcode(0x0D);
- tok.u32++;
+ tok++;
reg2 = GetRegister(FU_REGTWO);
- if (*tok.u32 != ')')
+ if (*tok != ')')
return MalformedOpcode(0x0E);
- tok.u32++;
+ tok++;
at_eol();
BuildRISCIntructionWord(parm, reg2, reg1);
break;
// the JR or JUMP should default to 0, Jump Always
commaFound = 0;
- for(t=tok.u32; *t!=EOL; t++)
+ for(t=tok; *t!=EOL; t++)
{
if (*t == ',')
{
if (commaFound)
{
- if (*tok.u32 == CONST)
+ if (*tok == CONST)
{
// CC using a constant number
- tok.u32++;
- uint64_t *tok64 = (uint64_t *)tok.u32;
+ tok++;
+ uint64_t *tok64 = (uint64_t *)tok;
val = (int)*tok64++;
- tok.u32 = (uint32_t *)tok64;
+ tok = (uint32_t *)tok64;
CHECK_COMMA;
}
- else if (*tok.u32 == SYMBOL)
+ else if (*tok == SYMBOL)
{
val = 99;
-// strcpy(scratch, (char *)tok.u32[1]);
- strcpy(scratch, string[tok.u32[1]]);
+// strcpy(scratch, (char *)tok[1]);
+ strcpy(scratch, string[tok[1]]);
strtoupper(scratch);
for(i=0; i<MAXINTERNCC; i++)
// Standard CC was not found, look for an equated one
if (val == 99)
{
-// ccsym = lookup((char *)tok.u32[1], LABEL, 0);
- ccsym = lookup(string[tok.u32[1]], LABEL, 0);
+// ccsym = lookup((char *)tok[1], LABEL, 0);
+ ccsym = lookup(string[tok[1]], LABEL, 0);
if (ccsym && (ccsym->sattre & EQUATEDCC) && !(ccsym->sattre & UNDEF_CC))
val = ccsym->svalue;
return error("unknown condition code");
}
- tok.u32 += 2;
+ tok += 2;
CHECK_COMMA;
}
- else if (*tok.u32 == '(')
+ else if (*tok == '(')
{
// Set CC to "Jump Always"
val = 0;
if (type == RI_JR)
{
// JR cc,n
- if (expr((TOKENPTR)r_expr, &eval, &eattr, &esym) != OK)
+ if (expr(r_expr, &eval, &eattr, &esym) != OK)
return MalformedOpcode(0x0F);
if ((challoc - ch_size) < 4)
if (!(eattr & DEFINED))
{
- AddFixup(FU_WORD | FU_JR, sloc, (TOKENPTR)r_expr);
+ AddFixup(FU_WORD | FU_JR, sloc, r_expr);
reg2 = 0;
}
else
else
{
// JUMP cc, (Rn)
- if (*tok.u32 != '(')
+ if (*tok != '(')
return MalformedOpcode(0x10);
- tok.u32++;
+ tok++;
reg2 = GetRegister(FU_REGTWO);
- if (*tok.u32 != ')')
+ if (*tok != ')')
return MalformedOpcode(0x11);
- tok.u32++;
+ tok++;
at_eol();
BuildRISCIntructionWord(parm, reg2, reg1);
}
#define GPUONLY 0x4000 // Opcode is for the GPU Only
#define DSPONLY 0x8000 // Opcode is for the DSP Only
-#define CHECK_COMMA if(*tok.u32++ != ',') { error(comma_error); return(ERROR); }
+#define CHECK_COMMA if(*tok++ != ',') { error(comma_error); return(ERROR); }
// Opcode Specific Data
struct opcoderecord {
// Assembler token
#define TOKEN uint32_t
-// Token pointer type is a union because we have 64-bit sized tokens now :-P
-#define TOKENPTR union _tokenptr
-TOKENPTR
-{
- uint32_t * u32;
- uint64_t * u64;
-};
-
// Pointer type that can point to (almost) anything
#define PTR union _ptr
PTR
{
- uint8_t * cp; // Char
- uint16_t * wp; // WORD
- uint32_t * lp; // LONG
- uint32_t lw; // LONG
- SYM ** sy; // SYM
- TOKENPTR tk; // TOKEN
+ uint8_t * cp; // Char pointer
+ uint16_t * wp; // WORD pointer
+ uint32_t * lp; // LONG pointer
+ uint32_t * u32; // 32-bit pointer
+ uint64_t * u64; // 64-bit pointer
+ uint32_t lw; // LONG (for some reason)
+ SYM ** sy; // SYM pointer
+ TOKEN * tk; // TOKEN pointer
};
// Symbol spaces
//
// Arrange for a fixup on a location
//
-int AddFixup(uint16_t attr, uint32_t loc, TOKENPTR fexpr)
+int AddFixup(uint16_t attr, uint32_t loc, TOKEN * fexpr)
{
uint32_t i = MIN_FIXUP_MEM;
uint16_t len = 0;
// Compute length of expression (could be faster); determine if it's the
// single-symbol case; no expression if it's just a mark. (? is this true?)
- if ((*fexpr.u32 == SYMBOL) && (fexpr.u32[2] == ENDEXPR))
+ if ((*fexpr == SYMBOL) && (fexpr[2] == ENDEXPR))
{
// Just a single symbol, possibly followed by a DWORD
i += sizeof(SYM *);
attr |= FU_EXPR;
// Count the # of tokens in the expression
- for(len=0; fexpr.u32[len]!=ENDEXPR; len++)
+ for(len=0; fexpr[len]!=ENDEXPR; len++)
{
// Add one to len for 2X tokens, two for 3X tokens
- if (fexpr.u32[len] == SYMBOL)
+ if (fexpr[len] == SYMBOL)
len++;
- else if (fexpr.u32[len] == CONST)
+ else if (fexpr[len] == CONST)
len += 2;
}
*fchptr.wp++ = len;
while (len--)
- *fchptr.lp++ = *fexpr.u32++;
+ *fchptr.lp++ = *fexpr++;
}
else
{
- *fchptr.sy++ = symbolPtr[fexpr.u32[1]];
+ *fchptr.sy++ = symbolPtr[fexpr[1]];
// SCPCD: Correct bit mask for attr (else other FU_xxx will match)
// NYAN !
{
i = *fup.wp++;
- if (evexpr((TOKENPTR)fup.tk, &eval, &eattr, &esym) != OK)
+ if (evexpr(fup.tk, &eval, &eattr, &esym) != OK)
{
fup.lp += i;
continue;
#else
-#error Please implement a non-byte swapped D_extend!
+WARNING(Please implement a non-byte swapped D_extend!)
+//stopgap for now, until this can be implemented proppa-ly :-P
+#define D_extend(w) {chcheck(12); chptr+=12; sloc+=12; ch_size+=12; if(orgactive) orgaddr +=12;}
#endif
// Fill n bytes with zeroes
void SaveSection(void);
int fixtest(int, uint32_t);
int chcheck(uint32_t);
-int AddFixup(uint16_t, uint32_t, TOKENPTR);
+int AddFixup(uint16_t, uint32_t, TOKEN *);
int ResolveAllFixups(void);
#endif // __SECT_H__
//
#include "token.h"
+
+#include <errno.h>
#include "direct.h"
#include "error.h"
#include "macro.h"
char lnbuf[LNSIZ]; // Text of current line
WORD filecount; // Unique file number counter
WORD cfileno; // Current file number
-TOKENPTR tok; // Ptr to current token
+TOKEN * tok; // Ptr to current token
TOKEN * etok; // Ptr past last token in tokbuf[]
TOKEN tokeol[1] = {EOL}; // Bailout end-of-line token
char * string[TOKBUFSIZE*2];// Token buffer string pointer storage
// Install INOBJ on top of input stack
inobj->in_ifent = ifent; // Record .if context on entry
inobj->in_type = (WORD)typ;
- inobj->in_otok = tok.u32;
+ inobj->in_otok = tok;
inobj->in_etok = etok;
inobj->in_link = cur_inobj;
cur_inobj = inobj;
if (numUnmatched > 0)
warn("missing %d .endif(s)", numUnmatched);
- tok.u32 = inobj->in_otok; // Restore tok and otok
+ tok = inobj->in_otok; // Restore tok and otok
etok = inobj->in_etok;
switch (inobj->in_type)
{
uint8_t * ln = NULL; // Ptr to current position in line
uint8_t * p; // Random character ptr
- TOKENPTR tk; // Token-deposit ptr
+ PTR tk; // Token-deposit ptr
int state = 0; // State for keyword detector
int j = 0; // Var for keyword detector
uint8_t c; // Random char
strcpy(lnbuf, ln);
// General housekeeping
- tok.u32 = tokeol; // Set "tok" to EOL in case of error
+ tok = tokeol; // Set "tok" to EOL in case of error
tk.u32 = etok; // Reset token ptr
stuffnull = 0; // Don't stuff nulls
totlines++; // Bump total #lines assembled
}
#else
// Here we parse the whole floating point number
-#include <errno.h>
char * numEnd;
errno = 0;
double f = strtod(numStart, &numEnd);
// Terminate line of tokens and return "success."
goteol:
- tok.u32 = etok; // Set tok to beginning of line
+ tok = etok; // Set tok to beginning of line
if (stuffnull) // Terminate last SYMBOL
*nullspot = EOS;
int d_goto(WORD unused)
{
// Setup for the search
- if (*tok.u32 != SYMBOL)
+ if (*tok != SYMBOL)
return error("missing label");
- char * sym = string[tok.u32[1]];
- tok.u32 += 2;
+ char * sym = string[tok[1]];
+ tok += 2;
if (cur_inobj->in_type != SRC_IMACRO)
return error("goto not in macro");
printf("[COLON]");
else if (*t == CONST)
{
- TOKENPTR tp = (TOKENPTR)(t + 1);
- printf("[CONST: $%lX]", (uint64_t)(*tp.u64));
+ PTR tp;
+ tp.u32 = t + 1;
+ printf("[CONST: $%lX]", *tp.u64);
t += 2;
}
else if (*t == ACONST)
extern uint16_t curlineno;
extern char * curfname;
extern WORD cfileno;
-extern TOKENPTR tok;
+extern TOKEN * tok;
extern char lnbuf[];
extern char lntag;
extern char tolowertab[];
#define MAJOR 1 // Major version number
#define MINOR 10 // Minor version number
-#define PATCH 0 // Patch release number
+#define PATCH 1 // Patch release number
#endif // __VERSION_H__