Mercurial > repos > blastem
comparison m68k_core_x86.c @ 726:7367b14ac01c
Don't attempt to translate or map code at odd addresses. This fixes a bug that shows up when playing College Footbal USA 96
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 22 May 2015 23:49:32 -0700 |
parents | 0a86e81fa87d |
children | 59a98179d3ba |
comparison
equal
deleted
inserted
replaced
725:a92ca6f0ed83 | 726:7367b14ac01c |
---|---|
799 int32_t disp = inst->src.params.immed; | 799 int32_t disp = inst->src.params.immed; |
800 uint32_t after = inst->address + 2; | 800 uint32_t after = inst->address + 2; |
801 if (inst->extra.cond == COND_TRUE) { | 801 if (inst->extra.cond == COND_TRUE) { |
802 jump_m68k_abs(opts, after + disp); | 802 jump_m68k_abs(opts, after + disp); |
803 } else { | 803 } else { |
804 code_ptr dest_addr = get_native_address(opts->gen.native_code_map, after + disp); | 804 code_ptr dest_addr = get_native_address(opts, after + disp); |
805 uint8_t cond = m68k_eval_cond(opts, inst->extra.cond); | 805 uint8_t cond = m68k_eval_cond(opts, inst->extra.cond); |
806 if (!dest_addr) { | 806 if (!dest_addr) { |
807 opts->gen.deferred = defer_address(opts->gen.deferred, after + disp, code->cur + 2); | 807 opts->gen.deferred = defer_address(opts->gen.deferred, after + disp, code->cur + 2); |
808 //dummy address to be replaced later, make sure it generates a 4-byte displacement | 808 //dummy address to be replaced later, make sure it generates a 4-byte displacement |
809 dest_addr = code->cur + 256; | 809 dest_addr = code->cur + 256; |
2087 { | 2087 { |
2088 uint32_t inst_start = get_instruction_start(context->native_code_map, address | 0xFF0000); | 2088 uint32_t inst_start = get_instruction_start(context->native_code_map, address | 0xFF0000); |
2089 if (inst_start) { | 2089 if (inst_start) { |
2090 m68k_options * options = context->options; | 2090 m68k_options * options = context->options; |
2091 code_info *code = &options->gen.code; | 2091 code_info *code = &options->gen.code; |
2092 code_ptr dst = get_native_address(context->native_code_map, inst_start); | 2092 code_ptr dst = get_native_address(context->options, inst_start); |
2093 code_info orig; | 2093 code_info orig; |
2094 orig.cur = dst; | 2094 orig.cur = dst; |
2095 orig.last = dst + 128; | 2095 orig.last = dst + 128; |
2096 mov_ir(&orig, inst_start, options->gen.scratch2, SZ_D); | 2096 mov_ir(&orig, inst_start, options->gen.scratch2, SZ_D); |
2097 | 2097 |
2473 shl_ir(code, 2, opts->gen.scratch1, SZ_D); | 2473 shl_ir(code, 2, opts->gen.scratch1, SZ_D); |
2474 call(code, opts->read_32); | 2474 call(code, opts->read_32); |
2475 call(code, opts->native_addr_and_sync); | 2475 call(code, opts->native_addr_and_sync); |
2476 cycles(&opts->gen, 18); | 2476 cycles(&opts->gen, 18); |
2477 jmp_r(code, opts->gen.scratch1); | 2477 jmp_r(code, opts->gen.scratch1); |
2478 } | 2478 |
2479 opts->odd_address = code->cur; | |
2480 mov_ir(code, (int64_t)stderr, RDI, SZ_PTR); | |
2481 mov_ir(code, (int64_t)"Attempt to execute code at odd address\n", RSI, SZ_PTR); | |
2482 call_args_abi(code, (code_ptr)fprintf, 2, RDI, RSI, RDX); | |
2483 xor_rr(code, RDI, RDI, SZ_D); | |
2484 call_args(code, (code_ptr)exit, 1, RDI); | |
2485 } |