]> Shamusworld >> Repos - rmac/commitdiff
.equr overhaul part 4: handle equrundef (and the other permutations of the directive)
authorggn <ggn@atari.org>
Mon, 7 Mar 2022 16:50:33 +0000 (18:50 +0200)
committerShamus Hammons <jlhamm@acm.org>
Mon, 30 May 2022 19:17:59 +0000 (14:17 -0500)
kw.tab
rmac.h
token.c
token.h

diff --git a/kw.tab b/kw.tab
index 5b4ab1144a2e5018687e4b5c1623565985f51881..12b7106121cf2baf1b9829c45fb6a5d40bb1c720 100644 (file)
--- a/kw.tab
+++ b/kw.tab
@@ -75,6 +75,10 @@ equ  61
 reg     82
 .equr  148
 equr   148
+.equrundef  50
+equrundef   50
+.regundef   50
+regundef 50
 .regequ  148
 regequ   148
 set    149
diff --git a/rmac.h b/rmac.h
index dddaca1011af8b54aeba0063589e9de4adb79619..a23acafd77a251bf76c4254c3c01af917c995448 100644 (file)
--- a/rmac.h
+++ b/rmac.h
@@ -39,7 +39,6 @@
        #define STRINGIZE(x) STRINGIZE_HELPER(x)
        #define WARNING(desc) __pragma(message(__FILE__ "(" STRINGIZE(__LINE__) ") : Warning: " #desc))
        #define inline __inline
-
        // usage:
        // WARNING(FIXME: Code removed because...)
 
 #include <dirent.h>
 #include "symbol.h"
 
+#if defined(WIN32) || defined(WIN64)
+// Ever since Visual Studio... 2017? 2019? the following constants come defined in the
+// platform SDK, which leads to endless warnings from the compiler. So let's just
+// put the pacifier on and undef them, sheesh! (No, we won't rename the defines,
+// we've been here since 1986, Visual Studio wasn't even a glimpse in the milkman's eyes,
+// if you catch my drift)
+#undef CONST
+#undef ERROR
+#undef TEXT
+#endif
+
 #define BYTE         uint8_t
 #define WORD         uint16_t
 #define LONG         uint32_t
diff --git a/token.c b/token.c
index 162e7390bcf2576998815c66c84db75d303c4986..2d3742fedc6d2643ef3d50f6ecfe118120777aed 100644 (file)
--- a/token.c
+++ b/token.c
@@ -975,6 +975,7 @@ int TokenizeLine(void)
        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:
 
@@ -1200,38 +1201,51 @@ DEBUG { printf("TokenizeLine: Calling fpop() from SRC_IFILE...\n"); }
                        case 121:   // date
                                j = -1;
                        }
+                       
+                       // If we detected equrundef/regundef set relevant flag
+                       if (j == KW_EQURUNDEF)
+                       {
+                               equrundef = 1;
+                               j = -1;
+                               //printf("line %d, equrundef found\n", curlineno);
+                       }
 
                        // 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)
                                {
-                                       if (sy->sattre & EQUATEDREG)
+                                       // 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)
                                        {
-                                               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)
+                                                       uint32_t register_token = sy->svalue;
+                                                       if (rgpu || rdsp)
                                                        {
-                                                               register_token |= 0x40000000;   // Mark bank 1
+                                                               // 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++ = register_token;
+                                                       stuffnull = 0;
+                                                       continue;
                                                }
-                                               *tk.u32++ = register_token;
-                                               stuffnull = 0;
-                                               continue;
                                        }
                                }
                                // Ok, that failed, let's store the symbol instead
diff --git a/token.h b/token.h
index 310a9c258be013e885ac83cdeb971ec3c0a458d2..16cd8cb45c561561154c8fc5cfc34e69f2dfefd8 100644 (file)
--- a/token.h
+++ b/token.h
@@ -30,7 +30,7 @@
 #define TOKBUFSIZE      4096           // Size of token-line buffer
 #define QUANTUM         4096L          // # bytes to eat at a time from a file
 #define LNBUFSIZ        (QUANTUM*2)    // Size of file's buffer
-#define KWSIZE                               // Maximum size of keyword in kwtab.h
+#define KWSIZE          10                     // Maximum size of keyword in kwtab.h
 
 // (Normally) non-printable tokens
 #define COLON           ':'                    // : (grumble: GNUmacs hates ':')