Mercurial > repos > blastem
comparison m68k_to_x86.c @ 543:915a1cb98bac
Generate retrans_stub at runtime so it can use the generated save/load_context functions
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 16 Feb 2014 18:17:59 -0800 |
parents | 5d57fd8b44f8 |
children | 8a26567852b7 |
comparison
equal
deleted
inserted
replaced
542:5d57fd8b44f8 | 543:915a1cb98bac |
---|---|
32 | 32 |
33 void handle_cycle_limit(); | 33 void handle_cycle_limit(); |
34 void m68k_native_addr(); | 34 void m68k_native_addr(); |
35 void m68k_native_addr_and_sync(); | 35 void m68k_native_addr_and_sync(); |
36 void m68k_invalid(); | 36 void m68k_invalid(); |
37 void m68k_retrans_stub(); | |
38 void set_sr(); | 37 void set_sr(); |
39 void set_ccr(); | 38 void set_ccr(); |
40 void get_sr(); | 39 void get_sr(); |
41 void do_sync(); | 40 void do_sync(); |
42 void bcd_add(); | 41 void bcd_add(); |
4014 { | 4013 { |
4015 uint32_t inst_start = get_instruction_start(context->native_code_map, address | 0xFF0000); | 4014 uint32_t inst_start = get_instruction_start(context->native_code_map, address | 0xFF0000); |
4016 if (inst_start) { | 4015 if (inst_start) { |
4017 uint8_t * dst = get_native_address(context->native_code_map, inst_start); | 4016 uint8_t * dst = get_native_address(context->native_code_map, inst_start); |
4018 dst = mov_ir(dst, inst_start, SCRATCH2, SZ_D); | 4017 dst = mov_ir(dst, inst_start, SCRATCH2, SZ_D); |
4019 dst = jmp(dst, (uint8_t *)m68k_retrans_stub); | 4018 x86_68k_options * options = context->options; |
4019 if (!options->retrans_stub) { | |
4020 if (options->code_end - options->cur_code < 32) { | |
4021 size_t size = 1024*1024; | |
4022 options->cur_code = alloc_code(&size); | |
4023 options->code_end = options->cur_code + size; | |
4024 } | |
4025 uint8_t * rdst = options->retrans_stub = options->cur_code; | |
4026 rdst = call(rdst, options->save_context); | |
4027 rdst = push_r(rdst, CONTEXT); | |
4028 rdst = call(rdst, (uint8_t *)m68k_retranslate_inst); | |
4029 rdst = pop_r(rdst, CONTEXT); | |
4030 rdst = mov_rr(rdst, RAX, SCRATCH1, SZ_Q); | |
4031 rdst = call(rdst, options->load_context); | |
4032 rdst = jmp_r(rdst, SCRATCH1); | |
4033 options->cur_code = rdst; | |
4034 } | |
4035 dst = jmp(dst, options->retrans_stub); | |
4020 } | 4036 } |
4021 return context; | 4037 return context; |
4022 } | 4038 } |
4023 | 4039 |
4024 void insert_breakpoint(m68k_context * context, uint32_t address, uint8_t * bp_handler) | 4040 void insert_breakpoint(m68k_context * context, uint32_t address, uint8_t * bp_handler) |