From a911249fbf0a2b43cc01d78083f490b5727b4af3 Mon Sep 17 00:00:00 2001 From: mooglyguy Date: Mon, 13 Nov 2017 19:02:42 +0100 Subject: e132x, looked at negs opcode, nw. --- src/devices/cpu/e132xs/e132xs.cpp | 37 ++-------- src/devices/cpu/e132xs/e132xs.h | 6 +- src/devices/cpu/e132xs/e132xsop.hxx | 135 +++++++++++++++++++++++++----------- 3 files changed, 101 insertions(+), 77 deletions(-) diff --git a/src/devices/cpu/e132xs/e132xs.cpp b/src/devices/cpu/e132xs/e132xs.cpp index 0dcc3945d93..4a0e9e07c34 100644 --- a/src/devices/cpu/e132xs/e132xs.cpp +++ b/src/devices/cpu/e132xs/e132xs.cpp @@ -1814,35 +1814,6 @@ void hyperstone_device::hyperstone_subs(regs_decode &decode) } } -void hyperstone_device::hyperstone_negs(regs_decode &decode) -{ - if (SRC_IS_SR) - SREG = GET_C; - - int64_t tmp = -(int64_t)((int32_t)(SREG)); - CHECK_VSUB(SREG,0,tmp); - -//#if SETCARRYS -// CHECK_C(tmp); -//#endif - - int32_t res = -(int32_t)(SREG); - - SET_DREG(res); - - SET_Z(res == 0 ? 1 : 0); - SET_N(SIGN_BIT(res)); - - - m_icount -= m_clock_cycles_1; - - if (GET_V && !SRC_IS_SR) //trap doesn't occur when source is SR - { - uint32_t addr = get_trap_addr(TRAPNO_RANGE_ERROR); - execute_exception(addr); - } -} - void hyperstone_device::hyperstone_sardi() { check_delay_PC(); @@ -2188,10 +2159,10 @@ void hyperstone_device::execute_run() case 0x59: hyperstone_neg_global_local(); break; case 0x5a: hyperstone_neg_local_global(); break; case 0x5b: hyperstone_neg_local_local(); break; - case 0x5c: op5c(); break; - case 0x5d: op5d(); break; - case 0x5e: op5e(); break; - case 0x5f: op5f(); break; + case 0x5c: hyperstone_negs_global_global(); break; + case 0x5d: hyperstone_negs_global_local(); break; + case 0x5e: hyperstone_negs_local_global(); break; + case 0x5f: hyperstone_negs_local_local(); break; case 0x60: hyperstone_cmpi_global_simm(); break; case 0x61: hyperstone_cmpi_global_limm(); break; case 0x62: hyperstone_cmpi_local_simm(); break; diff --git a/src/devices/cpu/e132xs/e132xs.h b/src/devices/cpu/e132xs/e132xs.h index 05793f4e1f2..1c59912a7fd 100644 --- a/src/devices/cpu/e132xs/e132xs.h +++ b/src/devices/cpu/e132xs/e132xs.h @@ -285,7 +285,10 @@ private: void hyperstone_neg_global_local(); void hyperstone_neg_local_global(); void hyperstone_neg_local_local(); - void hyperstone_negs(regs_decode &decode); + void hyperstone_negs_global_global(); + void hyperstone_negs_global_local(); + void hyperstone_negs_local_global(); + void hyperstone_negs_local_local(); void hyperstone_and_global_global(); void hyperstone_and_global_local(); void hyperstone_and_local_global(); @@ -462,7 +465,6 @@ private: void op2c(); void op2d(); void op2e(); void op2f(); // addc void op40(); void op41(); void op42(); void op43(); // subc void op4c(); void op4d(); void op4e(); void op4f(); // subs - void op5c(); void op5d(); void op5e(); void op5f(); // negs #if 0 void generate_op00(drcuml_block *block, compiler_state *compiler, const opcode_desc *desc); void generate_op01(drcuml_block *block, compiler_state *compiler, const opcode_desc *desc); diff --git a/src/devices/cpu/e132xs/e132xsop.hxx b/src/devices/cpu/e132xs/e132xsop.hxx index 57f4ad5e691..37788ae4536 100644 --- a/src/devices/cpu/e132xs/e132xsop.hxx +++ b/src/devices/cpu/e132xs/e132xsop.hxx @@ -2365,72 +2365,123 @@ void hyperstone_device::hyperstone_neg_local_local() m_icount -= m_clock_cycles_1; } -void hyperstone_device::op5c() +void hyperstone_device::hyperstone_negs_global_global() { - regs_decode decode; check_delay_PC(); - decode.src = SRC_CODE; - decode.dst = DST_CODE; - decode.src_is_local = 0; - SREG = m_global_regs[decode.src]; + const uint32_t src_code = SRC_CODE; + const int32_t sreg = (src_code == SR_REGISTER) ? (SR & C_MASK) : (int32_t)m_global_regs[src_code]; + const int64_t tmp = -(int64_t)sreg; - decode.dst_is_local = 0; - DREG = m_global_regs[decode.dst]; + SR &= ~(V_MASK | Z_MASK | N_MASK); + + if (tmp & sreg & 0x80000000) + SR |= V_MASK; + +//#if SETCARRYS +// CHECK_C(tmp); +//#endif + + const int32_t res = -sreg; + set_global_register(DST_CODE, res); + + if (res == 0) + SR |= Z_MASK; + SR |= SIGN_TO_N(res); - hyperstone_negs(decode); - printf("0x5c, negs global,global\n"); + m_icount -= m_clock_cycles_1; + + if (GET_V && src_code != SR_REGISTER) // trap doesn't occur when source is SR + execute_exception(get_trap_addr(TRAPNO_RANGE_ERROR)); } -void hyperstone_device::op5d() +void hyperstone_device::hyperstone_negs_global_local() { - regs_decode decode; check_delay_PC(); - decode.src = SRC_CODE; - decode.dst = DST_CODE; - decode.src_is_local = 1; - SREG = m_local_regs[(decode.src + GET_FP) & 0x3f]; + const int32_t sreg = (int32_t)m_local_regs[(SRC_CODE + GET_FP) & 0x3f]; + const int64_t tmp = -(int64_t)sreg; - decode.dst_is_local = 0; - DREG = m_global_regs[decode.dst]; + SR &= ~(V_MASK | Z_MASK | N_MASK); + + if (tmp & sreg & 0x80000000) + SR |= V_MASK; + +//#if SETCARRYS +// CHECK_C(tmp); +//#endif + + const int32_t res = -sreg; + set_global_register(DST_CODE, res); + + if (res == 0) + SR |= Z_MASK; + SR |= SIGN_TO_N(res); - hyperstone_negs(decode); - printf("0x5d, negs global,local\n"); + m_icount -= m_clock_cycles_1; + + if (GET_V) + execute_exception(get_trap_addr(TRAPNO_RANGE_ERROR)); } -void hyperstone_device::op5e() +void hyperstone_device::hyperstone_negs_local_global() { - regs_decode decode; check_delay_PC(); - decode.src = SRC_CODE; - decode.dst = DST_CODE; - decode.src_is_local = 0; - SREG = m_global_regs[decode.src]; + const uint32_t src_code = SRC_CODE; + const int32_t sreg = (src_code == SR_REGISTER) ? (SR & C_MASK) : (int32_t)m_global_regs[src_code]; + const int64_t tmp = -(int64_t)sreg; - decode.dst_is_local = 1; - DREG = m_local_regs[(decode.dst + GET_FP) & 0x3f]; /* registers offset by frame pointer */ + SR &= ~(V_MASK | Z_MASK | N_MASK); + + if (tmp & sreg & 0x80000000) + SR |= V_MASK; + +//#if SETCARRYS +// CHECK_C(tmp); +//#endif + + const int32_t res = -sreg; + m_local_regs[(DST_CODE + GET_FP) & 0x3f] = res; + + if (res == 0) + SR |= Z_MASK; + SR |= SIGN_TO_N(res); - hyperstone_negs(decode); - printf("0x5e, negs local,global"); + m_icount -= m_clock_cycles_1; + + if (GET_V && src_code != SR_REGISTER) // trap doesn't occur when source is SR + execute_exception(get_trap_addr(TRAPNO_RANGE_ERROR)); } -void hyperstone_device::op5f() +void hyperstone_device::hyperstone_negs_local_local() { - regs_decode decode; check_delay_PC(); - decode.src = SRC_CODE; - decode.dst = DST_CODE; - decode.src_is_local = 1; - SREG = m_local_regs[(decode.src + GET_FP) & 0x3f]; + const uint32_t fp = GET_FP; + const int32_t sreg = (int32_t)m_local_regs[(SRC_CODE + fp) & 0x3f]; + const int64_t tmp = -(int64_t)sreg; - decode.dst_is_local = 1; - DREG = m_local_regs[(decode.dst + GET_FP) & 0x3f]; /* registers offset by frame pointer */ + SR &= ~(V_MASK | Z_MASK | N_MASK); + + if (tmp & sreg & 0x80000000) + SR |= V_MASK; + +//#if SETCARRYS +// CHECK_C(tmp); +//#endif + + const int32_t res = -sreg; + m_local_regs[(DST_CODE + fp) & 0x3f] = res; + + if (res == 0) + SR |= Z_MASK; + SR |= SIGN_TO_N(res); - hyperstone_negs(decode); - printf("0x5f, negs local,local\n"); + m_icount -= m_clock_cycles_1; + + if (GET_V) + execute_exception(get_trap_addr(TRAPNO_RANGE_ERROR)); } @@ -6301,7 +6352,7 @@ void hyperstone_device::hypesrtone_ldwp_local_local() // post increment the destination register if it's different from the source one // (needed by Hidden Catch) - if (src_code != dst_code || (m_op & 0x100)) + if (src_code != dst_code) m_local_regs[dst_code] += 4; m_icount -= m_clock_cycles_1; @@ -6338,7 +6389,7 @@ void hyperstone_device::hyperstone_lddp_local_local() // post increment the destination register if it's different from the source one // and from the "next source" one - if (!(src_code == dst_code && (m_op & 0x100)) && !same_srcf_dst) + if (src_code != dst_code && !same_srcf_dst) { m_local_regs[dst_code] += 8; } -- cgit v1.2.3