Fixed assembler not complaining when using RISC regs in 68K mode.
authorShamus Hammons <jlhamm@acm.org>
Fri, 13 Sep 2013 02:59:10 +0000 (21:59 -0500)
committerShamus Hammons <jlhamm@acm.org>
Fri, 13 Sep 2013 02:59:10 +0000 (21:59 -0500)
68kgen.c
amode.c
parmode.h
procln.c
token.c
version.h

index 23da319429c9c443e8c7aac2c3e9264b03c5e32b..b2a6f81c164d4b1d3363641efe91f5ce42f6bbb9 100644 (file)
--- 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 b721491dc4d58e4ce2245295fa532370dd010918..2c89911b3c87fc643f0bf5d7f65b97fdcd10316c 100644 (file)
--- 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;
 }
+
index 4637d72dda1bca9613a2484de82f4bf68ffb9f4c..11b16bfbe81894d962029d18cf88d40a65930f77 100644 (file)
--- 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))
                {
 
                        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.
                        switch ((int)*tok)
                        {                                // Index reg size: <empty> | .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;
 
                        if (*tok == '*')
                        {                                  // scale: *1, *2, *4, *8 
-                               ++tok;
+                               tok++;
+
                                if (*tok++ != CONST || *tok > 8)
                                        goto badmode;
 
                        if ((*tok >= KW_A0) && (*tok <= KW_A7))
                        {
                                AnREG = *tok & 7;
-                               ++tok;
+                               tok++;
 
                                if (*tok == ',')
                                {
                                else if (*tok == ')')
                                {
                                        AMn = ADISP;
-                                       ++tok;
+                                       tok++;
                                        goto AnOK;
                                }
                                else
                                else if (*tok == ')')
                                {
                                        AMn = PCDISP;                                // expr(PC) 
-                                       ++tok;
+                                       tok++;
                                        goto AnOK;
                                }
                                else
        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
 
                if (*tok == DOTW)
                {                                    // expr.W 
-                       ++tok;
+                       tok++;
                        AMn = ABSW;
                        goto AnOK;
                }
 
                        if (*tok == DOTL)
                        {                                 // force .L 
-                               ++tok;
+                               tok++;
                                AMn = ABSL;
                        }
 
                        if (*tok == ')')
                        {
                                AMn = ADISP;
-                               ++tok;
+                               tok++;
                                goto AnOK;
                        }
 
                        if (*++tok == ')')
                        {
                                AMn = PCDISP;
-                               ++tok;
+                               tok++;
                                goto AnOK;
                        }
 
index 743c9b96e13b61da115d038dc8f529578849eee7..9987aad70ef4c836d81a1fb08ea4fc8f95aae579 100644 (file)
--- 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 78de051d7e7df3ae3281023a99f7eb65f96fe415..4a06efedcbebf1a0fdb72aec48857e74d6286b5a 100644 (file)
--- 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;
                                }
index 9ed41e3ce7d68b01d58b4b5f3c949d17769acce9..52172c069ff137cd6b7558cd0463134e6f857686 100644 (file)
--- 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__