From 6c1bc379012b1c1ca369e71e39509f3538042382 Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Thu, 12 Sep 2013 21:59:10 -0500 Subject: [PATCH] Fixed assembler not complaining when using RISC regs in 68K mode. --- 68kgen.c | 22 +++++++++++++--------- amode.c | 13 +++++++------ parmode.h | 38 ++++++++++++++++++++------------------ procln.c | 9 +++++---- token.c | 19 ++++++++++++------- version.h | 2 +- 6 files changed, 58 insertions(+), 45 deletions(-) diff --git a/68kgen.c b/68kgen.c index 23da319..b2a6f81 100644 --- a/68kgen.c +++ b/68kgen.c @@ -34,7 +34,7 @@ int main(int argc, char ** argv) while (fgets(ln, 256, stdin) != NULL) { - ++lineno; /* bump line# */ + lineno++; /* bump line# */ if (*ln == '#') /* ignore comments */ continue; @@ -55,7 +55,7 @@ int main(int argc, char ** argv) namv[namcnt++] = s; while (*s && !isspace(*s)) - ++s; + s++; if (isspace(*s)) *s++ = EOS; @@ -70,15 +70,16 @@ int main(int argc, char ** argv) } -/* - * Parse line - */ +// +// Parse line +// void procln(int namc, char ** namv) { int i, j; char * s; - if (namc == 1) /* alias for previous entry */ + // alias for previous entry + if (namc == 1) { fprintf(kfp, "%s\t%d\n", namv[0], kwnum-1+1000); return; @@ -90,7 +91,8 @@ void procln(int namc, char ** namv) exit(1); } - if (*namv[0] != '-') /* output keyword name */ + // output keyword name + if (*namv[0] != '-') fprintf(kfp, "%s\t%d\n", namv[0], kwnum + 1000); printf("/*%4d %-6s*/ {", kwnum, namv[0]); @@ -102,7 +104,8 @@ void procln(int namc, char ** namv) printf(", %s, %s, ", namv[2], namv[3]); - if (*namv[4] == '%') /* enforce little fascist percent signs */ + // enforce little fascist percent signs + if (*namv[4] == '%') { for(i=1, j=0; i<17; ++i) { @@ -124,7 +127,7 @@ void procln(int namc, char ** namv) printf("%s},\n", namv[5]); - ++kwnum; + kwnum++; } @@ -134,3 +137,4 @@ void error(char * s, char * s1) fprintf(stderr, "\n"); exit(1); } + diff --git a/amode.c b/amode.c index b721491..2c89911 100644 --- a/amode.c +++ b/amode.c @@ -84,7 +84,8 @@ int amode(int acount) if (acount == 0 || *tok != ',') return 1; - ++tok; // Eat comma + // Eat the comma + tok++; // Parse second addressing mode #define AnOK a1ok @@ -126,10 +127,9 @@ int reglist(WORD * a_rmask) 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0x8000 }; - WORD rmask; - int r, cnt; - rmask = 0; + WORD rmask = 0; + int r, cnt; for(;;) { @@ -140,7 +140,7 @@ int reglist(WORD * a_rmask) if (*tok == '-') { - ++tok; + tok++; if (*tok >= KW_D0 && *tok <= KW_A7) cnt = *tok++ & 15; @@ -161,10 +161,11 @@ int reglist(WORD * a_rmask) if (*tok != '/') break; - ++tok; + tok++; } *a_rmask = rmask; return OK; } + diff --git a/parmode.h b/parmode.h index 4637d72..11b16bf 100644 --- a/parmode.h +++ b/parmode.h @@ -24,7 +24,8 @@ } else if (*tok == '#') { - ++tok; + tok++; + if (expr(AnEXPR, &AnEXVAL, &AnEXATTR, &AnESYM) != OK) return ERROR; @@ -44,7 +45,7 @@ // ([bd,PC,Xn],od) else if (*tok == '(') { - ++tok; + tok++; if ((*tok >= KW_A0) && (*tok <= KW_A7)) { @@ -52,11 +53,11 @@ if (*tok == ')') { - ++tok; + tok++; if (*tok == '+') { - ++tok; + tok++; AMn = APOSTINC; } else @@ -70,7 +71,7 @@ } else if (*tok == KW_PC) { // (PC,Xn[.siz][*scale]) - ++tok; + tok++; AMn = PCINDEXED; // Common index handler; enter here with `tok' pointing at the comma. @@ -93,13 +94,13 @@ switch ((int)*tok) { // Index reg size: | .W | .L case DOTW: - ++tok; + tok++; default: AnIXSIZ = 0; break; case DOTL: AnIXSIZ = 0x0800; - ++tok; + tok++; break; case DOTB: // .B not allowed here... goto badmode; @@ -107,7 +108,8 @@ if (*tok == '*') { // scale: *1, *2, *4, *8 - ++tok; + tok++; + if (*tok++ != CONST || *tok > 8) goto badmode; @@ -149,7 +151,7 @@ if ((*tok >= KW_A0) && (*tok <= KW_A7)) { AnREG = *tok & 7; - ++tok; + tok++; if (*tok == ',') { @@ -159,7 +161,7 @@ else if (*tok == ')') { AMn = ADISP; - ++tok; + tok++; goto AnOK; } else @@ -175,7 +177,7 @@ else if (*tok == ')') { AMn = PCDISP; // expr(PC) - ++tok; + tok++; goto AnOK; } else @@ -194,19 +196,19 @@ else if (*tok == KW_CCR) { AMn = AM_CCR; - ++tok; + tok++; goto AnOK; } else if (*tok == KW_SR) { AMn = AM_SR; - ++tok; + tok++; goto AnOK; } else if (*tok == KW_USP) { AMn = AM_USP; - ++tok; + tok++; goto AnOK; } // expr @@ -223,7 +225,7 @@ if (*tok == DOTW) { // expr.W - ++tok; + tok++; AMn = ABSW; goto AnOK; } @@ -237,7 +239,7 @@ if (*tok == DOTL) { // force .L - ++tok; + tok++; AMn = ABSL; } @@ -253,7 +255,7 @@ if (*tok == ')') { AMn = ADISP; - ++tok; + tok++; goto AnOK; } @@ -265,7 +267,7 @@ if (*++tok == ')') { AMn = PCDISP; - ++tok; + tok++; goto AnOK; } diff --git a/procln.c b/procln.c index 743c9b9..9987aad 100644 --- a/procln.c +++ b/procln.c @@ -208,7 +208,8 @@ as68label: } } - if (*tok == EOL) // EOL is legal here... + // EOL is legal here... + if (*tok == EOL) goto normal; // Next token MUST be a symbol @@ -259,11 +260,11 @@ as68label: siz = SIZN; if (*tok == DOTW) - siz = SIZW, ++tok; + siz = SIZW, tok++; else if (*tok == DOTL) - siz = SIZL, ++tok; + siz = SIZL, tok++; else if (*tok == DOTB) - siz = SIZB, ++tok; + siz = SIZB, tok++; // Do special directives (500..999) (These must be handled in "real time") if (state >= 500 && state < 1000) diff --git a/token.c b/token.c index 78de051..4a06efe 100644 --- a/token.c +++ b/token.c @@ -1054,6 +1054,12 @@ if (verb_flag) printf("TokenizeLine: Calling fpop() from SRC_IREPT...\n"); j = -1; } + // Make j = -1 if user tries to use a RISC register while in 68K mode + if (!(rgpu || rdsp) && ((TOKEN)j >= KW_R0 && (TOKEN)j <= KW_R31)) + { + j = -1; + } + //make j = -1 if time, date etc with no preceeding ^^ //defined, referenced, streq, macdef, date and time switch ((TOKEN)j) @@ -1065,9 +1071,10 @@ if (verb_flag) printf("TokenizeLine: Calling fpop() from SRC_IREPT...\n"); case 120: // time case 121: // date j = -1; - break; +// break; } + // If not tokenized keyword OR token was not found if (j < 0 || state < 0) { *tk++ = SYMBOL; @@ -1410,22 +1417,20 @@ if (verb_flag) printf("TokenizeLine: Calling fpop() from SRC_IREPT...\n"); while ((int)chrtab[*ln] & DIGIT) v = (v * 10) + *ln++ - '0'; - // See if there's a .[bwl] after the constant, & deal with it + // See if there's a .[bwl] after the constant & deal with it if so if (*ln == '.') { - if ((*(ln+1) == 'b') || (*(ln+1) == 'B')) + if ((*(ln + 1) == 'b') || (*(ln + 1) == 'B')) { v &= 0x000000FF; ln += 2; } - - if ((*(ln+1) == 'w') || (*(ln+1) == 'W')) + else if ((*(ln + 1) == 'w') || (*(ln + 1) == 'W')) { v &= 0x0000FFFF; ln += 2; } - - if ((*(ln+1) == 'l') || (*(ln+1) == 'L')) + else if ((*(ln + 1) == 'l') || (*(ln + 1) == 'L')) { ln += 2; } diff --git a/version.h b/version.h index 9ed41e3..52172c0 100644 --- a/version.h +++ b/version.h @@ -13,6 +13,6 @@ #define MAJOR 1 // Major version number #define MINOR 2 // Minor version number -#define PATCH 6 // Patch release number +#define PATCH 7 // Patch release number #endif // __VERSION_H__ -- 2.37.2