changeset 839:4556818b6847

Implement TRAPV
author Michael Pavone <pavone@retrodev.com>
date Thu, 29 Oct 2015 19:06:06 -0700
parents 9a5dc22297f2
children 5822c6e5642f
files m68k_core.c m68k_core_x86.c m68k_internal.h
diffstat 3 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/m68k_core.c	Thu Oct 29 01:06:48 2015 -0700
+++ b/m68k_core.c	Thu Oct 29 19:06:06 2015 -0700
@@ -790,6 +790,7 @@
 	//traps
 	OP_IMPL(M68K_CHK, translate_m68k_chk),
 	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),
 
@@ -797,9 +798,6 @@
 	RAW_IMPL(M68K_NOP, translate_m68k_nop),
 	RAW_IMPL(M68K_RESET, translate_m68k_reset),
 	RAW_IMPL(M68K_TAS, translate_m68k_tas),
-
-	//currently unimplemented
-	//M68K_TRAPV
 };
 
 void translate_m68k(m68k_options * opts, m68kinst * inst)
--- a/m68k_core_x86.c	Thu Oct 29 01:06:48 2015 -0700
+++ b/m68k_core_x86.c	Thu Oct 29 19:06:06 2015 -0700
@@ -2116,6 +2116,19 @@
 	jcc(code, CC_C, loop_top);
 }
 
+void translate_m68k_trapv(m68k_options *opts, m68kinst *inst)
+{
+	code_info *code = &opts->gen.code;
+	cycles(&opts->gen, BUS);
+	flag_to_carry(opts, FLAG_V);
+	code_ptr no_trap = code->cur + 1;
+	jcc(code, CC_NC, no_trap);
+	ldi_native(opts, VECTOR_TRAPV, opts->gen.scratch2);
+	ldi_native(opts, inst->address+2, opts->gen.scratch1);
+	jmp(code, opts->trap);
+	*no_trap = code->cur - (no_trap + 1);
+}
+
 void translate_m68k_move_from_sr(m68k_options *opts, m68kinst *inst, host_ea *src_op, host_ea *dst_op)
 {
 	code_info *code = &opts->gen.code;
--- a/m68k_internal.h	Thu Oct 29 01:06:48 2015 -0700
+++ b/m68k_internal.h	Thu Oct 29 19:06:06 2015 -0700
@@ -60,6 +60,7 @@
 void translate_m68k_dbcc(m68k_options * opts, m68kinst * inst);
 void translate_m68k_rtr(m68k_options *opts, m68kinst * inst);
 void translate_m68k_trap(m68k_options *opts, m68kinst *inst);
+void translate_m68k_trapv(m68k_options *opts, m68kinst *inst);
 void translate_m68k_move(m68k_options * opts, m68kinst * inst);
 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);