X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=amode.c;h=8ac53920d1343d9dc6f3099274a46306c86ded6c;hp=3d789af93cb3f258a12d4370e18f3a22d0678cf8;hb=bdbf34766f4d074a5933eb1326fe4ce03d249e10;hpb=cfd001aea60f54e49d9beae0f941c513f45c202b diff --git a/amode.c b/amode.c index 3d789af..8ac5392 100644 --- a/amode.c +++ b/amode.c @@ -1,7 +1,7 @@ // // RMAC - Reboot's Macro Assembler for all Atari computers // AMODE.C - Addressing Modes -// Copyright (C) 199x Landon Dyer, 2011-2017 Reboot and Friends +// Copyright (C) 199x Landon Dyer, 2011-2019 Reboot and Friends // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // @@ -27,16 +27,16 @@ int nmodes; // Number of addr'ing modes found int am0; // Addressing mode int a0reg; // Register TOKEN a0expr[EXPRSIZE]; // Expression -uint32_t a0exval; // Expression's value +uint64_t a0exval; // Expression's value WORD a0exattr; // Expression's attribute int a0ixreg; // Index register int a0ixsiz; // Index register size (and scale) TOKEN a0oexpr[EXPRSIZE]; // Outer displacement expression -uint32_t a0oexval; // Outer displacement value +uint64_t a0oexval; // Outer displacement value WORD a0oexattr; // Outer displacement attribute SYM * a0esym; // External symbol involved in expr TOKEN a0bexpr[EXPRSIZE]; // Base displacement expression -uint32_t a0bexval; // Base displacement value +uint64_t a0bexval; // Base displacement value WORD a0bexattr; // Base displacement attribute WORD a0bsize; // Base displacement size WORD a0extension; // 020+ extension address word @@ -45,35 +45,34 @@ WORD am0_030; // ea bits for 020+ addressing modes int am1; // Addressing mode int a1reg; // Register TOKEN a1expr[EXPRSIZE]; // Expression -uint32_t a1exval; // Expression's value +uint64_t a1exval; // Expression's value WORD a1exattr; // Expression's attribute int a1ixreg; // Index register int a1ixsiz; // Index register size (and scale) TOKEN a1oexpr[EXPRSIZE]; // Outer displacement expression -uint32_t a1oexval; // Outer displacement value +uint64_t a1oexval; // Outer displacement value WORD a1oexattr; // Outer displacement attribute SYM * a1esym; // External symbol involved in expr TOKEN a1bexpr[EXPRSIZE]; // Base displacement expression -uint32_t a1bexval; // Base displacement value +uint64_t a1bexval; // Base displacement value WORD a1bexattr; // Base displacement attribute WORD a1bsize; // Base displacement size WORD a1extension; // 020+ extension address word WORD am1_030; // ea bits for 020+ addressing modes int a2reg; // Register for div.l (68020+) -WORD mulmode; // to distinguish between 32 and 64 bit multiplications (68020+) int bfparam1; // bfxxx / fmove instruction parameter 1 int bfparam2; // bfxxx / fmove instruction parameter 2 -int bfval1; //bfxxx / fmove value 1 -int bfval2; //bfxxx / fmove value 2 +int bfval1; // bfxxx / fmove value 1 +int bfval2; // bfxxx / fmove value 2 TOKEN bf0expr[EXPRSIZE]; // Expression -uint32_t bf0exval; // Expression's value +uint64_t bf0exval; // Expression's value WORD bf0exattr; // Expression's attribute SYM * bf0esym; // External symbol involved in expr // Function prototypes -int check030bf(void); +int Check030Bitfield(void); // @@ -88,7 +87,8 @@ int amode(int acount) a0exattr = a0oexattr = a1exattr = a1oexattr = 0; a0esym = a1esym = NULL; a0bexpr[0] = a1bexpr[0] = ENDEXPR; - a0bexval = a0bsize = a0extension = a1bexval = a1bsize = a1extension = 0; + a0bexval = a1bexval = 0; + a0bsize = a0extension = a1bsize = a1extension = 0; am0_030 = am1_030 = 0; bfparam1 = bfparam2 = 0; bf0expr[0] = ENDEXPR; @@ -132,7 +132,7 @@ int amode(int acount) // it's a bitfield instruction--check the parameters inside the {} block // for validity if (*tok == '{') - if (check030bf() == ERROR) + if (Check030Bitfield() == ERROR) return ERROR; if ((acount == 0) || (*tok != ',')) @@ -170,7 +170,7 @@ int amode(int acount) // It's a bitfield instruction--check the parameters inside the {} block // for validity if (*tok == '{') - if (check030bf() == ERROR) + if (Check030Bitfield() == ERROR) return ERROR; // At this point, it is legal for 020+ to have a ':'. For example divu.l @@ -184,26 +184,17 @@ int amode(int acount) tok++; //eat the colon if ((*tok >= KW_D0) && (*tok <= KW_D7)) - { - a2reg = (*tok - KW_D0); - mulmode = 1 << 10; - } + a2reg = (*tok++) & 7; else if ((*tok >= KW_FP0) && (*tok <= KW_FP7)) - { - a2reg = (*tok - KW_FP0); - mulmode = 1 << 10; - } + a2reg = (*tok++) & 7; else return error("a data or FPU register must follow a :"); - - *tok++; } else { // If no ':' is present then maybe we have something like divs.l d0,d1 // which sould translate to divs.l d0,d1:d1 a2reg = a1reg; - mulmode = 0; } nmodes = 2; @@ -212,9 +203,6 @@ int amode(int acount) // Error messages: badmode: return error("addressing mode syntax"); - - //unmode: - //return error("unimplemented addressing mode"); } @@ -329,8 +317,8 @@ int fpu_reglist_left(WORD * a_rmask) int fpu_reglist_right(WORD * a_rmask) { static WORD msktab_plus[] = { - 0x0001, 0x0002, 0x0004, 0x0008, - 0x0010, 0x0020, 0x0040, 0x0080 + 0x0080, 0x0040, 0x0020, 0x0010, + 0x0008, 0x0004, 0x0002, 0x0001 }; WORD rmask = 0; @@ -381,19 +369,20 @@ int fpu_reglist_right(WORD * a_rmask) // bfxxx {param1,param2} // param1/2 are either data registers or immediate values // -int check030bf(void) +int Check030Bitfield(void) { + PTR tp; CHECK00; tok++; if (*tok == CONST) { - tok++; - bfval1 = *(int *)tok; + tp.u32 = tok + 1; + bfval1 = (int)*tp.u64++; + tok = tp.u32; // Do=0, offset=immediate - shift it to place bfparam1 = (0 << 11); - tok++; } else if (*tok == SYMBOL) { @@ -403,7 +392,7 @@ int check030bf(void) if (!(bf0exattr & DEFINED)) return error("bfxxx offset: immediate value must evaluate"); - bfval1 = bf0exval; + bfval1 = (int)bf0exval; // Do=0, offset=immediate - shift it to place bfparam1 = (0 << 11); @@ -418,8 +407,9 @@ int check030bf(void) else return ERROR; - if (*tok==':') - tok++; //eat the ':' + // Eat the ':', if any + if (*tok == ':') + tok++; if (*tok == '}' && tok[1] == EOL) { @@ -430,19 +420,19 @@ int check030bf(void) if (*tok == CONST) { - tok++; - bfval2 = *(int *)tok; + tp.u32 = tok + 1; + bfval2 = (int)*tp.u64++; + tok = tp.u32; // Do=0, offset=immediate - shift it to place bfparam2 = (0 << 5); - tok++; } else if (*tok == SYMBOL) { if (expr(bf0expr, &bf0exval, &bf0exattr, &bf0esym) != OK) return ERROR; - bfval2 = bf0exval; + bfval2 = (int)bf0exval; if (!(bf0exattr & DEFINED)) return error("bfxxx width: immediate value must evaluate"); @@ -453,7 +443,7 @@ int check030bf(void) else if ((*tok >= KW_D0) && (*tok <= KW_D7)) { // Do=1, offset=data register - shift it to place - bfval2 = ((*(int *)tok - 128)); + bfval2 = (*(int *)tok - 128); bfparam2 = (1 << 5); tok++; }