X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=mach.c;h=4e106da85efc34f6258bb3ddba4a71d5aaccc917;hp=e01ea88599b6ab892f2364c3291f7aefa473927e;hb=582df8950c285e1746d0c4a9e3ead6545c962dc8;hpb=ada93ab0c3763d4a4ab607cbc73c24d74bc94ff4 diff --git a/mach.c b/mach.c index e01ea88..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) { - uint32_t 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) { - uint32_t 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) { - uint32_t 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); - uint32_t v = a0exval - (sloc + 2); + uint32_t v = (uint32_t)a0exval - (sloc + 2); D_word(inst); D_long(v); @@ -1341,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 @@ -1627,7 +1625,7 @@ int m_cpbr(WORD inst, WORD siz) if ((a0exattr & TDB) != cursect) return error(rel_error); - uint32_t v = a0exval - (sloc + 2); + uint32_t v = (uint32_t)a0exval - (sloc + 2); // Optimize branch instr. size if (siz == SIZL) @@ -1697,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); @@ -2094,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) @@ -2103,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); @@ -2485,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: @@ -2522,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) { @@ -2675,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; } @@ -2804,7 +2802,6 @@ int m_pmovefd(WORD inst, WORD siz) return m_pmove(inst | (1 << 8), siz); } - // // ptrapcc (68851) // @@ -3105,7 +3102,7 @@ int m_fdbcc(WORD inst, WORD siz) if ((a1exattr & TDB) != cursect) return error(rel_error); - uint32_t v = a1exval - sloc; + uint32_t v = (uint32_t)a1exval - sloc; if ((v + 0x8000) > 0x10000) return error(range_error);