X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=parmode.h;h=c72b47012613e6ffd4d3b15bbdcf75e221157601;hp=5ef768a44175dbde77b08ffbc58cc078798877b8;hb=917bfc1503181b7e762b73b9560bb834c12c64fa;hpb=75969398d9b8a9f82ea76fc4e4cbfb97b11160a4 diff --git a/parmode.h b/parmode.h index 5ef768a..c72b470 100644 --- a/parmode.h +++ b/parmode.h @@ -3,7 +3,7 @@ // PARMODE.C - Addressing Modes Parser Include // Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 -// Source Utilised with the Kind Permission of Landon Dyer +// Source utilised with the kind permission of Landon Dyer // // This file is included (twice) to parse two addressing modes, into slightly @@ -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,22 +237,31 @@ if (expr(AnEXPR, &AnEXVAL, &AnEXATTR, &AnESYM) != OK) return ERROR; +CHK_FOR_DISPn: if (*tok == DOTW) - { // expr.W + { + // expr.W tok++; AMn = ABSW; goto AnOK; } else if (*tok != '(') - { // expr[.L] + { + // expr[.L] AMn = ABSL; - // Defined, absolute values from $FFFF8000..$00007FFF get optimized to absolute short - if ((AnEXATTR & (TDB|DEFINED)) == DEFINED && (AnEXVAL + 0x8000) < 0x10000) + // Defined, absolute values from $FFFF8000..$00007FFF get optimized + // to absolute short + if (optim_flag && (AnEXATTR & (TDB|DEFINED)) == DEFINED && (AnEXVAL + 0x8000) < 0x10000) + { AMn = ABSW; + if (sbra_flag) + warn("absolute value from $FFFF8000..$00007FFF optimised to absolute short"); + } + // Is .L forced here? if (*tok == DOTL) - { // force .L + { tok++; AMn = ABSL; } @@ -283,7 +306,7 @@ ; } -// Cleanup dirty little macros +// Clean up dirty little macros #undef AnOK #undef AMn #undef AnREG @@ -298,3 +321,4 @@ #undef AnESYM #undef AMn_IX0 #undef AMn_IXN +#undef CHK_FOR_DISPn