changeset 663:7a5461001242

Sync Z80 when taking an interrupt so that int_cycle gets updated
author Michael Pavone <pavone@retrodev.com>
date Fri, 02 Jan 2015 00:19:10 -0800
parents 66388360f873
children bca748422bf0
files z80_to_x86.c
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/z80_to_x86.c	Thu Jan 01 23:37:24 2015 -0800
+++ b/z80_to_x86.c	Fri Jan 02 00:19:10 2015 -0800
@@ -2103,7 +2103,16 @@
 	//TODO: Support interrupt mode 0 and 2
 	mov_ir(code, 0x38, options->gen.scratch1, SZ_W);
 	call(code, options->native_addr);
-	jmp_r(code, options->gen.scratch1);
+	mov_rrind(code, options->gen.scratch1, options->gen.context_reg, SZ_PTR);
+	//restore callee saved registers
+	pop_r(code, R15);
+	pop_r(code, R14);
+	pop_r(code, R13);
+	pop_r(code, R12);
+	pop_r(code, RBP);
+	pop_r(code, RBX);
+	//return to caller of z80_run to sync
+	retn(code);
 	*skip_int = code->cur - (skip_int+1);
 	cmp_rdispr(code, options->gen.context_reg, offsetof(z80_context, sync_cycle), options->gen.cycles, SZ_D);
 	code_ptr skip_sync = code->cur + 1;