summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pavone <pavone@retrodev.com>2013-01-06 22:45:45 -0800
committerMike Pavone <pavone@retrodev.com>2013-01-06 22:45:45 -0800
commit706394b9af11755dd7e7c4f326614dba885cc47b (patch)
tree0d6c6769200908fc87aa904df75d980c09c26cb6
parentb1f04ec182a1cfbdcfb6fbc52b0c45a0182494e5 (diff)
Fix order of reading saved pc and swapping user and system stack pointers
-rw-r--r--m68k_to_x86.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/m68k_to_x86.c b/m68k_to_x86.c
index 0561c4c..894f2ae 100644
--- a/m68k_to_x86.c
+++ b/m68k_to_x86.c
@@ -3343,6 +3343,10 @@ uint8_t * translate_m68k(uint8_t * dst, m68kinst * inst, x86_68k_options * opts)
dst = call(dst, (uint8_t *)m68k_read_word_scratch1);
dst = add_ir(dst, 2, opts->aregs[7], SZ_D);
dst = call(dst, (uint8_t *)set_sr);
+ //Read saved PC
+ dst = mov_rr(dst, opts->aregs[7], SCRATCH1, SZ_D);
+ dst = call(dst, (uint8_t *)m68k_read_long_scratch1);
+ dst = add_ir(dst, 4, opts->aregs[7], SZ_D);
//Check if we've switched to user mode and swap stack pointers if needed
dst = bt_irdisp8(dst, 5, CONTEXT, offsetof(m68k_context, status), SZ_B);
end_off = dst+1;
@@ -3351,10 +3355,6 @@ uint8_t * translate_m68k(uint8_t * dst, m68kinst * inst, x86_68k_options * opts)
dst = mov_rdisp8r(dst, CONTEXT, offsetof(m68k_context, aregs) + sizeof(uint32_t) * 8, opts->aregs[7], SZ_D);
dst = mov_rrdisp8(dst, SCRATCH2, CONTEXT, offsetof(m68k_context, aregs) + sizeof(uint32_t) * 8, SZ_D);
*end_off = dst - (end_off+1);
- //Read saved PC
- dst = mov_rr(dst, opts->aregs[7], SCRATCH1, SZ_D);
- dst = call(dst, (uint8_t *)m68k_read_long_scratch1);
- dst = add_ir(dst, 4, opts->aregs[7], SZ_D);
//Get native address, sync components, recalculate integer points and jump to returned address
dst = call(dst, (uint8_t *)m68k_native_addr_and_sync);
dst = jmp_r(dst, SCRATCH1);