#define DEF_MR // Declare keyword values
#include "risckw.h" // Incl. generated risc keywords
-#define DEF_KW // Declare keyword values
-#include "kwtab.h" // Incl. generated keyword tables & defs
+#define DEF_REGRISC
+#include "riscregs.h" // Incl. generated keyword tables & defs
#define MAXINTERNCC 26 // Maximum internal condition codes
{ MR_NORMI, RI_TWO, 56 },
{ MR_NOP, RI_NONE, 57 },
{ MR_SAT24, RI_ONE, 62 },
- { MR_UNPACK, RI_ONE, 63 + GPUONLY | (0 << 6) },
- { MR_PACK, RI_ONE, 63 + GPUONLY | (1 << 6) },
+ { MR_UNPACK, RI_ONE, 63 + GPUONLY | (1 << 6) },
+ { MR_PACK, RI_ONE, 63 + GPUONLY | (0 << 6) },
{ MR_ADDQMOD, RI_NUM_32, 63 + DSPONLY },
{ MR_MOVE, RI_MOVE, 0 },
{ MR_LOAD, RI_LOAD, 0 },
//
static inline int IllegalIndexedRegister(int reg)
{
- return error("Attempted index reference with non-indexable register (r%d)", reg - KW_R0);
+ return error("Attempted index reference with non-indexable register (r%d)", reg - REGRISC_R0);
}
//
}
int value = ((opcode & 0x3F) << 10) + ((reg1 & 0x1F) << 5) + (reg2 & 0x1F);
+ GENLINENOSYM();
D_word(value);
}
// Firstly, check to see if it's a register token and return that. No
// need to invoke expr() for easy cases like this.
int reg = *tok & 255;
- if (reg >= KW_R0 && reg <= KW_R31)
+ if (reg >= REGRISC_R0 && reg <= REGRISC_R31)
{
- // Check register bank usage in the case of .equr register
- // (encoded as bits 30 and 31 in *tok).
- // (I still think that this is superfluous and should be taken out, see my note in token.c)
- if (*tok & 0x80000000)
- {
- // Oops, with all the evaluation in token.c we now lost the equated symbol reference, so we
- // don't know its name or anything else. Oh well...
- if ((regbank == BANK_0) && (*tok & 0x40000000) && !altbankok)
- return error("equated symbol cannot be used in register bank 0");
-
- if ((regbank == BANK_1) && !(*tok & 0x40000000) && !altbankok)
- return error("equated symbol cannot be used in register bank 1");
- }
- reg -= KW_R0;
+ reg -= REGRISC_R0;
tok++;
return reg;
}
// We shouldn't get here, that should not be legal
interror(9);
-
- // If we got a register in range (0-31), return it
- //if (eattr & RISCREG)
- // return (int)eval - KW_R0;
-
- //// Otherwise, it's out of range & we flag an error
- //return error(reg_err);
+ return 0; // Not that this will ever execute, but let's be nice and pacify gcc warnings
}
//
// PC,Rd or Rs,Rd
case RI_MOVE:
- if (*tok == KW_PC)
+ if (*tok == REGRISC_PC)
{
parm = 51;
reg1 = 0;
if ((tok[1] == '+') || (tok[1] == '-'))
{
// Trying to make indexed call
- // Note: no bank check for .equr symbol here, but the original code for .equr
- // below also didn't check for banks. Even more reasons to throw away
- // bank checks.
- if (((*tok & 0xff) == KW_R14) || ((*tok &0xff) == KW_R15))
- indexed = ((*tok & 0xff) - KW_R0);
+ if ((*tok == REGRISC_R14) || (*tok == REGRISC_R15))
+ indexed = (*tok - REGRISC_R0);
else
return IllegalIndexedRegister(*tok);
}
- //if (*tok == SYMBOL)
- //{
- // sy = lookup(string[tok[1]], LABEL, 0);
- //
- // if (!sy)
- // {
- // error(reg_err);
- // return ERROR;
- // }
- //
- // if (sy->sattre & EQUATEDREG)
- // {
- // if ((tok[2] == '+') || (tok[2] == '-'))
- // {
- // if ((sy->svalue - KW_R0) == 14 || (sy->svalue - KW_R0) == 15) {
- // indexed = (sy->svalue - KW_R0);
- // tok++;
- // }
- // else
- // return IllegalIndexedRegisterEqur(sy);
- // }
- // }
- //}
-
if (!indexed)
{
EVAL_REG_RETURN_IF_ERROR(reg1, FU_REGONE);
parm = (WORD)(reg1 - 14 + 58);
tok++;
- if (((*tok & 0xff) >= KW_R0) && ((*tok & 0xff) <= KW_R31))
+ if ((*tok >= REGRISC_R0) && (*tok <= REGRISC_R31))
indexed = 1;
if (*tok == SYMBOL)
tok++;
indexed = 0;
- // Again, no bank checks here or in the original code.
- // This check has more holes than a very hole-y thing.
- if ((((*tok & 0xff) == KW_R14) || ((*tok & 0xff) == KW_R15)) && (tok[1] != ')'))
- indexed = (*tok & 0xff) - KW_R0;
-
- //if (*tok == SYMBOL)
- //{
- // sy = lookup(string[tok[1]], LABEL, 0);
- //
- // if (!sy)
- // {
- // error(reg_err);
- // return ERROR;
- // }
- //
- // if (sy->sattre & EQUATEDREG)
- // {
- // if (((sy->svalue - KW_R0) == 14 || (sy->svalue - KW_R0) == 15)
- // && (tok[2] != ')'))
- // {
- // indexed = (sy->svalue - KW_R0);
- // tok++;
- // }
- // }
- //}
+ if (((*tok == REGRISC_R14) || (*tok == REGRISC_R15)) && (tok[1] != ')'))
+ indexed = *tok - REGRISC_R0;
if (!indexed)
{
parm = (WORD)(reg2 - 14 + 60);
tok++;
- if (((*tok & 0xff) >= KW_R0) && ((*tok & 0xff) <= KW_R31))
+ if ((*tok >= REGRISC_R0) && (*tok <= REGRISC_R31))
indexed = 1;
if (*tok == SYMBOL)