]> Shamusworld >> Repos - rmac/commitdiff
.equr overhaul part 5: enabled .equr for all registers for all architectures
authorggn <ggn@atari.org>
Mon, 7 Mar 2022 18:36:37 +0000 (20:36 +0200)
committerShamus Hammons <jlhamm@acm.org>
Mon, 30 May 2022 19:17:59 +0000 (14:17 -0500)
docs/rmac.rst
kw.tab
procln.c
sect.c
token.h

index d46f9c5712603f9b73a36a059022415817b25219..aba11a1ef867b4f2774088cdfcb764537ce03131 100644 (file)
@@ -1261,11 +1261,11 @@ Directives relating to the 6502 are described in the chapter on `6502 Support`_.
 
 **.equr** *expression*
 
-   Allows you to name a register. This is only implemented for GPU/DSP
-   code sections. For example:
+   Allows you to name a register. For example:
 
     ::
 
+     .gpu
      Clipw .equr r19
      . . .
           add ClipW,r0 ; ClipW actually is r19
diff --git a/kw.tab b/kw.tab
index 12b7106121cf2baf1b9829c45fb6a5d40bb1c720..eb1e8bc729a32d70d26cff4f7e6162d9233cb35c 100644 (file)
--- a/kw.tab
+++ b/kw.tab
@@ -73,14 +73,14 @@ fp7     231
 equ    61
 .reg    82
 reg     82
-.equr  148
-equr   148
+.equr  85
+equr   85
+.regequ  85
+regequ   85
 .equrundef  50
 equrundef   50
 .regundef   50
 regundef 50
-.regequ  148
-regequ   148
 set    149
 
 r0     151
index 85721e878bf1b1258c6640d55d4044ed4167a5ca..ef7bf1cc7be760b2bc52468670a2cd4056a3098b 100644 (file)
--- a/procln.c
+++ b/procln.c
@@ -154,7 +154,7 @@ void Assemble(void)
        char * opname = NULL;           // Name of dirctve/mnemonic/macro
        int listflag;                           // 0: Don't call listeol()
        WORD rmask;                                     // Register list, for REG
-       int riscreg;                            // RISC register
+       int equreg;                             // RISC register
        listflag = 0;                           // Initialise listing flag
 
 loop:                                                  // Line processing loop label
@@ -434,57 +434,48 @@ corresponding register bool to true. Whenever it's undef'ed, set it to false.
 When checking to see if it's already been equated, issue a warning.
 */
 
-                       if (rgpu || rdsp)
+                       // Check for register to equate to
+                       // This check will change once we split the registers per architecture into their own tables
+                       // and out of kw.tab. But for now it'll do...
+                       if ((*tok >= KW_D0) && (*tok <= KW_BA))
                        {
-                               // GPU/DSP architectures need some special TLC for now
-                               // Check for register to equate to
-                               if ((*tok >= KW_R0) && (*tok <= KW_R31))
+                               sy->sattre = EQUATEDREG;        // Mark as equated register
+                               equreg = *tok;
+                               // Check for ",<bank #>" override notation and skip past it.
+                               // It is ignored now. Was that ever useful anyway?
+                               if ((rgpu ||rdsp) && (tok[1] == ',') && (tok[2] == CONST))
                                {
-                                       sy->sattre = EQUATEDREG;        // Mark as equated register
-                                       riscreg = *tok;
-                                       // Check for ",<bank #>" override notation and skip past it.
-                                       // It is ignored now. Was that ever useful anyway?
-                                       if ((tok[1] == ',') && (tok[2] == CONST))
-                                       {
-                                               // Advance token pointer and skip everything
-                                               tok += 4;
-                                       }
-
-                                       eattr = ABS | DEFINED | GLOBAL;
-                                       eval = riscreg;
-                                       tok++;
+                                       // Advance token pointer and skip everything
+                                       tok += 4;
                                }
-                               // Checking for a register symbol
-                               else if (tok[0] == SYMBOL)
-                               {
-                                       sy2 = lookup(string[tok[1]], LABEL, j);
 
-                                       // Make sure symbol is a valid equreg
-                                       if (!sy2 || !(sy2->sattre & EQUATEDREG))
-                                       {
-                                               error("invalid GPU/DSP .equr/.regequ definition");
-                                               goto loop;
-                                       }
-                                       else
-                                       {
-                                               eattr = ABS | DEFINED | GLOBAL; // Copy symbol's attributes
-                                               sy->sattre = sy2->sattre;
-                                               eval = (sy2->svalue & 0xFFFFF0FF);
-                                               tok += 2;
-                                       }
+                               eattr = ABS | DEFINED | GLOBAL;
+                               eval = equreg;
+                               tok++;
+                       }
+                       // Checking for a register symbol
+                       else if (tok[0] == SYMBOL)
+                       {
+                               sy2 = lookup(string[tok[1]], LABEL, j);
+
+                               // Make sure symbol is a valid equreg
+                               if (!sy2 || !(sy2->sattre & EQUATEDREG))
+                               {
+                                       error("invalid .equr/.regequ definition");
+                                       goto loop;
                                }
                                else
                                {
-                                       error("invalid GPU/DSP .equr/.regequ definition");
-                                       goto loop;
+                                       eattr = ABS | DEFINED | GLOBAL; // Copy symbol's attributes
+                                       sy->sattre = sy2->sattre;
+                                       eval = (sy2->svalue & 0xFFFFF0FF);
+                                       tok += 2;
                                }
                        }
                        else
                        {
-                               sy->sattre = EQUATEDREG;        // Mark as equated register
-                               eattr = ABS | DEFINED | GLOBAL;
-                               eval = *tok;
-                               tok++;
+                               error("invalid .equr/.regequ definition");
+                               goto loop;
                        }
                }
                else if (equtyp == REG)
diff --git a/sect.c b/sect.c
index ebf80cfec02bf585886a89329dbe801022c533b9..3cedbb24221c2f7279b40612cce48faef1f9e3d4 100644 (file)
--- a/sect.c
+++ b/sect.c
@@ -20,6 +20,7 @@
 #include "token.h"
 #define DEF_KW
 #include "kwtab.h"
+#undef DEF_KW
 
 // Function prototypes
 void MakeSection(int, uint16_t);
diff --git a/token.h b/token.h
index 16cd8cb45c561561154c8fc5cfc34e69f2dfefd8..31541189a1d3a8b7c8fa3c4fb6fa2b0f08ce1279 100644 (file)
--- a/token.h
+++ b/token.h
@@ -45,7 +45,7 @@
 #define DEQUALS         'g'                    // ==
 #define SET             0x95           // Set
 #define REG             'R'                    // Reg
-#define EQUREG          0x94           // equreg
+#define EQUREG          'U'                    // equreg (must be synchronised with the equate in kw.tab)
 #define CCDEF           0xB7           // ccdef
 #define DCOLON          'h'                    // ::
 #define GE              'i'                    // >=