From: Frode Solheim Date: Tue, 22 Sep 2015 18:37:09 +0000 (+0200) Subject: JIT: Do not use uae_p32 for an intentional case of 32-bit wraparound X-Git-Tag: 3200~55^2 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=f46a79831f79911947d2b738f307c6463ae8ab06;p=francis%2Fwinuae.git JIT: Do not use uae_p32 for an intentional case of 32-bit wraparound --- diff --git a/jit/compemu_fpp.cpp b/jit/compemu_fpp.cpp index d025fdd7..a76ac929 100644 --- a/jit/compemu_fpp.cpp +++ b/jit/compemu_fpp.cpp @@ -548,6 +548,9 @@ void comp_fbcc_opp (uae_u32 opcode) return; } + // comp_pc_p is expected to be bound to 32-bit addresses + assert((uintptr) comp_pc_p <= 0xffffffffUL); + if (opcode & 0x20) { /* only cc from 00 to 1f are defined */ FAIL (1); return; @@ -558,9 +561,13 @@ void comp_fbcc_opp (uae_u32 opcode) else { off = comp_get_ilong ((m68k_pc_offset += 4) - 4); } - mov_l_ri (S1, uae_p32( - comp_pc_p + off - (m68k_pc_offset - start_68k_offset))); - mov_l_ri (PC_P, uae_p32(comp_pc_p)); + + /* Note, "off" will sometimes be (unsigned) "negative", so the following + * uintptr can be > 0xffffffff, but the result will be correct due to + * wraparound when truncated to 32 bit in the call to mov_l_ri. */ + mov_l_ri(S1, (uintptr) + (comp_pc_p + off - (m68k_pc_offset - start_68k_offset))); + mov_l_ri(PC_P, (uintptr) comp_pc_p); /* Now they are both constant. Might as well fold in m68k_pc_offset */ add_l_ri (S1, m68k_pc_offset);