summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2017-11-15 13:54:50 +1100
committer Vas Crabb <vas@vastheman.com>2017-11-15 13:54:50 +1100
commiteff0a95e89a2ce322be6cdf43ae0c3c02f2db9ae (patch)
treea4284922ce3279173196e07fa4ac17a3566cf860
parent487382c15fc0457c44b2e15c9494894cf9ec75f8 (diff)
hyperstone: template check, index move, mask and sum handlers
(nw) couple of fixes - sum Rd,C,const was incorrectly using the whole SR rather than just the carry value; sums with local register as destination was not burning cycles; negs doesn't need explicit guard against trapping when source is SR as carry flag alone can never cause an overflow
-rw-r--r--src/devices/cpu/e132xs/e132xs.cpp40
-rw-r--r--src/devices/cpu/e132xs/e132xs.h25
-rw-r--r--src/devices/cpu/e132xs/e132xsop.hxx504
3 files changed, 80 insertions, 489 deletions
diff --git a/src/devices/cpu/e132xs/e132xs.cpp b/src/devices/cpu/e132xs/e132xs.cpp
index a992e4e56f9..ca26f3dd67e 100644
--- a/src/devices/cpu/e132xs/e132xs.cpp
+++ b/src/devices/cpu/e132xs/e132xs.cpp
@@ -1634,10 +1634,10 @@ void hyperstone_device::execute_run()
switch ((OP >> 8) & 0x00ff)
{
- case 0x00: hyperstone_chk_global_global(); break;
- case 0x01: hyperstone_chk_global_local(); break;
- case 0x02: hyperstone_chk_local_global(); break;
- case 0x03: hyperstone_chk_local_local(); break;
+ case 0x00: hyperstone_chk<GLOBAL, GLOBAL>(); break;
+ case 0x01: hyperstone_chk<GLOBAL, LOCAL>(); break;
+ case 0x02: hyperstone_chk<LOCAL, GLOBAL>(); break;
+ case 0x03: hyperstone_chk<LOCAL, LOCAL>(); break;
case 0x04: hyperstone_movd_global_global(); break;
case 0x05: hyperstone_movd_global_local(); break;
case 0x06: hyperstone_movd_local_global(); break;
@@ -1650,22 +1650,22 @@ void hyperstone_device::execute_run()
case 0x0d: hyperstone_divs_global_local(); break;
case 0x0e: hyperstone_divs_local_global(); break;
case 0x0f: hyperstone_divs_local_local(); break;
- case 0x10: hyperstone_xm_global_global(); break;
- case 0x11: hyperstone_xm_global_local(); break;
- case 0x12: hyperstone_xm_local_global(); break;
- case 0x13: hyperstone_xm_local_local(); break;
- case 0x14: hyperstone_mask_global_global(); break;
- case 0x15: hyperstone_mask_global_local(); break;
- case 0x16: hyperstone_mask_local_global(); break;
- case 0x17: hyperstone_mask_local_local(); break;
- case 0x18: hyperstone_sum_global_global(); break;
- case 0x19: hyperstone_sum_global_local(); break;
- case 0x1a: hyperstone_sum_local_global(); break;
- case 0x1b: hyperstone_sum_local_local(); break;
- case 0x1c: hyperstone_sums_global_global(); break;
- case 0x1d: hyperstone_sums_global_local(); break;
- case 0x1e: hyperstone_sums_local_global(); break;
- case 0x1f: hyperstone_sums_local_local(); break;
+ case 0x10: hyperstone_xm<GLOBAL, GLOBAL>(); break;
+ case 0x11: hyperstone_xm<GLOBAL, LOCAL>(); break;
+ case 0x12: hyperstone_xm<LOCAL, GLOBAL>(); break;
+ case 0x13: hyperstone_xm<LOCAL, LOCAL>(); break;
+ case 0x14: hyperstone_mask<GLOBAL, GLOBAL>(); break;
+ case 0x15: hyperstone_mask<GLOBAL, LOCAL>(); break;
+ case 0x16: hyperstone_mask<LOCAL, GLOBAL>(); break;
+ case 0x17: hyperstone_mask<LOCAL, LOCAL>(); break;
+ case 0x18: hyperstone_sum<GLOBAL, GLOBAL>(); break;
+ case 0x19: hyperstone_sum<GLOBAL, LOCAL>(); break;
+ case 0x1a: hyperstone_sum<LOCAL, GLOBAL>(); break;
+ case 0x1b: hyperstone_sum<LOCAL, LOCAL>(); break;
+ case 0x1c: hyperstone_sums<GLOBAL, GLOBAL>(); break;
+ case 0x1d: hyperstone_sums<GLOBAL, LOCAL>(); break;
+ case 0x1e: hyperstone_sums<LOCAL, GLOBAL>(); break;
+ case 0x1f: hyperstone_sums<LOCAL, LOCAL>(); break;
case 0x20: hyperstone_cmp<GLOBAL, GLOBAL>(); break;
case 0x21: hyperstone_cmp<GLOBAL, LOCAL>(); break;
case 0x22: hyperstone_cmp<LOCAL, GLOBAL>(); break;
diff --git a/src/devices/cpu/e132xs/e132xs.h b/src/devices/cpu/e132xs/e132xs.h
index 08d69bd7f7b..792fa4b0439 100644
--- a/src/devices/cpu/e132xs/e132xs.h
+++ b/src/devices/cpu/e132xs/e132xs.h
@@ -208,10 +208,7 @@ private:
uint32_t decode_immediate_s();
uint32_t decode_const();
- void hyperstone_chk_global_global();
- void hyperstone_chk_global_local();
- void hyperstone_chk_local_global();
- void hyperstone_chk_local_local();
+ template <reg_bank DST_GLOBAL, reg_bank SRC_GLOBAL> void hyperstone_chk();
void hyperstone_movd_global_global();
void hyperstone_movd_global_local();
void hyperstone_movd_local_global();
@@ -224,22 +221,10 @@ private:
void hyperstone_divs_global_local();
void hyperstone_divs_local_global();
void hyperstone_divs_local_local();
- void hyperstone_xm_global_global();
- void hyperstone_xm_global_local();
- void hyperstone_xm_local_global();
- void hyperstone_xm_local_local();
- void hyperstone_mask_global_global();
- void hyperstone_mask_global_local();
- void hyperstone_mask_local_global();
- void hyperstone_mask_local_local();
- void hyperstone_sum_global_global();
- void hyperstone_sum_global_local();
- void hyperstone_sum_local_global();
- void hyperstone_sum_local_local();
- void hyperstone_sums_global_global();
- void hyperstone_sums_global_local();
- void hyperstone_sums_local_global();
- void hyperstone_sums_local_local();
+ template <reg_bank DST_GLOBAL, reg_bank SRC_GLOBAL> void hyperstone_xm();
+ template <reg_bank DST_GLOBAL, reg_bank SRC_GLOBAL> void hyperstone_mask();
+ template <reg_bank DST_GLOBAL, reg_bank SRC_GLOBAL> void hyperstone_sum();
+ template <reg_bank DST_GLOBAL, reg_bank SRC_GLOBAL> void hyperstone_sums();
template <reg_bank DST_GLOBAL, reg_bank SRC_GLOBAL> void hyperstone_cmp();
void hyperstone_mov_global_global();
void hyperstone_mov_global_local();
diff --git a/src/devices/cpu/e132xs/e132xsop.hxx b/src/devices/cpu/e132xs/e132xsop.hxx
index 5a8325ee371..ee454ee0e0a 100644
--- a/src/devices/cpu/e132xs/e132xsop.hxx
+++ b/src/devices/cpu/e132xs/e132xsop.hxx
@@ -1,87 +1,25 @@
// license:BSD-3-Clause
// copyright-holders:Pierpaolo Prazzoli
-void hyperstone_device::hyperstone_chk_global_global()
+template <hyperstone_device::reg_bank DST_GLOBAL, hyperstone_device::reg_bank SRC_GLOBAL>
+void hyperstone_device::hyperstone_chk()
{
check_delay_PC();
- const uint32_t src_code = SRC_CODE;
- const uint32_t dst_code = DST_CODE;
- const uint32_t dreg = m_global_regs[dst_code];
+ const uint32_t fp = GET_FP;
+ const uint32_t src_code = SRC_GLOBAL ? SRC_CODE : ((SRC_CODE + fp) & 0x3f);
+ const uint32_t dreg = DST_GLOBAL ? m_global_regs[DST_CODE] : m_local_regs[(DST_CODE + fp) & 0x3f];
- if (src_code == SR_REGISTER)
+ if (SRC_GLOBAL && (src_code == SR_REGISTER))
{
if (dreg == 0)
execute_exception(get_trap_addr(TRAPNO_RANGE_ERROR));
}
else
{
- const uint32_t sreg = m_global_regs[src_code];
- if (src_code == PC_REGISTER)
- {
- if (dreg >= sreg)
- execute_exception(get_trap_addr(TRAPNO_RANGE_ERROR));
- }
- else
- {
- if (dreg > sreg)
- execute_exception(get_trap_addr(TRAPNO_RANGE_ERROR));
- }
- }
-
- m_icount -= m_clock_cycles_1;
-}
-
-void hyperstone_device::hyperstone_chk_global_local()
-{
- check_delay_PC();
-
- const uint32_t sreg = m_local_regs[(SRC_CODE + GET_FP) & 0x3f];
- const uint32_t dreg = m_global_regs[DST_CODE];
- if (dreg > sreg)
- execute_exception(get_trap_addr(TRAPNO_RANGE_ERROR));
-
- m_icount -= m_clock_cycles_1;
-}
-
-void hyperstone_device::hyperstone_chk_local_global()
-{
- check_delay_PC();
-
- const uint32_t src_code = SRC_CODE;
- const uint32_t dreg = m_local_regs[(DST_CODE + GET_FP) & 0x3f];
-
- if (src_code == SR_REGISTER)
- {
- if (dreg == 0)
+ const uint32_t sreg = (SRC_GLOBAL ? m_global_regs : m_local_regs)[src_code];
+ if ((SRC_GLOBAL && (src_code == PC_REGISTER)) ? (dreg >= sreg) : (dreg > sreg))
execute_exception(get_trap_addr(TRAPNO_RANGE_ERROR));
}
- else
- {
- const uint32_t sreg = m_global_regs[src_code];
- if (src_code == PC_REGISTER)
- {
- if (dreg >= sreg)
- execute_exception(get_trap_addr(TRAPNO_RANGE_ERROR));
- }
- else
- {
- if (dreg > sreg)
- execute_exception(get_trap_addr(TRAPNO_RANGE_ERROR));
- }
- }
-
- m_icount -= m_clock_cycles_1;
-}
-
-void hyperstone_device::hyperstone_chk_local_local()
-{
- check_delay_PC();
-
- const uint32_t fp = GET_FP;
- const uint32_t sreg = m_local_regs[(SRC_CODE + fp) & 0x3f];
- const uint32_t dreg = m_local_regs[(DST_CODE + fp) & 0x3f];
- if (dreg > sreg)
- execute_exception(get_trap_addr(TRAPNO_RANGE_ERROR));
m_icount -= m_clock_cycles_1;
}
@@ -604,59 +542,8 @@ void hyperstone_device::hyperstone_divs_local_local()
-void hyperstone_device::hyperstone_xm_global_global()
-{
- const uint32_t next = READ_OP(PC);
- PC += 2;
-
- const uint8_t sub_type = (next & 0x7000) >> 12;
-
- uint32_t extra_u = next & 0xfff;
- if (next & 0x8000)
- {
- extra_u = ((extra_u & 0xfff) << 16) | READ_OP(PC);
- PC += 2;
- m_instruction_length = (3<<19);
- }
- else
- {
- m_instruction_length = (2<<19);
- }
-
- check_delay_PC();
-
- const uint32_t src_code = SRC_CODE;
- const uint32_t dst_code = DST_CODE;
-
- if (src_code == SR_REGISTER || dst_code < 2)
- {
- DEBUG_PRINTF(("Denoted PC or SR in hyperstone_xm. PC = %08X\n", PC));
- m_icount -= m_clock_cycles_1;
- return;
- }
-
- uint32_t sreg = m_global_regs[src_code];
-
- if (sub_type < 4)
- {
- if (src_code != PC_REGISTER && sreg > extra_u)
- execute_exception(get_trap_addr(TRAPNO_RANGE_ERROR));
- else if (src_code == PC_REGISTER && sreg >= extra_u)
- execute_exception(get_trap_addr(TRAPNO_RANGE_ERROR));
- else
- sreg <<= sub_type;
- }
- else
- {
- sreg <<= (sub_type - 4);
- }
-
- set_global_register(dst_code, sreg);
-
- m_icount -= m_clock_cycles_1;
-}
-
-void hyperstone_device::hyperstone_xm_global_local()
+template <hyperstone_device::reg_bank DST_GLOBAL, hyperstone_device::reg_bank SRC_GLOBAL>
+void hyperstone_device::hyperstone_xm()
{
const uint32_t next = READ_OP(PC);
PC += 2;
@@ -677,20 +564,22 @@ void hyperstone_device::hyperstone_xm_global_local()
check_delay_PC();
- const uint32_t dst_code = DST_CODE;
+ const uint32_t fp = GET_FP;
+ const uint32_t src_code = SRC_GLOBAL ? SRC_CODE : ((SRC_CODE + fp) & 0x3f);
+ const uint32_t dst_code = DST_GLOBAL ? DST_CODE : ((DST_CODE + fp) & 0x3f);
- if (dst_code < 2)
+ if ((SRC_GLOBAL && (src_code == SR_REGISTER)) || (DST_GLOBAL && (dst_code < 2)))
{
DEBUG_PRINTF(("Denoted PC or SR in hyperstone_xm. PC = %08X\n", PC));
m_icount -= m_clock_cycles_1;
return;
}
- uint32_t sreg = m_local_regs[(SRC_CODE + GET_FP) & 0x3f];
+ uint32_t sreg = (SRC_GLOBAL ? m_global_regs : m_local_regs)[src_code];
if (sub_type < 4)
{
- if (sreg > extra_u)
+ if ((SRC_GLOBAL && (src_code == PC_REGISTER)) ? (sreg >= extra_u) : (sreg > extra_u))
execute_exception(get_trap_addr(TRAPNO_RANGE_ERROR));
else
sreg <<= sub_type;
@@ -700,159 +589,26 @@ void hyperstone_device::hyperstone_xm_global_local()
sreg <<= (sub_type - 4);
}
- set_global_register(dst_code, sreg);
-
- m_icount -= m_clock_cycles_1;
-}
-
-void hyperstone_device::hyperstone_xm_local_global()
-{
- const uint32_t next = READ_OP(PC);
- PC += 2;
-
- const uint8_t sub_type = (next & 0x7000) >> 12;
-
- uint32_t extra_u = next & 0xfff;
- if (next & 0x8000)
- {
- extra_u = ((extra_u & 0xfff) << 16) | READ_OP(PC);
- PC += 2;
- m_instruction_length = (3<<19);
- }
- else
- {
- m_instruction_length = (2<<19);
- }
-
- check_delay_PC();
-
- const uint32_t src_code = SRC_CODE;
-
- if (src_code == SR_REGISTER)
- {
- DEBUG_PRINTF(("Denoted SR in hyperstone_xm. PC = %08X\n", PC));
- m_icount -= m_clock_cycles_1;
- return;
- }
-
- uint32_t sreg = m_global_regs[src_code];
-
- if (sub_type < 4)
- {
- if (src_code != PC_REGISTER && sreg > extra_u)
- execute_exception(get_trap_addr(TRAPNO_RANGE_ERROR));
- else if (src_code == PC_REGISTER && sreg >= extra_u)
- execute_exception(get_trap_addr(TRAPNO_RANGE_ERROR));
- else
- sreg <<= sub_type;
- }
- else
- {
- sreg <<= (sub_type - 4);
- }
-
- m_local_regs[(DST_CODE + GET_FP) & 0x3f] = sreg;
-}
-
-void hyperstone_device::hyperstone_xm_local_local()
-{
- const uint32_t next = READ_OP(PC);
- PC += 2;
-
- const uint8_t sub_type = (next & 0x7000) >> 12;
-
- uint32_t extra_u = next & 0xfff;
- if (next & 0x8000)
- {
- extra_u = ((extra_u & 0xfff) << 16) | READ_OP(PC);
- PC += 2;
- m_instruction_length = (3<<19);
- }
- else
- {
- m_instruction_length = (2<<19);
- }
-
- check_delay_PC();
-
- const uint32_t fp = GET_FP;
- uint32_t sreg = m_local_regs[(SRC_CODE + fp) & 0x3f];
-
- if (sub_type < 4)
- {
- if(sreg > extra_u)
- execute_exception(get_trap_addr(TRAPNO_RANGE_ERROR));
- else
- sreg <<= sub_type;
- }
- else
- {
- sreg <<= (sub_type - 4);
- }
-
- m_local_regs[(DST_CODE + fp) & 0x3f] = sreg;
-}
-
-void hyperstone_device::hyperstone_mask_global_global()
-{
- const uint32_t extra_u = decode_const();
-
- check_delay_PC();
-
- const uint32_t dreg = m_global_regs[SRC_CODE] & extra_u;
- set_global_register(DST_CODE, dreg);
-
- if (dreg == 0)
- SR |= Z_MASK;
- else
- SR &= ~Z_MASK;
-
- m_icount -= m_clock_cycles_1;
-}
-
-void hyperstone_device::hyperstone_mask_global_local()
-{
- const uint32_t extra_u = decode_const();
-
- check_delay_PC();
-
- const uint32_t dreg = m_local_regs[(SRC_CODE + GET_FP) & 0x3f] & extra_u;
- set_global_register(DST_CODE, dreg);
-
- if (dreg == 0)
- SR |= Z_MASK;
+ if (DST_GLOBAL)
+ set_global_register(dst_code, sreg);
else
- SR &= ~Z_MASK;
+ m_local_regs[dst_code] = sreg;
m_icount -= m_clock_cycles_1;
}
-void hyperstone_device::hyperstone_mask_local_global()
+template <hyperstone_device::reg_bank DST_GLOBAL, hyperstone_device::reg_bank SRC_GLOBAL>
+void hyperstone_device::hyperstone_mask()
{
const uint32_t extra_u = decode_const();
check_delay_PC();
- const uint32_t dreg = m_global_regs[SRC_CODE] & extra_u;
- m_local_regs[(DST_CODE + GET_FP) & 0x3f] = dreg;
-
- if (dreg == 0)
- SR |= Z_MASK;
+ const uint32_t dreg = (SRC_GLOBAL ? m_global_regs[SRC_CODE] : m_local_regs[(SRC_CODE + GET_FP) & 0x3f]) & extra_u;
+ if (DST_GLOBAL)
+ set_global_register(DST_CODE, dreg);
else
- SR &= ~Z_MASK;
-
- m_icount -= m_clock_cycles_1;
-}
-
-void hyperstone_device::hyperstone_mask_local_local()
-{
- const uint32_t extra_u = decode_const();
-
- check_delay_PC();
-
- const uint32_t fp = GET_FP;
- const uint32_t dreg = m_local_regs[(SRC_CODE + fp) & 0x3f] & extra_u;
- m_local_regs[(DST_CODE + fp) & 0x3f] = dreg;
+ m_local_regs[(DST_CODE + GET_FP) & 0x3f] = dreg;
if (dreg == 0)
SR |= Z_MASK;
@@ -862,100 +618,28 @@ void hyperstone_device::hyperstone_mask_local_local()
m_icount -= m_clock_cycles_1;
}
-void hyperstone_device::hyperstone_sum_global_global()
-{
- const uint32_t extra_u = decode_const();
-
- check_delay_PC();
-
- const uint32_t sreg = m_global_regs[SRC_CODE];
- const uint64_t tmp = (uint64_t)sreg + (uint64_t)extra_u;
-
- SR &= ~(C_MASK | V_MASK | Z_MASK | N_MASK);
-
- SR |= (tmp & 0x100000000L) >> 32;
- SR |= ((sreg ^ tmp) & (extra_u ^ tmp) & 0x80000000) >> 28;
-
- const uint32_t dreg = sreg + extra_u;
-
- set_global_register(DST_CODE, dreg);
-
- if (dreg == 0)
- SR |= Z_MASK;
- SR |= SIGN_TO_N(dreg);
-
- m_icount -= m_clock_cycles_1;
-}
-
-void hyperstone_device::hyperstone_sum_global_local()
-{
- const uint32_t extra_u = decode_const();
-
- check_delay_PC();
-
- const uint32_t sreg = m_local_regs[(SRC_CODE + GET_FP) & 0x3f];
- const uint64_t tmp = (uint64_t)sreg + (uint64_t)extra_u;
-
- SR &= ~(C_MASK | V_MASK | Z_MASK | N_MASK);
-
- SR |= (tmp & 0x100000000L) >> 32;
- SR |= ((sreg ^ tmp) & (extra_u ^ tmp) & 0x80000000) >> 28;
-
- const uint32_t dreg = sreg + extra_u;
-
- set_global_register(DST_CODE, dreg);
-
- if (dreg == 0)
- SR |= Z_MASK;
- SR |= SIGN_TO_N(dreg);
-
- m_icount -= m_clock_cycles_1;
-}
-
-void hyperstone_device::hyperstone_sum_local_global()
-{
- const uint32_t extra_u = decode_const();
-
- check_delay_PC();
-
- const uint32_t sreg = m_global_regs[SRC_CODE];
- const uint64_t tmp = (uint64_t)sreg + (uint64_t)extra_u;
-
- SR &= ~(C_MASK | V_MASK | Z_MASK | N_MASK);
-
- SR |= (tmp & 0x100000000L) >> 32;
- SR |= ((sreg ^ tmp) & (extra_u ^ tmp) & 0x80000000) >> 28;
-
- const uint32_t dreg = sreg + extra_u;
-
- m_local_regs[(DST_CODE + GET_FP) & 0x3f] = dreg;
-
- if (dreg == 0)
- SR |= Z_MASK;
- SR |= SIGN_TO_N(dreg);
-
- m_icount -= m_clock_cycles_1;
-}
-
-void hyperstone_device::hyperstone_sum_local_local()
+template <hyperstone_device::reg_bank DST_GLOBAL, hyperstone_device::reg_bank SRC_GLOBAL>
+void hyperstone_device::hyperstone_sum()
{
const uint32_t extra_u = decode_const();
check_delay_PC();
const uint32_t fp = GET_FP;
- const uint32_t sreg = m_local_regs[(SRC_CODE + fp) & 0x3f];
-
- const uint64_t tmp = (uint64_t)sreg + (uint64_t)extra_u;
+ const uint32_t src_code = SRC_GLOBAL ? SRC_CODE : ((SRC_CODE + fp) & 0x3f);
+ const uint32_t sreg = SRC_GLOBAL ? ((src_code == SR_REGISTER) ? GET_C : m_global_regs[src_code]) : m_local_regs[src_code];
+ const uint64_t tmp = uint64_t(sreg) + uint64_t(extra_u);
SR &= ~(C_MASK | V_MASK | Z_MASK | N_MASK);
- SR |= (tmp & 0x100000000L) >> 32;
+ SR |= (tmp & 0x100000000) >> 32;
SR |= ((sreg ^ tmp) & (extra_u ^ tmp) & 0x80000000) >> 28;
const uint32_t dreg = sreg + extra_u;
-
- m_local_regs[(DST_CODE + fp) & 0x3f] = dreg;
+ if (DST_GLOBAL)
+ set_global_register(DST_CODE, dreg);
+ else
+ m_local_regs[(DST_CODE + fp) & 0x3f] = dreg;
if (dreg == 0)
SR |= Z_MASK;
@@ -964,79 +648,29 @@ void hyperstone_device::hyperstone_sum_local_local()
m_icount -= m_clock_cycles_1;
}
-void hyperstone_device::hyperstone_sums_global_global()
-{
- const int32_t extra_s = decode_const();
-
- check_delay_PC();
-
- const uint32_t src_code = SRC_CODE;
- const int32_t sreg = (src_code == SR_REGISTER) ? (SR & C_MASK) : m_global_regs[src_code];
-
- const int64_t tmp = (int64_t)sreg + (int64_t)extra_s;
- SR |= ((sreg ^ tmp) & (extra_s ^ tmp) & 0x80000000) >> 28;
-
-//#if SETCARRYS
-// CHECK_C(tmp);
-//#endif
-
- const int32_t res = (int32_t)sreg + extra_s;
- set_global_register(DST_CODE, res);
-
- if (res == 0)
- SR |= Z_MASK;
- SR |= SIGN_TO_N(res);
-
- m_icount -= m_clock_cycles_1;
-
- if ((SR & V_MASK) && src_code != SR_REGISTER)
- execute_exception(get_trap_addr(TRAPNO_RANGE_ERROR));
-}
-
-void hyperstone_device::hyperstone_sums_global_local()
+template <hyperstone_device::reg_bank DST_GLOBAL, hyperstone_device::reg_bank SRC_GLOBAL>
+void hyperstone_device::hyperstone_sums()
{
const int32_t extra_s = decode_const();
check_delay_PC();
- const int32_t sreg = m_local_regs[(SRC_CODE + GET_FP) & 0x3f];
- const int64_t tmp = (int64_t)sreg + (int64_t)extra_s;
- SR |= ((sreg ^ tmp) & (extra_s ^ tmp) & 0x80000000) >> 28;
-
-//#if SETCARRYS
-// CHECK_C(tmp);
-//#endif
-
- const int32_t res = (int32_t)sreg + extra_s;
- set_global_register(DST_CODE, res);
-
- if (res == 0)
- SR |= Z_MASK;
- SR |= SIGN_TO_N(res);
-
- m_icount -= m_clock_cycles_1;
-
- if (SR & V_MASK)
- execute_exception(get_trap_addr(TRAPNO_RANGE_ERROR));
-}
-
-void hyperstone_device::hyperstone_sums_local_global()
-{
- const int32_t extra_s = decode_const();
-
- check_delay_PC();
+ const uint32_t fp = GET_FP;
+ const uint32_t src_code = SRC_GLOBAL ? SRC_CODE : ((SRC_CODE + fp) & 0x3f);
+ const int32_t sreg = int32_t(SRC_GLOBAL ? ((src_code == SR_REGISTER) ? GET_C : m_global_regs[src_code]) : m_local_regs[src_code]);
- const uint32_t src_code = SRC_CODE;
- const int32_t sreg = (src_code == SR_REGISTER) ? (SR & C_MASK) : m_global_regs[src_code];
- const int64_t tmp = (int64_t)sreg + (int64_t)extra_s;
+ const int64_t tmp = int64_t(sreg) + int64_t(extra_s);
SR |= ((sreg ^ tmp) & (extra_s ^ tmp) & 0x80000000) >> 28;
//#if SETCARRYS
// CHECK_C(tmp);
//#endif
- const int32_t res = (int32_t)sreg + extra_s;
- m_local_regs[(DST_CODE + GET_FP) & 0x3f] = res;
+ const int32_t res = sreg + extra_s;
+ if (DST_GLOBAL)
+ set_global_register(DST_CODE, res);
+ else
+ m_local_regs[(DST_CODE + fp) & 0x3f] = res;
if (res == 0)
SR |= Z_MASK;
@@ -1048,34 +682,6 @@ void hyperstone_device::hyperstone_sums_local_global()
execute_exception(get_trap_addr(TRAPNO_RANGE_ERROR));
}
-void hyperstone_device::hyperstone_sums_local_local()
-{
- const int32_t extra_s = decode_const();
-
- check_delay_PC();
-
- const uint32_t fp = GET_FP;
- const int32_t sreg = m_local_regs[(SRC_CODE + fp) & 0x3f];
- const int64_t tmp = (int64_t)sreg + (int64_t)extra_s;
- SR |= ((sreg ^ tmp) & (extra_s ^ tmp) & 0x80000000) >> 28;
-
-//#if SETCARRYS
-// CHECK_C(tmp);
-//#endif
-
- const int32_t res = (int32_t)sreg + extra_s;
- m_local_regs[(DST_CODE + fp) & 0x3f] = res;
-
- if (res == 0)
- SR |= Z_MASK;
- SR |= SIGN_TO_N(res);
-
- m_icount -= m_clock_cycles_1;
-
- if (SR & V_MASK)
- execute_exception(get_trap_addr(TRAPNO_RANGE_ERROR));
-}
-
template <hyperstone_device::reg_bank DST_GLOBAL, hyperstone_device::reg_bank SRC_GLOBAL>
void hyperstone_device::hyperstone_cmp()
@@ -1227,7 +833,7 @@ void hyperstone_device::hyperstone_add()
SR &= ~(C_MASK | V_MASK | Z_MASK | N_MASK);
- SR |= (tmp & 0x100000000L) >> 32;
+ SR |= (tmp & 0x100000000) >> 32;
SR |= ((sreg ^ tmp) & (dreg ^ tmp) & 0x80000000) >> 28;
dreg += sreg;
@@ -1391,7 +997,7 @@ void hyperstone_device::hyperstone_subc()
{
const uint64_t tmp = uint64_t(dreg) - uint64_t(c);
SR |= ((tmp ^ dreg) & dreg & 0x80000000);
- SR |= (tmp & 0x100000000L) >> 32;
+ SR |= (tmp & 0x100000000) >> 32;
dreg -= c;
}
else
@@ -1401,7 +1007,7 @@ void hyperstone_device::hyperstone_subc()
//CHECK!
const uint32_t sreg_c = sreg + c;
SR |= ((tmp ^ dreg) & (dreg ^ sreg_c) & 0x80000000);
- SR |= (tmp & 0x100000000L) >> 32;
+ SR |= (tmp & 0x100000000) >> 32;
dreg -= sreg_c;
}
@@ -1452,7 +1058,7 @@ void hyperstone_device::hyperstone_sub()
SR &= ~(C_MASK | V_MASK | Z_MASK | N_MASK);
- SR |= (tmp & 0x100000000L) >> 32;
+ SR |= (tmp & 0x100000000) >> 32;
SR |= ((tmp ^ dreg) & (dreg ^ sreg) & 0x80000000) >> 28;
dreg -= sreg;
@@ -1545,7 +1151,7 @@ void hyperstone_device::hyperstone_addc()
dreg += sreg + c;
}
- SR |= (tmp & 0x100000000L) >> 32;
+ SR |= (tmp & 0x100000000) >> 32;
if (DST_GLOBAL)
set_global_register(dst_code, dreg);
@@ -1592,7 +1198,7 @@ void hyperstone_device::hyperstone_neg()
const uint64_t tmp = -uint64_t(sreg);
SR &= ~(C_MASK | V_MASK | Z_MASK | N_MASK);
- SR |= (tmp & 0x100000000L) >> 32;
+ SR |= (tmp & 0x100000000) >> 32;
SR |= (tmp & sreg & 0x80000000) >> 28;
const uint32_t dreg = -sreg;
@@ -1617,7 +1223,7 @@ void hyperstone_device::hyperstone_negs()
const uint32_t src_code = SRC_GLOBAL ? SRC_CODE : ((SRC_CODE + fp) & 0x3f);
const int32_t sreg = int32_t(SRC_GLOBAL ? ((src_code == SR_REGISTER) ? GET_C : m_global_regs[src_code]) : m_local_regs[src_code]);
- const int64_t tmp = -(int64_t)sreg;
+ const int64_t tmp = -int64_t(sreg);
SR &= ~(V_MASK | Z_MASK | N_MASK);
@@ -1640,7 +1246,7 @@ void hyperstone_device::hyperstone_negs()
m_icount -= m_clock_cycles_1;
- if (GET_V && (!SRC_GLOBAL || (src_code != SR_REGISTER))) // trap doesn't occur when source is SR
+ if (GET_V)
execute_exception(get_trap_addr(TRAPNO_RANGE_ERROR));
}
@@ -1739,7 +1345,7 @@ void hyperstone_device::hyperstone_addi()
const uint64_t tmp = (uint64_t)imm + (uint64_t)dreg;
- SR |= (tmp & 0x100000000L) >> 32;
+ SR |= (tmp & 0x100000000) >> 32;
SR |= ((imm ^ tmp) & (dreg ^ tmp) & 0x80000000) >> 28;
dreg += imm;