diff options
author | Mike Pavone <pavone@retrodev.com> | 2013-06-08 11:31:52 -0700 |
---|---|---|
committer | Mike Pavone <pavone@retrodev.com> | 2013-06-08 11:31:52 -0700 |
commit | c451b9b3878da0c81feabb9501a9af55644ac12e (patch) | |
tree | 2edafb1ac40dc03f084031b06ffd2e6c5eed21cc | |
parent | 871cb9435b2e33f45fd63b76472a7db2ca7bad8d (diff) |
Use a call instruction to figure out the original native address when retranslating so that it does not get lost when the byte transforms from a instruction word to extension word
-rw-r--r-- | z80_to_x86.c | 5 | ||||
-rw-r--r-- | zruntime.S | 4 |
2 files changed, 6 insertions, 3 deletions
diff --git a/z80_to_x86.c b/z80_to_x86.c index b30c7a1..827ceb0 100644 --- a/z80_to_x86.c +++ b/z80_to_x86.c @@ -1742,7 +1742,7 @@ z80_context * z80_handle_code_write(uint32_t address, z80_context * context) uint8_t * dst = z80_get_native_address(context, inst_start); dprintf("patching code at %p for Z80 instruction at %X due to write to %X\n", dst, inst_start, address); dst = mov_ir(dst, inst_start, SCRATCH1, SZ_D); - dst = jmp(dst, (uint8_t *)z80_retrans_stub); + dst = call(dst, (uint8_t *)z80_retrans_stub); } return context; } @@ -1769,12 +1769,11 @@ void z80_handle_deferred(z80_context * context) } } -void * z80_retranslate_inst(uint32_t address, z80_context * context) +void * z80_retranslate_inst(uint32_t address, z80_context * context, uint8_t * orig_start) { char disbuf[80]; x86_z80_options * opts = context->options; uint8_t orig_size = z80_get_native_inst_size(opts, address); - uint8_t * orig_start = z80_get_native_address(context, address); uint32_t orig = address; address &= 0x1FFF; uint8_t * dst = opts->cur_code; @@ -247,8 +247,12 @@ z80_io_write: .global z80_retrans_stub z80_retrans_stub: + pop %r14 call z80_save_context + /* adjust for mov and call instructions */ + sub $10, %r14 mov %r13d, %edi + mov %r14, %rdx push %rsi call z80_retranslate_inst pop %rsi |