Version bump for last commit; now at v2.0.23.
[rmac] / parmode.h
index 3cefbca164e728125e5deccd27aadcd3ba5875fd..dd3e1a2b03ee87b6bd58b0a6df3da462ab7bfe2f 100644 (file)
--- a/parmode.h
+++ b/parmode.h
@@ -367,8 +367,8 @@ AMn_IXN:                 // Handle any indexed (tok -> a comma)
                                        tok++;
                        }
 
-                       // Check for address register or PC, 
-                       // suppress base register otherwise
+                       // Check for address register or PC, suppress base register
+                       // otherwise
 
                        if (*tok == KW_PC)
                        {                                       // ([bd,PC,...
@@ -518,7 +518,7 @@ AMn_IXN:                 // Handle any indexed (tok -> a comma)
                                        goto IS_SUPPRESSEDn;    // https://xkcd.com/292/ - what does he know anyway?
                                }
 
-                               // Check for size
+                               // Check for Xn size
                                // ([bd,An/PC],Xn.W/L...)
                                switch ((int)*tok)
                                {
@@ -526,8 +526,6 @@ AMn_IXN:                 // Handle any indexed (tok -> a comma)
                                case DOTW:
                                        tok++;
                                        break;
-                               default:
-                                       break;
                                case DOTL:
                                        AnEXTEN |= EXT_L;
                                        tok++;
@@ -535,9 +533,11 @@ AMn_IXN:                 // Handle any indexed (tok -> a comma)
                                case DOTB:
                                        // .B not allowed here...
                                        goto badmode;
+                               default:
+                                       break;
                                }
 
-                               // Check for scale
+                               // Check for Xn scale
                                if (*tok == '*')                   // ([bd,An/PC],Xn*...)
                                {                                  // scale: *1, *2, *4, *8
                                        tok++;
@@ -546,47 +546,32 @@ AMn_IXN:                 // Handle any indexed (tok -> a comma)
                                        {
                                                if (expr(scaleexpr, &scaleval, &scaleattr, &scaleesym) != OK)
                                                        return error("scale factor expression must evaluate");
-
-                                               switch (scaleval)
-                                               {
-                                               case 1:
-                                                       break;
-                                               case 2:
-                                                       AnIXSIZ |= TIMES2;
-                                                       break;
-                                               case 4:
-                                                       AnIXSIZ |= TIMES4;
-                                                       break;
-                                               case 8:
-                                                       AnIXSIZ |= TIMES8;
-                                                       break;
-                                               default:
-                                                       goto badmode;
-                                               }
                                        }
-                                       else if (*tok++ != CONST)
-                                               goto badmode;
-                                       else
+                                       else if (*tok == CONST)
                                        {
-                                               switch ((int)*tok++)
-                                               {
-                                               case 1:
-                                                       break;
-                                               case 2:
-                                                       AnIXSIZ |= TIMES2;
-                                                       break;
-                                               case 4:
-                                                       AnIXSIZ |= TIMES4;
-                                                       break;
-                                               case 8:
-                                                       AnIXSIZ |= TIMES8;
-                                                       break;
-                                               default:
-                                                       goto badmode;
-                                               }
-
+                                               scaleval = (int)*tok++;
                                                tok++;  // Take into account that constants are 64-bit
                                        }
+                                       else
+                                               goto badmode;
+
+                                       switch (scaleval)
+                                       {
+                                       case 1:
+                                               break;
+                                       case 2:
+                                               AnIXSIZ |= TIMES2;
+                                               break;
+                                       case 4:
+                                               AnIXSIZ |= TIMES4;
+                                               break;
+                                       case 8:
+                                               AnIXSIZ |= TIMES8;
+                                               break;
+                                       default:
+                                               goto badmode;
+                                       }
+
                                }
 
                                // Check for od
@@ -631,13 +616,15 @@ CHECKODn:
                                        if (*tok == DOTL)
                                                tok++;                          // Doesn't matter, we're going for .L anyway
 
+                                       WORD od_ea = 0;
+
                                        // od.L
                                        if (!(AnEXTEN & EXT_BS))
-                                               AnEXTEN |= EXT_IISPOSL; // Long outer displacement
+                                               od_ea = EXT_IISPOSL; // Long outer displacement
                                        else
                                        {
                                                // bd is suppressed, so sticking the od size in bd
-                                               AnEXTEN |= EXT_BDSIZEL;
+                                               od_ea = EXT_BDSIZEL;
                                                // And of course the expression has to be copied to
                                                // AnBEXPR instead of AnEXPR. Yay. :-/
                                                int i = 0;
@@ -646,7 +633,8 @@ CHECKODn:
                                                {
                                                        AnBEXPR[i] = AnEXPR[i];
                                                        i++;
-                                               } while (AnEXPR[i] != 'E');
+                                               }
+                                               while (AnEXPR[i] != 'E');
 
                                                AnBEXPR[i] = 'E';
                                        }
@@ -659,11 +647,13 @@ CHECKODn:
                                                && ((AnEXATTR & (TDB | DEFINED)) == DEFINED)
                                                && (((uint32_t)AnEXVAL + 0x8000) < 0x10000))
                                        {
-                                               AnEXTEN |= EXT_IISPOSW; // Word outer displacement
+                                               od_ea = EXT_IISPOSW; // Word outer displacement
                                                AMn = MEMPOST + ea_PC;
+
                                                if (optim_warn_flag)
                                                        warn("absolute value in outer displacement ranging $FFFF8000..$00007FFF optimised to absolute short");
                                        }
+                                       AnEXTEN |= od_ea;
                                }
 
                                // Check for final closing parenthesis