From dc323f06509e113706af8ac38d3f28386934a447 Mon Sep 17 00:00:00 2001 From: mooglyguy Date: Thu, 16 Nov 2017 22:25:34 +0100 Subject: e132xs: templated immediate shifts, nw --- src/devices/cpu/e132xs/e132xs.cpp | 24 ++++---- src/devices/cpu/e132xs/e132xs.h | 9 +-- src/devices/cpu/e132xs/e132xsop.hxx | 114 ++++++++---------------------------- 3 files changed, 39 insertions(+), 108 deletions(-) diff --git a/src/devices/cpu/e132xs/e132xs.cpp b/src/devices/cpu/e132xs/e132xs.cpp index bf227070ed2..227ce35de43 100644 --- a/src/devices/cpu/e132xs/e132xs.cpp +++ b/src/devices/cpu/e132xs/e132xs.cpp @@ -1791,18 +1791,18 @@ void hyperstone_device::execute_run() case 0x9d: hyperstone_stxx2(); break; case 0x9e: hyperstone_stxx2(); break; case 0x9f: hyperstone_stxx2(); break; - case 0xa0: hyperstone_shri_global(); break; - case 0xa1: hyperstone_shri_global(); break; - case 0xa2: hyperstone_shri_local(); break; - case 0xa3: hyperstone_shri_local(); break; - case 0xa4: hyperstone_sari_global(); break; - case 0xa5: hyperstone_sari_global(); break; - case 0xa6: hyperstone_sari_local(); break; - case 0xa7: hyperstone_sari_local(); break; - case 0xa8: hyperstone_shli_global(); break; - case 0xa9: hyperstone_shli_global(); break; - case 0xaa: hyperstone_shli_local(); break; - case 0xab: hyperstone_shli_local(); break; + case 0xa0: hyperstone_shri(); break; + case 0xa1: hyperstone_shri(); break; + case 0xa2: hyperstone_shri(); break; + case 0xa3: hyperstone_shri(); break; + case 0xa4: hyperstone_sari(); break; + case 0xa5: hyperstone_sari(); break; + case 0xa6: hyperstone_sari(); break; + case 0xa7: hyperstone_sari(); break; + case 0xa8: hyperstone_shli(); break; + case 0xa9: hyperstone_shli(); break; + case 0xaa: hyperstone_shli(); break; + case 0xab: hyperstone_shli(); break; case 0xac: hyperstone_reserved(); break; case 0xad: hyperstone_reserved(); break; case 0xae: hyperstone_reserved(); break; diff --git a/src/devices/cpu/e132xs/e132xs.h b/src/devices/cpu/e132xs/e132xs.h index c62dc8e6c4e..a26aeb34918 100644 --- a/src/devices/cpu/e132xs/e132xs.h +++ b/src/devices/cpu/e132xs/e132xs.h @@ -249,18 +249,15 @@ private: void hyperstone_shrdi(); void hyperstone_shrd(); void hyperstone_shr(); - void hyperstone_shri_global(); - void hyperstone_shri_local(); + template void hyperstone_shri(); void hyperstone_sardi(); void hyperstone_sard(); void hyperstone_sar(); - void hyperstone_sari_global(); - void hyperstone_sari_local(); + template void hyperstone_sari(); void hyperstone_shldi(); void hyperstone_shld(); void hyperstone_shl(); - void hyperstone_shli_global(); - void hyperstone_shli_local(); + template void hyperstone_shli(); void hyperstone_testlz(); void hyperstone_rol(); template void hyperstone_ldxx1(); diff --git a/src/devices/cpu/e132xs/e132xsop.hxx b/src/devices/cpu/e132xs/e132xsop.hxx index 03be3c451c8..0fa3d3f9d7f 100644 --- a/src/devices/cpu/e132xs/e132xsop.hxx +++ b/src/devices/cpu/e132xs/e132xsop.hxx @@ -2401,38 +2401,13 @@ void hyperstone_device::hyperstone_stxx2() m_icount -= m_clock_cycles_1; } - - -void hyperstone_device::hyperstone_shri_global() -{ - check_delay_PC(); - - const uint32_t dst_code = DST_CODE; - - uint32_t val = m_global_regs[dst_code]; - - SR &= ~(C_MASK | Z_MASK | N_MASK); - - const uint32_t n = N_VALUE; - if (n) - SR |= (val >> (n - 1)) & 1; - - val >>= n; - - m_global_regs[dst_code] = val; - if (val == 0) - SR |= Z_MASK; - SR |= SIGN_TO_N(val); - - m_icount -= m_clock_cycles_1; -} - -void hyperstone_device::hyperstone_shri_local() +template +void hyperstone_device::hyperstone_shri() { check_delay_PC(); - const uint32_t dst_code = (DST_CODE + GET_FP) & 0x3f; - uint32_t val = m_local_regs[dst_code]; + const uint32_t dst_code = DST_GLOBAL ? DST_CODE : ((DST_CODE + GET_FP) & 0x3f); + uint32_t val = (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code]; SR &= ~(C_MASK | Z_MASK | N_MASK); @@ -2442,7 +2417,10 @@ void hyperstone_device::hyperstone_shri_local() val >>= n; - m_local_regs[dst_code] = val; + if (DST_GLOBAL) + set_global_register(dst_code, val); + else + m_local_regs[dst_code] = val; if (val == 0) SR |= Z_MASK; @@ -2451,12 +2429,13 @@ void hyperstone_device::hyperstone_shri_local() m_icount -= m_clock_cycles_1; } -void hyperstone_device::hyperstone_sari_global() +template +void hyperstone_device::hyperstone_sari() { check_delay_PC(); - const uint32_t dst_code = DST_CODE; - uint32_t val = m_global_regs[dst_code]; + const uint32_t dst_code = DST_GLOBAL ? DST_CODE : ((DST_CODE + GET_FP) & 0x3f); + uint32_t val = (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code]; const uint32_t n = N_VALUE; @@ -2472,37 +2451,11 @@ void hyperstone_device::hyperstone_sari_global() val |= 0xffffffff << (32 - n); } - set_global_register(dst_code, val); - if (val == 0) - SR |= Z_MASK; - SR |= SIGN_TO_N(val); - - m_icount -= m_clock_cycles_1; -} - -void hyperstone_device::hyperstone_sari_local() -{ - check_delay_PC(); - - const uint32_t dst_code = (DST_CODE + GET_FP) & 0x3f; - - uint32_t val = m_local_regs[dst_code]; - uint32_t sign_bit = val & 0x80000000; - - const uint32_t n = N_VALUE; - - SR &= ~(C_MASK | Z_MASK | N_MASK); - if (n) - { - SR |= (val >> (n - 1)) & 1; - - val >>= n; - - if (sign_bit) - val |= 0xffffffff << (32 - n); - } + if (DST_GLOBAL) + set_global_register(dst_code, val); + else + m_local_regs[dst_code] = val; - m_local_regs[dst_code] = val; if (val == 0) SR |= Z_MASK; SR |= SIGN_TO_N(val); @@ -2510,13 +2463,14 @@ void hyperstone_device::hyperstone_sari_local() m_icount -= m_clock_cycles_1; } -void hyperstone_device::hyperstone_shli_global() +template +void hyperstone_device::hyperstone_shli() { check_delay_PC(); - const uint32_t dst_code = DST_CODE; + const uint32_t dst_code = DST_GLOBAL ? DST_CODE : ((DST_CODE + GET_FP) & 0x3f); + uint32_t val = (DST_GLOBAL ? m_global_regs : m_local_regs)[dst_code]; - uint32_t val = m_global_regs[dst_code]; const uint32_t n = N_VALUE; SR &= ~(C_MASK | V_MASK | Z_MASK | N_MASK); SR |= n ? (((val << (n - 1)) & 0x80000000) ? 1 : 0) : 0; @@ -2526,31 +2480,11 @@ void hyperstone_device::hyperstone_shli_global() if (((val & mask) && (!(val2 & 0x80000000))) || (((val & mask) ^ mask) && (val2 & 0x80000000))) SR |= V_MASK; - set_global_register(dst_code, val2); - if (val2 == 0) - SR |= Z_MASK; - SR |= SIGN_TO_N(val2); - - m_icount -= m_clock_cycles_1; -} - -void hyperstone_device::hyperstone_shli_local() -{ - check_delay_PC(); - - const uint32_t dst_code = (DST_CODE + GET_FP) & 0x3f; - - uint32_t val = m_local_regs[dst_code]; - const uint32_t n = N_VALUE; - SR &= ~(C_MASK | V_MASK | Z_MASK | N_MASK); - SR |= n ? (((val << (n - 1)) & 0x80000000) ? 1 : 0) : 0; - uint64_t mask = ((1U << (32 - n)) - 1) ^ 0xffffffff; - uint32_t val2 = val << n; - - if (((val & mask) && (!(val2 & 0x80000000))) || (((val & mask) ^ mask) && (val2 & 0x80000000))) - SR |= V_MASK; + if (DST_GLOBAL) + set_global_register(dst_code, val2); + else + m_local_regs[dst_code] = val2; - m_local_regs[dst_code] = val2; if (val2 == 0) SR |= Z_MASK; SR |= SIGN_TO_N(val2); -- cgit v1.2.3