]> Shamusworld >> Repos - rmac/commitdiff
Added .opt directive with similar syntax to command line. Example syntax: '.opt ...
authorggn <ggn.dbug@gmail.com>
Wed, 7 Sep 2016 11:18:24 +0000 (14:18 +0300)
committerShamus Hammons <jlhamm@acm.org>
Tue, 13 Sep 2016 03:14:46 +0000 (22:14 -0500)
Signed-off-by: Shamus Hammons <jlhamm@acm.org>
direct.c
direct.h
eagen0.c
mntab
rmac.c
rmac.h

index 70f4469602278ad708811706181f5a37146a2c3f..7010e4616980714d6fdd3242a63a047581c56330 100644 (file)
--- a/direct.c
+++ b/direct.c
@@ -88,6 +88,7 @@ int (*dirtab[])() = {
        d_nojpad,                       // 55 .nojpad (deprecated)
        d_gpumain,                      // 56 .gpumain (deprecated)
        d_prgflags,                     // 57 .prgflags
+       d_opt,                          // 58 .opt
 };
 
 
@@ -1589,3 +1590,28 @@ int d_gpumain(void)
        return error("What the hell? Do you think we adhere to the Goof standard?");
 }
 
+//
+// .opt - turn a specific (or all) optimisation on or off
+//
+int d_opt(void)
+{
+       char * tmpstr;
+
+       while (*tok != EOL)
+       {
+               if (*tok == STRING)
+               {
+                       tok++;
+                       tmpstr = string[*tok++];
+
+                       if (ParseOptimization(tmpstr) != OK)
+                       {
+                               char temperr[256];
+                               sprintf(temperr, "unknown optimisation flag '%s'.", tmpstr);
+                               return error(temperr);
+                       }
+               }
+               else
+                       return error(".opt directive needs every switch enclosed inside quotation marks.");
+       }
+}
\ No newline at end of file
index e95b6dde1de61f98316c4c18f145d2aecb837023..2c5ce3a71eabcf022a2dfc53f3cd09c624c6ff42 100644 (file)
--- a/direct.h
+++ b/direct.h
@@ -69,9 +69,7 @@ int d_fail(void);
 int symlist(int(*)());
 int abs_expr(VALUE *);
 int d_cstruct(void);
-int d_jpad(void);
-int d_nojpad(void);
-int d_gpumain(void);
 int d_prgflags(void);
+int d_opt(void);
 
 #endif // __DIRECT_H__
index 7ec6ccb0fcf28cdbca6156b8982e802bd0cc1f41..bf4ba3da6ab64fdb093df39ac9944b82d8f109d5 100644 (file)
--- a/eagen0.c
+++ b/eagen0.c
@@ -65,6 +65,10 @@ int eaNgen(WORD siz)
                                        chptr_opcode[0] |= ((0x0080 >> 8) & 255); // slap in 010 bits
                                        chptr_opcode[1] |= 0x0080 & 255;          // slap in 010 bits
                                }
+
+                               if (sbra_flag)
+                                       warn("0(An) converted to (An)");
+
                                return OK;
                        }
 
diff --git a/mntab b/mntab
index 9bbc0039105be2313cda959e6344bb4cb94602e4..56a87cf599fe199de016fb9502af6ef3d39f6bb2 100644 (file)
--- a/mntab
+++ b/mntab
@@ -98,6 +98,8 @@ nojpad        55
 gpumain        56
 .prgflags      57
 prgflags       57
+opt     58
+.opt    58
 .if    500
 if     500
 .else  501
diff --git a/rmac.c b/rmac.c
index 3d1fffa9ee285920f6838c485de9252b090712c9..45cd1d8f0532ff69347de1979fa1e6ed3da18f69 100644 (file)
--- a/rmac.c
+++ b/rmac.c
@@ -171,6 +171,42 @@ void DisplayVersion(void)
 }
 
 
+//
+// Parse optimisation options
+//
+int ParseOptimization(char * optstring)
+{
+    int onoff = 0;
+
+    if (*optstring == '+')
+        onoff = 1;
+    else if (*optstring != '~')
+        return ERROR;
+
+    if ((optstring[2] == 'a' || optstring[2] == 'A') &&
+        (optstring[3] == 'l' || optstring[3] == 'L') &&
+        (optstring[4] == 'l' || optstring[4] == 'L'))
+    {
+        memset(optim_flags, onoff, OPT_COUNT * sizeof(int));
+        return OK;
+    }
+    else if (optstring[1] == 'o' || optstring[1] == 'O') //Turn on specific optimisation
+       {
+        int opt_no = atoi(&optstring[2]);
+        if ((opt_no >= 0) && (opt_no < OPT_COUNT))
+            optim_flags[opt_no] = onoff;
+        else
+        {
+            return ERROR;
+        }
+    }
+    else
+    {
+        return ERROR;
+    }
+}
+
+
 // 
 // Process command line arguments and do an assembly
 //
@@ -409,31 +445,7 @@ int Process(int argc, char ** argv)
                }
                else if (*argv[argno] == '+' || *argv[argno] == '~')
                {
-                       int onoff = 0;
-
-                       if (*argv[argno] == '+')
-                               onoff = 1;
-
-                       if ((argv[argno][2] == 'a' || argv[argno][2] == 'A')
-                               && (argv[argno][3] == 'l' || argv[argno][3] == 'L')
-                               && (argv[argno][4] == 'l' || argv[argno][4] == 'L'))
-                               memset(optim_flags, onoff, OPT_COUNT * sizeof(int));
-                       else if (argv[argno][1] == 'o' || argv[argno][1] == 'O') // Turn on specific optimisation
-                       {
-                               int opt_no = atoi(&argv[argno][2]);
-
-                               if ((opt_no >= 0) && (opt_no < OPT_COUNT))
-                                       optim_flags[opt_no] = onoff;
-                               else
-                               {
-                                   DisplayVersion();
-                                       printf("Unknown switch: %s\n\n", argv[argno]);
-                                       DisplayHelp();
-                                       errcnt++;
-                                       break;
-                               }
-                       }
-                       else
+                       if (ParseOptimization(argv[argno]) != OK)
                        {
                                DisplayVersion();
                                printf("Unknown switch: %s\n\n", argv[argno]);
diff --git a/rmac.h b/rmac.h
index 39b8ae67a5dcca8d240f3b81816e475e6b7f8a6d..1fa419bc172d153c7f7f0d7ea92e301619827873 100644 (file)
--- a/rmac.h
+++ b/rmac.h
@@ -216,6 +216,7 @@ extern int optim_flags[OPT_COUNT];
 // Exported functions
 char * fext(char *, char *, int);
 int nthpath(char *, int, char *);
+int ParseOptimization(char * optstring);
 
 #endif // __RMAC_H__