From 52cea8604f22cf5281dbc66fcae5fea37d038e0f Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Tue, 10 Nov 2015 21:44:44 -0600 Subject: [PATCH 1/1] Tentative fix for bug #55. Thanks to ggn for reporting! --- amode.c | 2 ++ parmode.h | 18 +++++++++++++++++- version.h | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/amode.c b/amode.c index 875c324..b09b2da 100644 --- a/amode.c +++ b/amode.c @@ -75,6 +75,7 @@ int amode(int acount) #define AnESYM a0esym #define AMn_IX0 am0_ix0 #define AMn_IXN am0_ixn + #define CHK_FOR_DISPn CheckForDisp0 #include "parmode.h" // If caller wants only one mode, return just one (ignore comma); @@ -102,6 +103,7 @@ int amode(int acount) #define AnESYM a1esym #define AMn_IX0 am1_ix0 #define AMn_IXN am1_ixn + #define CHK_FOR_DISPn CheckForDisp1 #include "parmode.h" nmodes = 2; diff --git a/parmode.h b/parmode.h index 543701a..38f6f94 100644 --- a/parmode.h +++ b/parmode.h @@ -31,6 +31,11 @@ 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]) @@ -145,6 +150,15 @@ 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; @@ -223,6 +237,7 @@ if (expr(AnEXPR, &AnEXVAL, &AnEXATTR, &AnESYM) != OK) return ERROR; +CHK_FOR_DISPn: if (*tok == DOTW) { // expr.W @@ -287,7 +302,7 @@ ; } -// Cleanup dirty little macros +// Clean up dirty little macros #undef AnOK #undef AMn #undef AnREG @@ -302,3 +317,4 @@ #undef AnESYM #undef AMn_IX0 #undef AMn_IXN +#undef CHK_FOR_DISPn diff --git a/version.h b/version.h index ad81875..1d1ba1e 100644 --- a/version.h +++ b/version.h @@ -13,6 +13,6 @@ #define MAJOR 1 // Major version number #define MINOR 4 // Minor version number -#define PATCH 0 // Patch release number +#define PATCH 1 // Patch release number #endif // __VERSION_H__ -- 2.37.2