X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=mach.c;h=4e106da85efc34f6258bb3ddba4a71d5aaccc917;hp=c3f6d83e11d4c3ade2aa60540820a13e094b2be9;hb=582df8950c285e1746d0c4a9e3ead6545c962dc8;hpb=05d0350b35a6a6b255cb2a3fab7796f5d4ee4d02 diff --git a/mach.c b/mach.c index c3f6d83..4e106da 100644 --- a/mach.c +++ b/mach.c @@ -475,7 +475,7 @@ int m_lea(WORD inst, WORD siz) && ((am0 == ADISP) && (a0reg == a1reg) && (a0exattr & DEFINED)) && ((a0exval > 0) && (a0exval <= 8))) { - inst = B16(01010000, 01001000) | ((a0exval & 7) << 9) | (a0reg); + inst = B16(01010000, 01001000) | (((uint16_t)a0exval & 7) << 9) | (a0reg); D_word(inst); warn("lea size(An),An converted to addq #size,An"); return OK; @@ -705,8 +705,6 @@ int m_bitop(WORD inst, WORD siz) int m_dbra(WORD inst, WORD siz) { - VALUE v; - siz = siz; inst |= a0reg; D_word(inst); @@ -716,7 +714,7 @@ int m_dbra(WORD inst, WORD siz) if ((a1exattr & TDB) != cursect) return error(rel_error); - v = a1exval - sloc; + uint32_t v = a1exval - sloc; if (v + 0x8000 > 0x10000) return error(range_error); @@ -822,10 +820,12 @@ int m_move(WORD inst, WORD size) int siz = (int)size; // Try to optimize to MOVEQ + // N.B.: We can get away with casting the uint64_t to a 32-bit value + // because it checks for a SIZL (i.e., a 32-bit value). if (CHECK_OPTS(OPT_MOVEL_MOVEQ) && (siz == SIZL) && (am0 == IMMED) && (am1 == DREG) && ((a0exattr & (TDB | DEFINED)) == DEFINED) - && (a0exval + 0x80 < 0x100)) + && ((uint32_t)a0exval + 0x80 < 0x100)) { m_moveq((WORD)0x7000, (WORD)0); @@ -917,7 +917,7 @@ int m_moveq(WORD inst, WORD siz) AddFixup(FU_BYTE | FU_SEXT, sloc + 1, a0expr); a0exval = 0; } - else if (a0exval + 0x100 >= 0x200) + else if ((uint32_t)a0exval + 0x100 >= 0x200) return error(range_error); inst |= reg_9[a1reg] | (a0exval & 0xFF); @@ -969,8 +969,6 @@ int m_movep(WORD inst, WORD siz) // int m_br(WORD inst, WORD siz) { - VALUE v; - if (a0exattr & DEFINED) { if ((a0exattr & TDB) != cursect) @@ -979,7 +977,7 @@ int m_br(WORD inst, WORD siz) return error(rel_error); //} - v = a0exval - (sloc + 2); + uint32_t v = (uint32_t)a0exval - (sloc + 2); // Optimize branch instr. size if (siz == SIZN) @@ -1105,7 +1103,7 @@ int m_trap(WORD inst, WORD siz) // int m_movem(WORD inst, WORD siz) { - VALUE eval; + uint64_t eval; WORD i; WORD w; WORD rmask; @@ -1229,7 +1227,7 @@ int m_br30(WORD inst, WORD siz) if ((a0exattr & TDB) != cursect) return error(rel_error); - VALUE v = a0exval - (sloc + 2); + uint32_t v = (uint32_t)a0exval - (sloc + 2); D_word(inst); D_long(v); @@ -1251,7 +1249,6 @@ int m_br30(WORD inst, WORD siz) // int m_bfop(WORD inst, WORD siz) { - if ((bfval1 > 31) || (bfval1 < 0)) return error("bfxxx offset: immediate value must be between 0 and 31"); @@ -1280,7 +1277,7 @@ int m_bfop(WORD inst, WORD siz) bfparam1 = bfval1 << 12; } - D_word((inst|am0|a0reg|am1|a1reg)); + D_word((inst | am0 | a0reg | am1 | a1reg)); ea0gen(siz); // Generate EA // Second instruction word - Dest register (if exists), Do, Offset, Dw, Width @@ -1342,7 +1339,7 @@ int m_callm(WORD inst, WORD siz) if (a0exval > 255) return error(range_error); - inst = a0exval; + inst = (uint16_t)a0exval; D_word(inst); } else @@ -1628,7 +1625,7 @@ int m_cpbr(WORD inst, WORD siz) if ((a0exattr & TDB) != cursect) return error(rel_error); - VALUE v = a0exval - (sloc + 2); + uint32_t v = (uint32_t)a0exval - (sloc + 2); // Optimize branch instr. size if (siz == SIZL) @@ -1682,7 +1679,7 @@ int m_cpdbr(WORD inst, WORD siz) { CHECK00; - VALUE v; + uint32_t v; WORD condition = inst & 0x1f; // Grab condition sneakily placed in the lower 5 bits of inst inst &= 0xffe0; // And then mask them out - you ain't seen me, roit? @@ -1698,7 +1695,7 @@ int m_cpdbr(WORD inst, WORD siz) if ((a1exattr & TDB) != cursect) return error(rel_error); - v = a1exval - sloc; + v = (uint32_t)a1exval - sloc; if (v + 0x8000 > 0x10000) return error(range_error); @@ -2095,7 +2092,7 @@ int m_move16b(WORD inst, WORD siz) { //move16 (ax)+,(xxx).L inst |= 0 << 3; - v = a1exval; + v = (int)a1exval; } } else if (am0 == ABSL) @@ -2104,20 +2101,20 @@ int m_move16b(WORD inst, WORD siz) { //move16 (xxx).L,(ax)+ inst |= 1 << 3; - v = a0exval; + v = (int)a0exval; } else //APOSTINC { //move16 (xxx).L,(ax) inst |= 3 << 3; - v = a0exval; + v = (int)a0exval; } } else if (am0 == AIND) { //move16 (ax),(xxx).L inst |= 2 << 3; - v = a1exval; + v = (int)a1exval; } D_word(inst); @@ -2182,14 +2179,14 @@ int m_pack(WORD inst, WORD siz) return error(undef_error); if (a0exval + 0x8000 > 0x10000) - return error(""); + return error(""); if (*tok != EOL) return error(extra_stuff); D_word((a0exval & 0xffff)); - + return OK; @@ -2486,7 +2483,7 @@ int m_pflush(WORD inst, WORD siz) return error("function code immediate should be defined"); if (a0exval > 7 && a0exval < 0) return error("function code out of range (0-7)"); - fc = a0exval; + fc = (uint16_t)a0exval; break; case KW_D0: case KW_D1: @@ -2523,7 +2520,7 @@ int m_pflush(WORD inst, WORD siz) return error("mask immediate value should be defined"); if (a0exval > 7 && a0exval < 0) return error("function code out of range (0-7)"); - mask = a0exval << 5; + mask = (uint16_t)a0exval << 5; if (*tok == EOL) { @@ -2575,7 +2572,7 @@ int m_pflush(WORD inst, WORD siz) // hardcoded in 68ktab but there is aliasing // between 68030 and 68040 opcode. So we just // set the 3 lower bits to 1 in pflushn inside - // 68ktab and detect it here. + // 68ktab and detect it here. inst = (inst & 0xff8) | 8; inst |= (tok[1] & 7) | (5 << 8); if (tok[3] != EOL) @@ -2651,7 +2648,7 @@ int m_pload(WORD inst, WORD siz, WORD extension) // a 68020 + 68551 socket and since this is // an Atari targetted assembler.... CHECKNO30; - + inst |= am1; D_word(inst); @@ -2676,7 +2673,7 @@ int m_pload(WORD inst, WORD siz, WORD extension) case IMMED: if ((a0exattr & DEFINED) == 0) return error("constant value must be defined"); - inst = (2 << 3) | a0exval; + inst = (2 << 3) | (uint16_t)a0exval; break; } @@ -2684,7 +2681,7 @@ int m_pload(WORD inst, WORD siz, WORD extension) D_word(inst); ea1gen(siz); - + return OK; } @@ -2805,7 +2802,6 @@ int m_pmovefd(WORD inst, WORD siz) return m_pmove(inst | (1 << 8), siz); } - // // ptrapcc (68851) // @@ -3106,7 +3102,7 @@ int m_fdbcc(WORD inst, WORD siz) if ((a1exattr & TDB) != cursect) return error(rel_error); - VALUE v = a1exval - sloc; + uint32_t v = (uint32_t)a1exval - sloc; if ((v + 0x8000) > 0x10000) return error(range_error);