comparison z80_to_x86.c @ 898:2f1157f00dc6

Z80 core is now slightly less broken
author Michael Pavone <pavone@retrodev.com>
date Thu, 26 Nov 2015 00:10:36 -0800
parents 13388ab6d78a
children 07bfbbbb4b2e
comparison
equal deleted inserted replaced
897:b9564fb88a5a 898:2f1157f00dc6
2387 tmp_stack_off = code->stack_off; 2387 tmp_stack_off = code->stack_off;
2388 pop_r(code, RAX); //return address in read/write func 2388 pop_r(code, RAX); //return address in read/write func
2389 add_ir(code, 16-sizeof(void *), RSP, SZ_PTR); 2389 add_ir(code, 16-sizeof(void *), RSP, SZ_PTR);
2390 pop_r(code, RBX); //return address in translated code 2390 pop_r(code, RBX); //return address in translated code
2391 add_ir(code, 16-sizeof(void *), RSP, SZ_PTR); 2391 add_ir(code, 16-sizeof(void *), RSP, SZ_PTR);
2392 sub_ir(code, 5, RAX, SZ_PTR); //adjust return address to point to the call that got us here 2392 //FIXME: get the right adjustment value for 32-bit
2393 sub_ir(code, 9, RAX, SZ_PTR); //adjust return address to point to the call + stack adjust that got us here
2393 mov_rrdisp(code, RBX, options->gen.context_reg, offsetof(z80_context, extra_pc), SZ_PTR); 2394 mov_rrdisp(code, RBX, options->gen.context_reg, offsetof(z80_context, extra_pc), SZ_PTR);
2394 mov_rrind(code, RAX, options->gen.context_reg, SZ_PTR); 2395 mov_rrind(code, RAX, options->gen.context_reg, SZ_PTR);
2395 restore_callee_save_regs(code); 2396 restore_callee_save_regs(code);
2396 *no_sync = code->cur - (no_sync + 1); 2397 *no_sync = code->cur - (no_sync + 1);
2397 //return to caller of z80_run 2398 //return to caller of z80_run
2411 mov_rrdisp(code, options->gen.scratch1, options->gen.context_reg, offsetof(z80_context, pc), SZ_D); 2412 mov_rrdisp(code, options->gen.scratch1, options->gen.context_reg, offsetof(z80_context, pc), SZ_D);
2412 options->do_sync = code->cur; 2413 options->do_sync = code->cur;
2413 call(code, options->gen.save_context); 2414 call(code, options->gen.save_context);
2414 tmp_stack_off = code->stack_off; 2415 tmp_stack_off = code->stack_off;
2415 //pop return address off the stack and save for resume later 2416 //pop return address off the stack and save for resume later
2416 pop_rind(code, options->gen.context_reg); 2417 //pop_rind(code, options->gen.context_reg);
2418 pop_r(code, RAX);
2419 //FIXME: get appropriate size for 32-bit
2420 add_ir(code, 4, RAX, SZ_PTR);
2417 add_ir(code, 16-sizeof(void *), RSP, SZ_PTR); 2421 add_ir(code, 16-sizeof(void *), RSP, SZ_PTR);
2422 mov_rrind(code, RAX, options->gen.context_reg, SZ_PTR);
2423
2418 //restore callee saved registers 2424 //restore callee saved registers
2419 restore_callee_save_regs(code); 2425 restore_callee_save_regs(code);
2420 //return to caller of z80_run 2426 //return to caller of z80_run
2421 *skip_sync = code->cur - (skip_sync+1); 2427 *skip_sync = code->cur - (skip_sync+1);
2422 retn(code); 2428 retn(code);
2554 #endif 2560 #endif
2555 call(code, options->load_context_scratch); 2561 call(code, options->load_context_scratch);
2556 cmp_irdisp(code, 0, options->gen.context_reg, offsetof(z80_context, extra_pc), SZ_PTR); 2562 cmp_irdisp(code, 0, options->gen.context_reg, offsetof(z80_context, extra_pc), SZ_PTR);
2557 code_ptr no_extra = code->cur+1; 2563 code_ptr no_extra = code->cur+1;
2558 jcc(code, CC_Z, no_extra); 2564 jcc(code, CC_Z, no_extra);
2565 sub_ir(code, 16-sizeof(void *), RSP, SZ_PTR);
2559 push_rdisp(code, options->gen.context_reg, offsetof(z80_context, extra_pc)); 2566 push_rdisp(code, options->gen.context_reg, offsetof(z80_context, extra_pc));
2560 mov_irdisp(code, 0, options->gen.context_reg, offsetof(z80_context, extra_pc), SZ_PTR); 2567 mov_irdisp(code, 0, options->gen.context_reg, offsetof(z80_context, extra_pc), SZ_PTR);
2561 *no_extra = code->cur - (no_extra + 1); 2568 *no_extra = code->cur - (no_extra + 1);
2562 jmp_rind(code, options->gen.context_reg); 2569 jmp_rind(code, options->gen.context_reg);
2563 code->stack_off = tmp_stack_off; 2570 code->stack_off = tmp_stack_off;