e132xs: templated immediate shifts, nw

This commit is contained in:
mooglyguy 2017-11-16 22:25:34 +01:00
parent 93c54536a8
commit dc323f0650
3 changed files with 40 additions and 109 deletions

View File

@ -1791,18 +1791,18 @@ void hyperstone_device::execute_run()
case 0x9d: hyperstone_stxx2<GLOBAL, LOCAL>(); break;
case 0x9e: hyperstone_stxx2<LOCAL, GLOBAL>(); break;
case 0x9f: hyperstone_stxx2<LOCAL, LOCAL>(); 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<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 0xac: hyperstone_reserved(); break;
case 0xad: hyperstone_reserved(); break;
case 0xae: hyperstone_reserved(); break;

View File

@ -249,18 +249,15 @@ private:
void hyperstone_shrdi();
void hyperstone_shrd();
void hyperstone_shr();
void hyperstone_shri_global();
void hyperstone_shri_local();
template <reg_bank DST_GLOBAL> void hyperstone_shri();
void hyperstone_sardi();
void hyperstone_sard();
void hyperstone_sar();
void hyperstone_sari_global();
void hyperstone_sari_local();
template <reg_bank DST_GLOBAL> void hyperstone_sari();
void hyperstone_shldi();
void hyperstone_shld();
void hyperstone_shl();
void hyperstone_shli_global();
void hyperstone_shli_local();
template <reg_bank DST_GLOBAL> void hyperstone_shli();
void hyperstone_testlz();
void hyperstone_rol();
template <reg_bank DST_GLOBAL, reg_bank SRC_GLOBAL> void hyperstone_ldxx1();

View File

@ -2401,15 +2401,13 @@ void hyperstone_device::hyperstone_stxx2()
m_icount -= m_clock_cycles_1;
}
void hyperstone_device::hyperstone_shri_global()
template <hyperstone_device::reg_bank DST_GLOBAL>
void hyperstone_device::hyperstone_shri()
{
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];
SR &= ~(C_MASK | Z_MASK | N_MASK);
@ -2419,30 +2417,10 @@ void hyperstone_device::hyperstone_shri_global()
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()
{
check_delay_PC();
const uint32_t dst_code = (DST_CODE + GET_FP) & 0x3f;
uint32_t val = m_local_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_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 <hyperstone_device::reg_bank DST_GLOBAL>
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,7 +2451,11 @@ void hyperstone_device::hyperstone_sari_global()
val |= 0xffffffff << (32 - n);
}
set_global_register(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;
SR |= SIGN_TO_N(val);
@ -2480,43 +2463,14 @@ void hyperstone_device::hyperstone_sari_global()
m_icount -= m_clock_cycles_1;
}
void hyperstone_device::hyperstone_sari_local()
template <hyperstone_device::reg_bank DST_GLOBAL>
void hyperstone_device::hyperstone_shli()
{
check_delay_PC();
const uint32_t dst_code = (DST_CODE + GET_FP) & 0x3f;
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_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);
}
m_local_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_shli_global()
{
check_delay_PC();
const uint32_t dst_code = 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);
if (DST_GLOBAL)
set_global_register(dst_code, val2);
else
m_local_regs[dst_code] = 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;
m_local_regs[dst_code] = val2;
if (val2 == 0)
SR |= Z_MASK;
SR |= SIGN_TO_N(val2);