summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2015-10-29 19:06:06 -0700
committerMichael Pavone <pavone@retrodev.com>2015-10-29 19:06:06 -0700
commita1f73f4ae60d0d2cff6e8619417c15c97460239b (patch)
tree1f2c087036ad375e6cf75b735936c17ddd4df97d
parent3a8f89cb47c0715d091dde6e317cebf9a4796778 (diff)
Implement TRAPV
-rw-r--r--m68k_core.c4
-rw-r--r--m68k_core_x86.c13
-rw-r--r--m68k_internal.h1
3 files changed, 15 insertions, 3 deletions
diff --git a/m68k_core.c b/m68k_core.c
index 490fcec..02463c9 100644
--- a/m68k_core.c
+++ b/m68k_core.c
@@ -790,6 +790,7 @@ impl_info m68k_impls[] = {
//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 @@ impl_info m68k_impls[] = {
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)
diff --git a/m68k_core_x86.c b/m68k_core_x86.c
index f23c51d..fff5855 100644
--- a/m68k_core_x86.c
+++ b/m68k_core_x86.c
@@ -2116,6 +2116,19 @@ void translate_m68k_stop(m68k_options *opts, m68kinst *inst)
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;
diff --git a/m68k_internal.h b/m68k_internal.h
index b0c162e..a70da23 100644
--- a/m68k_internal.h
+++ b/m68k_internal.h
@@ -60,6 +60,7 @@ void translate_m68k_scc(m68k_options * opts, m68kinst * inst);
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);