Tentative fix for bug #55. Thanks to ggn for reporting!
[rmac] / parmode.h
index 543701ace549f4bb9e9ee4c879888a1f6cab2c70..38f6f94b6c787f5143c40bb98cdc0e7f806c8a0f 100644 (file)
--- a/parmode.h
+++ b/parmode.h
 
                AMn = IMMED;
        }
 
                AMn = IMMED;
        }
+
+       // Small problem with this is that the opening parentheses might be an
+       // expression that's part of a displacement; this code will falsely flag
+       // that as an error.
+
        // (An)
        // (An)+
        // (An,Xn[.siz][*scale])
        // (An)
        // (An)+
        // (An,Xn[.siz][*scale])
                        if (expr(AnEXPR, &AnEXVAL, &AnEXATTR, &AnESYM) != OK)
                                return ERROR;
 
                        if (expr(AnEXPR, &AnEXVAL, &AnEXATTR, &AnESYM) != OK)
                                return ERROR;
 
+                       // It could be that this is really just an expression prefixing a
+                       // register as a displacement...
+                       if (*tok == ')')
+                       {
+                               tok++;
+                               goto CHK_FOR_DISPn;
+                       }
+
+                       // Otherwise, check for PC & etc displacements...
                        if (*tok++ != ',')
                                goto badmode;
 
                        if (*tok++ != ',')
                                goto badmode;
 
                if (expr(AnEXPR, &AnEXVAL, &AnEXATTR, &AnESYM) != OK)
                        return ERROR;
 
                if (expr(AnEXPR, &AnEXVAL, &AnEXATTR, &AnESYM) != OK)
                        return ERROR;
 
+CHK_FOR_DISPn:
                if (*tok == DOTW)
                {
                        // expr.W 
                if (*tok == DOTW)
                {
                        // expr.W 
        ;
 }
 
        ;
 }
 
-// Cleanup dirty little macros
+// Clean up dirty little macros
 #undef AnOK
 #undef AMn
 #undef AnREG
 #undef AnOK
 #undef AMn
 #undef AnREG
 #undef AnESYM
 #undef AMn_IX0
 #undef AMn_IXN
 #undef AnESYM
 #undef AMn_IX0
 #undef AMn_IXN
+#undef CHK_FOR_DISPn