#define DECL_KW // Declare keyword arrays
#define DEF_KW // Declare keyword values
#include "kwtab.h" // Incl generated keyword tables & defs
+#define DEF_REG68 // Incl 68k register definitions
+#include "68kregs.h"
+#define DEF_REGRISC // Include GPU/DSP register definitions
+#include "riscregs.h"
+#define DEF_UNARY // Declare unary values
+#define DECL_UNARY // Incl uanry keyword state machine tables
+#include "unarytab.h" // Incl generated unary tables & defs
int lnsave; // 1; strcpy() text of current line
"a10","b10","x","y","","","ab","ba" // 312,319
};
-static char * riscregname[] = {
- "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
- "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
- "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
- "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31"
-};
-
//
// Initialize tokenizer
// This is a hack. It might be better table-driven.
d = NULL;
- if ((*tk >= KW_D0) && !rdsp && !rgpu)
- {
- d = regname[(int)*tk++ - KW_D0];
- goto strcopy;
- }
- else if ((*tk >= KW_R0) && (*tk <= KW_R31))
+ if (*tk >= REG68_D0)
{
- d = riscregname[(int)*tk++ - KW_R0];
+ d = regname[(int)*tk++ - REG68_D0];
goto strcopy;
}
else
uint8_t c1;
int stringNum = 0; // Pointer to string locations in tokenized line
SYM* sy; // For looking up symbols (.equr)
+ int equrundef = 0; // Flag for equrundef scanning
retry:
// If the symbol is small, check to see if it's really the name of
// a register.
- if (j <= KWSIZE)
+ uint8_t *p2 = p;
+ if (j <= 5)
{
- for(state=0; state>=0;)
+ for (state = 0; state >= 0;)
{
j = (int)tolowertab[*p++];
- j += kwbase[state];
+ j += regbase[state];
- if (kwcheck[j] != state)
+ if (regcheck[j] != state)
{
j = -1;
break;
if (*p == EOS || p == ln)
{
- j = kwaccept[j];
+ j = regaccept[j];
+ goto skip_keyword;
break;
}
- state = kwtab[j];
+ state = regtab[j];
}
}
- else
- {
- j = -1;
- }
- // Make j = -1 if user tries to use a RISC register while in 68K mode
- if (!(rgpu || rdsp || dsp56001) && ((TOKEN)j >= KW_R0 && (TOKEN)j <= KW_R31))
+ // Scan for keywords
+ if ((j <= 0 || state <= 0) || p==p2)
{
- j = -1;
+ if (j <= KWSIZE)
+ {
+ for (state = 0; state >= 0;)
+ {
+ j = (int)tolowertab[*p2++];
+ j += kwbase[state];
+
+ if (kwcheck[j] != state)
+ {
+ j = -1;
+ break;
+ }
+
+ if (*p == EOS || p2 == ln)
+ {
+ j = kwaccept[j];
+ break;
+ }
+
+ state = kwtab[j];
+ }
+ }
+ else
+ {
+ j = -1;
+ }
}
- // Make j = -1 if time, date etc with no preceeding ^^
- // defined, referenced, streq, macdef, date and time
- switch ((TOKEN)j)
+ skip_keyword:
+
+ // If we detected equrundef/regundef set relevant flag
+ if (j == KW_EQURUNDEF)
{
- case 112: // defined
- case 113: // referenced
- case 118: // streq
- case 119: // macdef
- case 120: // time
- case 121: // date
+ equrundef = 1;
j = -1;
}
// If not tokenized keyword OR token was not found
if ((j < 0) || (state < 0))
{
- // Last attempt: let's see if this is an equated register
- char temp = *ln;
- *ln = 0;
- sy = lookup(nullspot, LABEL, 0);
- *ln = temp;
- if (sy)
+ // Only proceed if no equrundef has been detected. In that case we need to store the symbol
+ // because the directive handler (d_equrundef) will run outside this loop, further into procln.c
+ if (!equrundef && !disabled)
{
- if (sy->sattre & EQUATEDREG)
+ // Last attempt: let's see if this is an equated register.
+ // If yes, then just store the register's keyword value instead of the symbol
+ char temp = *ln;
+ *ln = 0;
+ sy = lookup(nullspot, LABEL, 0);
+ *ln = temp;
+ if (sy)
{
- uint32_t register_token = sy->svalue;
- if (rgpu || rdsp)
+ if (sy->sattre & EQUATEDREG)
{
- // If we are in GPU or DSP mode then mark the register bank.
- // We will use it during EvaluateRegisterFromTokenStream()
- // when we check if we can use the equated register with the currently
- // selected bank.
- // Note (ggn): I find all this superfluous. Do we really want to be so
- // protective? Plus, the current implementation happily skips
- // these checks on .equr that are set during fixups - oops!
- register_token |= 0x80000000; // Mark that this is an .equr
- if (sy->sattre & BANK_1)
- {
- register_token |= 0x40000000; // Mark bank 1
- }
+ *tk.u32++ = sy->svalue;
+ stuffnull = 0;
+ continue;
}
- *tk.u32++ = register_token;
- stuffnull = 0;
- continue;
}
}
// Ok, that failed, let's store the symbol instead
if (stuffnull) // Arrange for string termination on next pass
nullspot = ln;
+ if (disabled)
+ {
+ // When we are in a disabled code block, the only thing that can break out
+ // of this is an ".endif" keyword, so this is the minimum we have to parse
+ // in order to discover such a keyword.
+ goto goteol;
+ }
+
continue;
}
for(state=0; state>=0;)
{
// Get char, convert to lowercase
- j = *p++;
+ j = (int)tolowertab[*p++];
- if (j >= 'A' && j <= 'Z')
- j += 0x20;
+ //if (j >= 'A' && j <= 'Z')
+ // j += 0x20;
- j += kwbase[state];
+ j += unarybase[state];
- if (kwcheck[j] != state)
+ if (unarycheck[j] != state)
{
j = -1;
break;
if (*p == EOS || p == ln)
{
- j = kwaccept[j];
+ j = unaryaccept[j];
break;
}
- state = kwtab[j];
+ state = unarytab[j];
}
if (j < 0 || state < 0)