]> git.sur5r.net Git - cc65/commitdiff
Added new address size override commands z:, a: and f:.
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Tue, 17 Jun 2003 20:22:14 +0000 (20:22 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Tue, 17 Jun 2003 20:22:14 +0000 (20:22 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@2222 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/ca65/ea.c
src/ca65/scanner.c
src/ca65/scanner.h

index 00303a47f3f6c078d21a9fcce689773c3ec8dc7d..a0998b5a249263f6bac13c52bf7f89eb9d2dfa3f 100644 (file)
@@ -40,7 +40,7 @@
 #include "nexttok.h"
 #include "ea.h"
 
-               
+
 
 /*****************************************************************************/
 /*                                          Code                                    */
 void GetEA (EffAddr* A)
 /* Parse an effective address, return the result in A */
 {
+    unsigned long Restrictions;
+
     /* Clear the output struct */
     A->AddrModeSet = 0;
     A->Bank = 0;
     A->Expr = 0;
 
+    /* Handle an addressing size override */
+    switch (Tok) {
+        case TOK_OVERRIDE_ZP:
+            Restrictions = AM_DIR | AM_DIR_X | AM_DIR_Y;
+            NextTok ();
+            break;
+
+        case TOK_OVERRIDE_ABS:
+            Restrictions = AM_ABS | AM_ABS_X | AM_ABS_Y;
+            NextTok ();
+            break;
+
+        case TOK_OVERRIDE_FAR:
+            Restrictions = AM_ABS_LONG | AM_ABS_LONG_X;
+            NextTok ();
+            break;
+
+        default:
+            Restrictions = ~0UL;        /* None */
+            break;
+    }
 
+    /* Parse the effective address */
     if (TokIsSep (Tok)) {
 
        A->AddrModeSet = AM_IMPLICIT;
@@ -167,7 +191,7 @@ void GetEA (EffAddr* A)
                switch (Tok) {
 
                    case TOK_X:
-                               A->AddrModeSet = AM_ABS_X | AM_DIR_X;
+                               A->AddrModeSet = AM_ABS_LONG_X | AM_ABS_X | AM_DIR_X;
                        NextTok ();
                        break;
 
@@ -188,11 +212,14 @@ void GetEA (EffAddr* A)
 
            } else {
 
-               A->AddrModeSet = AM_ABS | AM_DIR;
+               A->AddrModeSet = AM_ABS_LONG | AM_ABS | AM_DIR;
 
            }
        }
     }
+
+    /* Apply addressing mode overrides */
+    A->AddrModeSet &= Restrictions;
 }
 
 
index 39f04174d74c3b806910c6c96ae1029cf7db4127..cec7284a5c5240920dd785c7114ae5a944d57f72 100644 (file)
@@ -767,13 +767,31 @@ Again:
        ReadIdent (0);
 
                /* Check for special names */
-        if (SVal [1] == '\0') {
+        if (SVal[1] == '\0') {
            switch (toupper (SVal [0])) {
 
                case 'A':
-                   Tok = TOK_A;
+                    if (C == ':') {
+                        NextChar ();
+                        Tok = TOK_OVERRIDE_ABS;
+                    } else {
+                       Tok = TOK_A;
+                    }
                    return;
 
+                case 'F':
+                    if (C == ':') {
+                        NextChar ();
+                        Tok = TOK_OVERRIDE_FAR;
+                    } else {
+                        Tok = TOK_IDENT;
+                    }
+                    return;
+
+               case 'S':
+                   Tok = TOK_S;
+                   return;
+
                case 'X':
                    Tok = TOK_X;
                    return;
@@ -782,9 +800,14 @@ Again:
                    Tok = TOK_Y;
                    return;
 
-               case 'S':
-                   Tok = TOK_S;
-                   return;
+                case 'Z':
+                    if (C == ':') {
+                        NextChar ();
+                        Tok = TOK_OVERRIDE_ZP;
+                    } else {
+                        Tok = TOK_IDENT;
+                    }
+                    return;
 
                default:
                    Tok = TOK_IDENT;
index 46549b91ec7b28df8942a6319caa3ca64187a171..0bf4617b4fe1611cbef377f40e93e9bea8c3cb35 100644 (file)
@@ -105,6 +105,10 @@ enum Token {
     TOK_LBRACK,                /* [ */
     TOK_RBRACK,                /* ] */
 
+    TOK_OVERRIDE_ZP,    /* z: */
+    TOK_OVERRIDE_ABS,   /* a: */
+    TOK_OVERRIDE_FAR,   /* f: */
+
     TOK_MACPARAM,      /* Macro parameter, not generated by scanner */
     TOK_REPCOUNTER,    /* Repeat counter, not generated by scanner */