From f46a79831f79911947d2b738f307c6463ae8ab06 Mon Sep 17 00:00:00 2001 From: Frode Solheim Date: Tue, 22 Sep 2015 20:37:09 +0200 Subject: [PATCH] JIT: Do not use uae_p32 for an intentional case of 32-bit wraparound --- jit/compemu_fpp.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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); -- 2.47.3