changeset 2330:959a3e9aaac5

Fix M68K STOP instruction for sub CPU
author Michael Pavone <pavone@retrodev.com>
date Wed, 23 Aug 2023 22:09:35 -0700
parents 06d5e9b08bdb
children f500831f7fb4
files m68k_core_x86.c
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/m68k_core_x86.c	Wed Aug 23 21:38:39 2023 -0700
+++ b/m68k_core_x86.c	Wed Aug 23 22:09:35 2023 -0700
@@ -2372,6 +2372,12 @@
 	}
 	code_ptr loop_top = code->cur;
 		call(code, opts->do_sync);
+		cmp_irdisp(code, 0, opts->gen.context_reg, offsetof(m68k_context, should_return), SZ_B);
+		code_ptr no_return = code->cur + 1;
+		jcc(code, CC_Z, no_return);
+		mov_irdisp(code, (intptr_t)loop_top, opts->gen.context_reg, offsetof(m68k_context, resume_pc), SZ_PTR);
+		retn(code);
+		*no_return = code->cur - (no_return+1);
 		cmp_rr(code, opts->gen.cycles, opts->gen.limit, SZ_D);
 		code_ptr normal_cycle_up = code->cur + 1;
 		jcc(code, CC_A, code->cur + 2);