# HG changeset patch # User Michael Pavone # Date 1419627133 28800 # Node ID 8d6ae5b3b87b96b9092ea23e342bf9237586e907 # Parent 9853bcce4729838306526b5d814652c85072056c 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 diff -r 9853bcce4729 -r 8d6ae5b3b87b z80_to_x86.c --- a/z80_to_x86.c Fri Dec 26 12:37:27 2014 -0800 +++ b/z80_to_x86.c Fri Dec 26 12:52:13 2014 -0800 @@ -1779,6 +1779,7 @@ } #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 @@ 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 {