comparison z80_to_x86.c @ 597:8d6ae5b3b87b

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
author Michael Pavone <pavone@retrodev.com>
date Fri, 26 Dec 2014 12:52:13 -0800
parents 086de8692932
children faad1927d836
comparison
equal deleted inserted replaced
596:9853bcce4729 597:8d6ae5b3b87b
1777 } else { 1777 } else {
1778 printf("%X\t%s\n", address, disbuf); 1778 printf("%X\t%s\n", address, disbuf);
1779 } 1779 }
1780 #endif 1780 #endif
1781 if (orig_size != ZMAX_NATIVE_SIZE) { 1781 if (orig_size != ZMAX_NATIVE_SIZE) {
1782 check_alloc_code(code, ZMAX_NATIVE_SIZE);
1782 code_ptr start = code->cur; 1783 code_ptr start = code->cur;
1783 deferred_addr * orig_deferred = opts->gen.deferred; 1784 deferred_addr * orig_deferred = opts->gen.deferred;
1784 translate_z80inst(&instbuf, context, address); 1785 translate_z80inst(&instbuf, context, address);
1785 /* 1786 /*
1786 if ((native_end - dst) <= orig_size) { 1787 if ((native_end - dst) <= orig_size) {
1800 } 1801 }
1801 }*/ 1802 }*/
1802 z80_map_native_address(context, address, start, after-inst, ZMAX_NATIVE_SIZE); 1803 z80_map_native_address(context, address, start, after-inst, ZMAX_NATIVE_SIZE);
1803 code_info tmp_code = {orig_start, orig_start + 16}; 1804 code_info tmp_code = {orig_start, orig_start + 16};
1804 jmp(&tmp_code, start); 1805 jmp(&tmp_code, start);
1806 tmp_code = *code;
1807 code->cur = start + ZMAX_NATIVE_SIZE;
1805 if (!z80_is_terminal(&instbuf)) { 1808 if (!z80_is_terminal(&instbuf)) {
1806 jmp(code, z80_get_native_address_trans(context, address + after-inst)); 1809 jmp(&tmp_code, z80_get_native_address_trans(context, address + after-inst));
1807 } 1810 }
1808 code->cur = start + ZMAX_NATIVE_SIZE;
1809 z80_handle_deferred(context); 1811 z80_handle_deferred(context);
1810 return start; 1812 return start;
1811 } else { 1813 } else {
1812 code_info tmp_code = *code; 1814 code_info tmp_code = *code;
1813 code->cur = orig_start; 1815 code->cur = orig_start;