e132x, looked at adds opcode, nw.

This commit is contained in:
mooglyguy 2017-11-13 19:14:32 +01:00
parent a911249fbf
commit 7ef02cc5f3
3 changed files with 97 additions and 83 deletions

View File

@ -1721,34 +1721,6 @@ offs_t hyperstone_device::disasm_disassemble(std::ostream &stream, offs_t pc, co
/* Opcodes */
void hyperstone_device::hyperstone_adds(regs_decode &decode)
{
if (SRC_IS_SR)
SREG = GET_C;
int64_t tmp = (int64_t)((int32_t)(SREG)) + (int64_t)((int32_t)(DREG));
CHECK_VADD(SREG, DREG, tmp);
//#if SETCARRYS
// CHECK_C(tmp);
//#endif
int32_t res = (int32_t)(SREG) + (int32_t)(DREG);
SET_DREG(res);
SET_Z(res == 0 ? 1 : 0);
SET_N(SIGN_BIT(res));
m_icount -= m_clock_cycles_1;
if (SR & V_MASK)
{
uint32_t addr = get_trap_addr(TRAPNO_RANGE_ERROR);
execute_exception(addr);
}
}
void hyperstone_device::hyperstone_subc(regs_decode &decode)
{
uint64_t tmp;
@ -2111,10 +2083,10 @@ void hyperstone_device::execute_run()
case 0x29: hyperstone_add_global_local(); break;
case 0x2a: hyperstone_add_local_global(); break;
case 0x2b: hyperstone_add_local_local(); break;
case 0x2c: op2c(); break;
case 0x2d: op2d(); break;
case 0x2e: op2e(); break;
case 0x2f: op2f(); break;
case 0x2c: hyperstone_adds_global_global(); break;
case 0x2d: hyperstone_adds_global_local(); break;
case 0x2e: hyperstone_adds_local_global(); break;
case 0x2f: hyperstone_adds_local_local(); break;
case 0x30: hyperstone_cmpb_global_global(); break;
case 0x31: hyperstone_cmpb_global_local(); break;
case 0x32: hyperstone_cmpb_local_global(); break;

View File

@ -266,7 +266,10 @@ private:
void hyperstone_add_global_local();
void hyperstone_add_local_global();
void hyperstone_add_local_local();
void hyperstone_adds(regs_decode &decode);
void hyperstone_adds_global_global();
void hyperstone_adds_global_local();
void hyperstone_adds_local_global();
void hyperstone_adds_local_local();
void hyperstone_cmpb_global_global();
void hyperstone_cmpb_global_local();
void hyperstone_cmpb_local_global();
@ -462,7 +465,6 @@ private:
bool generate_opcode(drcuml_block *block, compiler_state *compiler, const opcode_desc *desc);
#endif
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

View File

@ -1411,73 +1411,115 @@ void hyperstone_device::hyperstone_add_local_local()
m_icount -= m_clock_cycles_1;
}
void hyperstone_device::op2c()
void hyperstone_device::hyperstone_adds_global_global()
{
regs_decode decode;
check_delay_PC();
decode.src = SRC_CODE;
decode.dst = DST_CODE;
const uint32_t src_code = SRC_CODE;
const uint32_t dst_code = DST_CODE;
const int32_t sreg = (src_code == SR_REGISTER) ? (SR & C_MASK) : (int32_t)m_global_regs[src_code];
const int32_t dreg = m_global_regs[dst_code];
const int64_t tmp = (int64_t)sreg + (int64_t)dreg;
decode.src_is_local = 0;
SREG = m_global_regs[decode.src];
SR &= ~(V_MASK | Z_MASK | N_MASK);
SR |= ((sreg ^ tmp) & (dreg ^ tmp) & 0x80000000) >> 28;
decode.dst_is_local = 0;
DREG = m_global_regs[decode.dst];
DREGF = m_global_regs[decode.dst + 1];
//#if SETCARRYS
// CHECK_C(tmp);
//#endif
hyperstone_adds(decode);
printf("0x2c, adds global,global\n");
const int32_t res = sreg + dreg;
m_global_regs[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::op2d()
void hyperstone_device::hyperstone_adds_global_local()
{
regs_decode decode;
check_delay_PC();
decode.src = SRC_CODE;
decode.dst = DST_CODE;
const uint32_t dst_code = DST_CODE;
const int32_t sreg = (int32_t)m_local_regs[(SRC_CODE + GET_FP) & 0x3f];
const int32_t dreg = m_global_regs[dst_code];
const int64_t tmp = (int64_t)sreg + (int64_t)dreg;
decode.src_is_local = 1;
SREG = m_local_regs[(decode.src + GET_FP) & 0x3f];
SR &= ~(V_MASK | Z_MASK | N_MASK);
SR |= ((sreg ^ tmp) & (dreg ^ tmp) & 0x80000000) >> 28;
decode.dst_is_local = 0;
DREG = m_global_regs[decode.dst];
//#if SETCARRYS
// CHECK_C(tmp);
//#endif
hyperstone_adds(decode);
printf("0x2d, adds global,local\n");
const int32_t res = sreg + dreg;
m_global_regs[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::op2e()
void hyperstone_device::hyperstone_adds_local_global()
{
regs_decode decode;
check_delay_PC();
decode.src = SRC_CODE;
decode.dst = DST_CODE;
const uint32_t src_code = SRC_CODE;
const uint32_t dst_code = (DST_CODE + GET_FP) & 0x3f;
const int32_t sreg = (src_code == SR_REGISTER) ? (SR & C_MASK) : (int32_t)m_global_regs[src_code];
const int32_t dreg = m_local_regs[dst_code];
const int64_t tmp = (int64_t)sreg + (int64_t)dreg;
decode.src_is_local = 0;
SREG = m_global_regs[decode.src];
SR &= ~(V_MASK | Z_MASK | N_MASK);
SR |= ((sreg ^ tmp) & (dreg ^ tmp) & 0x80000000) >> 28;
decode.dst_is_local = 1;
DREG = m_local_regs[(decode.dst + GET_FP) & 0x3f]; /* registers offset by frame pointer */
//#if SETCARRYS
// CHECK_C(tmp);
//#endif
hyperstone_adds(decode);
printf("0x2e, adds local,global\n");
const int32_t res = sreg + dreg;
m_local_regs[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::op2f()
void hyperstone_device::hyperstone_adds_local_local()
{
regs_decode decode;
check_delay_PC();
decode.src = SRC_CODE;
decode.dst = DST_CODE;
const uint32_t fp = GET_FP;
const uint32_t dst_code = (DST_CODE + fp) & 0x3f;
const int32_t sreg = (int32_t)m_local_regs[(SRC_CODE + fp) & 0x3f];
const int32_t dreg = m_local_regs[dst_code];
const int64_t tmp = (int64_t)sreg + (int64_t)dreg;
decode.src_is_local = 1;
SREG = m_local_regs[(decode.src + GET_FP) & 0x3f];
SR &= ~(V_MASK | Z_MASK | N_MASK);
SR |= ((sreg ^ tmp) & (dreg ^ tmp) & 0x80000000) >> 28;
decode.dst_is_local = 1;
DREG = m_local_regs[(decode.dst + GET_FP) & 0x3f]; /* registers offset by frame pointer */
//#if SETCARRYS
// CHECK_C(tmp);
//#endif
hyperstone_adds(decode);
printf("0x2f, adds local,local\n");
const int32_t res = sreg + dreg;
m_local_regs[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));
}
@ -3589,11 +3631,9 @@ void hyperstone_device::hyperstone_rol()
#ifdef MISSIONCRAFT_FLAGS
SR &= ~(V_MASK | Z_MASK | C_MASK);
if (((base & mask) && (!(val & 0x80000000))) || (((base & mask) ^ mask) && (val & 0x80000000)))
SET_V(1);
else
SET_V(0);
SR |= V_MASK;
#else
SR &= ~(Z_MASK | C_MASK);
SR &= ~(Z_MASK | C_MASK | N_MASK);
#endif
m_local_regs[dst_code] = val;