comparison m68k_to_x86.c @ 540:4ca826862174

Generate m68k_start_context at runtime so it can use the generated load_context and save_context
author Michael Pavone <pavone@retrodev.com>
date Sat, 15 Feb 2014 21:25:36 -0800
parents c2716b502a81
children a59ac6b4b5b5
comparison
equal deleted inserted replaced
539:c2716b502a81 540:4ca826862174
40 void set_ccr(); 40 void set_ccr();
41 void get_sr(); 41 void get_sr();
42 void do_sync(); 42 void do_sync();
43 void bcd_add(); 43 void bcd_add();
44 void bcd_sub(); 44 void bcd_sub();
45 void m68k_start_context(uint8_t * addr, m68k_context * context);
46 void debug_print_sr(); 45 void debug_print_sr();
47 46
48 uint8_t * cycles(uint8_t * dst, uint32_t num) 47 uint8_t * cycles(uint8_t * dst, uint32_t num)
49 { 48 {
50 dst = add_ir(dst, num, CYCLES, SZ_D); 49 dst = add_ir(dst, num, CYCLES, SZ_D);
4166 } 4165 }
4167 4166
4168 void start_68k_context(m68k_context * context, uint32_t address) 4167 void start_68k_context(m68k_context * context, uint32_t address)
4169 { 4168 {
4170 uint8_t * addr = get_native_address_trans(context, address); 4169 uint8_t * addr = get_native_address_trans(context, address);
4171 m68k_start_context(addr, context); 4170 x86_68k_options * options = context->options;
4171 options->start_context(addr, context);
4172 } 4172 }
4173 4173
4174 void m68k_reset(m68k_context * context) 4174 void m68k_reset(m68k_context * context)
4175 { 4175 {
4176 //TODO: Make this actually use the normal read functions 4176 //TODO: Make this actually use the normal read functions
4452 dst = mov_rdisp8r(dst, CONTEXT, offsetof(m68k_context, aregs) + sizeof(uint32_t) * i, opts->aregs[i], SZ_D); 4452 dst = mov_rdisp8r(dst, CONTEXT, offsetof(m68k_context, aregs) + sizeof(uint32_t) * i, opts->aregs[i], SZ_D);
4453 } 4453 }
4454 } 4454 }
4455 dst = mov_rdisp8r(dst, CONTEXT, offsetof(m68k_context, current_cycle), CYCLES, SZ_D); 4455 dst = mov_rdisp8r(dst, CONTEXT, offsetof(m68k_context, current_cycle), CYCLES, SZ_D);
4456 dst = mov_rdisp8r(dst, CONTEXT, offsetof(m68k_context, target_cycle), LIMIT, SZ_D); 4456 dst = mov_rdisp8r(dst, CONTEXT, offsetof(m68k_context, target_cycle), LIMIT, SZ_D);
4457 dst = retn(dst);
4458
4459 opts->start_context = (start_fun)dst;
4460 dst = push_r(dst, RBP);
4461 dst = push_r(dst, R12);
4462 dst = push_r(dst, R13);
4463 dst = push_r(dst, R14);
4464 dst = push_r(dst, R15);
4465 dst = call(dst, opts->load_context);
4466 dst = call_r(dst, RDI);
4467 dst = call(dst, opts->save_context);
4468 dst = pop_r(dst, R15);
4469 dst = pop_r(dst, R14);
4470 dst = pop_r(dst, R13);
4471 dst = pop_r(dst, R12);
4472 dst = pop_r(dst, RBP);
4457 dst = retn(dst); 4473 dst = retn(dst);
4458 4474
4459 opts->cur_code = dst; 4475 opts->cur_code = dst;
4460 4476
4461 opts->read_16 = gen_mem_fun(opts, memmap, num_chunks, READ_16); 4477 opts->read_16 = gen_mem_fun(opts, memmap, num_chunks, READ_16);