comparison m68k_core_x86.c @ 1192:e0fc8967d380

Inefficient fix for overlapping instruction problem that was causing issues with Outrunners
author Michael Pavone <pavone@retrodev.com>
date Tue, 24 Jan 2017 00:15:27 -0800
parents 8f14767661fa
children 0649cd8ca097
comparison
equal deleted inserted replaced
1191:8dc50e50ced6 1192:e0fc8967d380
2261 } else { 2261 } else {
2262 jmp(code, next_inst); 2262 jmp(code, next_inst);
2263 } 2263 }
2264 } 2264 }
2265 2265
2266 #define M68K_MAX_INST_SIZE (2*(1+2+2))
2267
2266 m68k_context * m68k_handle_code_write(uint32_t address, m68k_context * context) 2268 m68k_context * m68k_handle_code_write(uint32_t address, m68k_context * context)
2267 { 2269 {
2268 m68k_options * options = context->options; 2270 m68k_options * options = context->options;
2269 uint32_t inst_start = get_instruction_start(options, address); 2271 uint32_t inst_start = get_instruction_start(options, address);
2270 if (inst_start) { 2272 while (inst_start && (address - inst_start) < M68K_MAX_INST_SIZE) {
2271 code_info *code = &options->gen.code; 2273 code_info *code = &options->gen.code;
2272 code_ptr dst = get_native_address(context->options, inst_start); 2274 code_ptr dst = get_native_address(context->options, inst_start);
2273 code_info orig = {dst, dst + 128, 0}; 2275 code_info orig = {dst, dst + 128, 0};
2274 mov_ir(&orig, inst_start, options->gen.scratch2, SZ_D); 2276 mov_ir(&orig, inst_start, options->gen.scratch2, SZ_D);
2275 2277
2282 mov_rr(code, RAX, options->gen.scratch1, SZ_PTR); 2284 mov_rr(code, RAX, options->gen.scratch1, SZ_PTR);
2283 call(code, options->gen.load_context); 2285 call(code, options->gen.load_context);
2284 jmp_r(code, options->gen.scratch1); 2286 jmp_r(code, options->gen.scratch1);
2285 } 2287 }
2286 jmp(&orig, options->retrans_stub); 2288 jmp(&orig, options->retrans_stub);
2289 inst_start = get_instruction_start(options, inst_start - 2);
2287 } 2290 }
2288 return context; 2291 return context;
2289 } 2292 }
2290 2293
2291 void insert_breakpoint(m68k_context * context, uint32_t address, m68k_debug_handler bp_handler) 2294 void insert_breakpoint(m68k_context * context, uint32_t address, m68k_debug_handler bp_handler)