Mercurial > repos > blastem
changeset 390:561fe3ea3fc8
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
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 08 Jun 2013 11:31:52 -0700 |
parents | 3815ad1e684e |
children | 3f4f2b7318a1 |
files | z80_to_x86.c zruntime.S |
diffstat | 2 files changed, 6 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/z80_to_x86.c Thu Jun 06 08:45:54 2013 -0700 +++ b/z80_to_x86.c Sat Jun 08 11:31:52 2013 -0700 @@ -1742,7 +1742,7 @@ 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_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;
--- a/zruntime.S Thu Jun 06 08:45:54 2013 -0700 +++ b/zruntime.S Sat Jun 08 11:31:52 2013 -0700 @@ -247,8 +247,12 @@ .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