diff options
author | Michael Pavone <pavone@retrodev.com> | 2014-12-26 12:52:13 -0800 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2014-12-26 12:52:13 -0800 |
commit | 669d5ebf9474cb7efcd6aee6a84c28b3910b9348 (patch) | |
tree | f4a2202581a96853e7eff3840f9259e3c76fa48a /z80_to_x86.c | |
parent | 58056e06047d7777dbb2fe500fe6801fa92785f9 (diff) |
Update code->cur before calling z80_get_address_trans in z80_retranslate_inst to avoid any newly translated instructions from being placed in the "buffer zone". Save the current value of the code_info struct for placing the final jmp instruction in the correct place
Diffstat (limited to 'z80_to_x86.c')
-rw-r--r-- | z80_to_x86.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/z80_to_x86.c b/z80_to_x86.c index c402ad5..fd30d56 100644 --- a/z80_to_x86.c +++ b/z80_to_x86.c @@ -1779,6 +1779,7 @@ void * z80_retranslate_inst(uint32_t address, z80_context * context, uint8_t * o } #endif if (orig_size != ZMAX_NATIVE_SIZE) { + check_alloc_code(code, ZMAX_NATIVE_SIZE); code_ptr start = code->cur; deferred_addr * orig_deferred = opts->gen.deferred; translate_z80inst(&instbuf, context, address); @@ -1802,10 +1803,11 @@ void * z80_retranslate_inst(uint32_t address, z80_context * context, uint8_t * o z80_map_native_address(context, address, start, after-inst, ZMAX_NATIVE_SIZE); code_info tmp_code = {orig_start, orig_start + 16}; jmp(&tmp_code, start); + tmp_code = *code; + code->cur = start + ZMAX_NATIVE_SIZE; if (!z80_is_terminal(&instbuf)) { - jmp(code, z80_get_native_address_trans(context, address + after-inst)); + jmp(&tmp_code, z80_get_native_address_trans(context, address + after-inst)); } - code->cur = start + ZMAX_NATIVE_SIZE; z80_handle_deferred(context); return start; } else { |