X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=parmode.h;h=5518343c04878f487f01e701a3bdb0cf774905ff;hp=38f6f94b6c787f5143c40bb98cdc0e7f806c8a0f;hb=60f204cb9e3905100da0d89f14bb40db764acd9e;hpb=52cea8604f22cf5281dbc66fcae5fea37d038e0f diff --git a/parmode.h b/parmode.h index 38f6f94..5518343 100644 --- a/parmode.h +++ b/parmode.h @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System // PARMODE.C - Addressing Modes Parser Include -// Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2017 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // @@ -72,21 +72,22 @@ } AMn = AINDEXED; - goto AMn_IX0; // Handle ",Xn[.siz][*scale])" + goto AMn_IX0; // Handle ",Xn[.siz][*scale])" } else if (*tok == KW_PC) - { // (PC,Xn[.siz][*scale]) + { // (PC,Xn[.siz][*scale]) tok++; AMn = PCINDEXED; - // Common index handler; enter here with `tok' pointing at the comma. + // Common index handler; enter here with 'tok' pointing at the + // comma. - AMn_IX0: // Handle indexed with missing expr + AMn_IX0: // Handle indexed with missing expr AnEXVAL = 0; AnEXATTR = ABS | DEFINED; - AMn_IXN: // Handle any indexed (tok -> a comma) + AMn_IXN: // Handle any indexed (tok -> a comma) if (*tok++ != ',') goto badmode; @@ -97,7 +98,7 @@ AnIXREG = *tok++ & 15; switch ((int)*tok) - { // Index reg size: | .W | .L + { // Index reg size: | .W | .L case DOTW: tok++; default: @@ -107,12 +108,12 @@ AnIXSIZ = 0x0800; tok++; break; - case DOTB: // .B not allowed here... + case DOTB: // .B not allowed here... goto badmode; } if (*tok == '*') - { // scale: *1, *2, *4, *8 + { // scale: *1, *2, *4, *8 tok++; if (*tok++ != CONST || *tok > 8) @@ -136,17 +137,17 @@ } } - if (*tok++ != ')') // final ")" + if (*tok++ != ')') // final ")" goto badmode; goto AnOK; } else if (*tok == '[') - { // ([... + { // ([... goto unmode; } else - { // (expr... + { // (expr... if (expr(AnEXPR, &AnEXVAL, &AnEXATTR, &AnESYM) != OK) return ERROR; @@ -190,7 +191,7 @@ } else if (*tok == ')') { - AMn = PCDISP; // expr(PC) + AMn = PCDISP; // expr(PC) tok++; goto AnOK; } @@ -201,7 +202,7 @@ goto badmode; } } - else if (*tok=='-' && tok[1]=='(' && ((tok[2]>=KW_A0) && (tok[2]<=KW_A7)) && tok[3]==')') + else if (*tok == '-' && tok[1] == '(' && ((tok[2] >= KW_A0) && (tok[2] <= KW_A7)) && tok[3] == ')') { AMn = APREDEC; AnREG = tok[2] & 7; @@ -240,9 +241,13 @@ CHK_FOR_DISPn: if (*tok == DOTW) { - // expr.W + // expr.W tok++; AMn = ABSW; + + if ((AnEXATTR & (TDB|DEFINED)) == DEFINED && (AnEXVAL < 0x10000)) + AnEXVAL = (int32_t)(int16_t)AnEXVAL; // Sign extend value + goto AnOK; } else if (*tok != '(') @@ -252,9 +257,14 @@ CHK_FOR_DISPn: // Defined, absolute values from $FFFF8000..$00007FFF get optimized // to absolute short - if ((AnEXATTR & (TDB|DEFINED)) == DEFINED && (AnEXVAL + 0x8000) < 0x10000) + if (optim_flags[OPT_ABS_SHORT] && (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) {