changeset 986:f680fe746a7d

Implement illegal instruction trap
author Michael Pavone <pavone@retrodev.com>
date Tue, 26 Apr 2016 00:07:15 -0700
parents 751280fb4494
children 1f09994e92c5
files m68k_core.c m68k_core_x86.c m68k_internal.h
diffstat 3 files changed, 10 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/m68k_core.c	Sun Apr 24 21:23:28 2016 -0700
+++ b/m68k_core.c	Tue Apr 26 00:07:15 2016 -0700
@@ -339,6 +339,15 @@
 	jmp(code, opts->trap);
 }
 
+void translate_m68k_illegal(m68k_options *opts, m68kinst *inst)
+{
+	code_info *code = &opts->gen.code;
+	cycles(&opts->gen, BUS);
+	ldi_native(opts, VECTOR_ILLEGAL_INST, opts->gen.scratch2);
+	ldi_native(opts, inst->address, opts->gen.scratch1);
+	jmp(code, opts->trap);
+}
+
 void translate_m68k_move_usp(m68k_options *opts, m68kinst *inst)
 {
 	cycles(&opts->gen, BUS);
@@ -800,7 +809,7 @@
 	RAW_IMPL(M68K_TRAP, translate_m68k_trap),
 	RAW_IMPL(M68K_TRAPV, translate_m68k_trapv),
 	RAW_IMPL(M68K_ILLEGAL, translate_m68k_illegal),
-	RAW_IMPL(M68K_INVALID, translate_m68k_invalid),
+	RAW_IMPL(M68K_INVALID, translate_m68k_illegal),
 
 	//misc
 	RAW_IMPL(M68K_NOP, translate_m68k_nop),
--- a/m68k_core_x86.c	Sun Apr 24 21:23:28 2016 -0700
+++ b/m68k_core_x86.c	Tue Apr 26 00:07:15 2016 -0700
@@ -1388,21 +1388,6 @@
 	m68k_save_result(inst, opts);
 }
 
-void translate_m68k_invalid(m68k_options *opts, m68kinst *inst)
-{
-	code_info *code = &opts->gen.code;
-	if (inst->src.params.immed == 0x7100) {
-		retn(code);
-		return;
-	}
-	mov_ir(code, (int64_t)stderr, RDI, SZ_PTR);
-	mov_ir(code, (int64_t)"Invalid instruction at %X\n", RSI, SZ_PTR);
-	mov_ir(code, inst->address, RDX, SZ_D);
-	call_args_abi(code, (code_ptr)fprintf, 3, RDI, RSI, RDX);
-	mov_ir(code, 1, RDI, SZ_D);
-	call_args(code, (code_ptr)exit, 1, RDI);
-}
-
 void translate_m68k_abcd_sbcd(m68k_options *opts, m68kinst *inst, host_ea *src_op, host_ea *dst_op)
 {
 	code_info *code = &opts->gen.code;
@@ -1983,13 +1968,6 @@
 	}
 }
 
-void translate_m68k_illegal(m68k_options *opts, m68kinst *inst)
-{
-	code_info *code = &opts->gen.code;
-	call(code, opts->gen.save_context);
-	call_args(code, (code_ptr)print_regs_exit, 1, opts->gen.context_reg);
-}
-
 #define BIT_SUPERVISOR 5
 
 void translate_m68k_andi_ori_ccr_sr(m68k_options *opts, m68kinst *inst)
--- a/m68k_internal.h	Sun Apr 24 21:23:28 2016 -0700
+++ b/m68k_internal.h	Tue Apr 26 00:07:15 2016 -0700
@@ -66,7 +66,6 @@
 void translate_m68k_movep(m68k_options * opts, m68kinst * inst);
 void translate_m68k_arith(m68k_options *opts, m68kinst * inst, uint32_t flag_mask, host_ea *src_op, host_ea *dst_op);
 void translate_m68k_unary(m68k_options *opts, m68kinst *inst, uint32_t flag_mask, host_ea *dst_op);
-void translate_m68k_invalid(m68k_options *opts, m68kinst *inst);
 void translate_m68k_cmp(m68k_options * opts, m68kinst * inst);
 void translate_m68k_tas(m68k_options * opts, m68kinst * inst);
 void translate_m68k_clr(m68k_options * opts, m68kinst * inst);
@@ -82,7 +81,6 @@
 void translate_m68k_mul(m68k_options *opts, m68kinst *inst, host_ea *src_op, host_ea *dst_op);
 void translate_m68k_negx(m68k_options *opts, m68kinst *inst, host_ea *src_op, host_ea *dst_op);
 void translate_m68k_rot(m68k_options *opts, m68kinst *inst, host_ea *src_op, host_ea *dst_op);
-void translate_m68k_illegal(m68k_options *opts, m68kinst *inst);
 void translate_m68k_andi_ori_ccr_sr(m68k_options *opts, m68kinst *inst);
 void translate_m68k_eori_ccr_sr(m68k_options *opts, m68kinst *inst);
 void translate_m68k_move_ccr_sr(m68k_options *opts, m68kinst *inst, host_ea *src_op, host_ea *dst_op);