summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author mooglyguy <therealmogminer@gmail.com>2020-02-09 16:24:49 +0100
committer mooglyguy <therealmogminer@gmail.com>2020-02-09 16:25:23 +0100
commite0510d2cf169416295ed7bc8dece5a995ba8d7fd (patch)
tree991b5b217e0534653f9a48aff8e034bd4db04920
parent2338fbd4fdd4e0f1e4649a7f96c560212d62a291 (diff)
-unspdrc: Added support for fir_mov and muls opcodes. Fixed S flag calculation. [Ryan Holtz]
-rw-r--r--src/devices/cpu/unsp/unsp.cpp2
-rw-r--r--src/devices/cpu/unsp/unsp.h4
-rw-r--r--src/devices/cpu/unsp/unsp_fxxx.cpp6
-rw-r--r--src/devices/cpu/unsp/unspdrc.cpp65
-rw-r--r--src/devices/cpu/unsp/unspfe.cpp18
5 files changed, 75 insertions, 20 deletions
diff --git a/src/devices/cpu/unsp/unsp.cpp b/src/devices/cpu/unsp/unsp.cpp
index 72d8ef35d07..6d0bc92c6d5 100644
--- a/src/devices/cpu/unsp/unsp.cpp
+++ b/src/devices/cpu/unsp/unsp.cpp
@@ -310,7 +310,7 @@ void unsp_device::device_reset()
m_core->m_r[REG_PC] = read16(0xfff7);
m_core->m_enable_irq = 0;
m_core->m_enable_fiq = 0;
- m_core->m_fir_move = 0;
+ m_core->m_fir_move = 1;
m_core->m_irq = 0;
m_core->m_fiq = 0;
}
diff --git a/src/devices/cpu/unsp/unsp.h b/src/devices/cpu/unsp/unsp.h
index 4515e82bab4..dc3ba619eaa 100644
--- a/src/devices/cpu/unsp/unsp.h
+++ b/src/devices/cpu/unsp/unsp.h
@@ -110,6 +110,8 @@ public:
void cfunc_log_write();
#endif
+ void cfunc_muls();
+
protected:
unsp_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, address_map_constructor internal);
@@ -216,7 +218,7 @@ protected:
void execute_fxxx_100_group(uint16_t op);
virtual void execute_extended_group(uint16_t op);
virtual void execute_exxx_group(uint16_t op);
- void execute_muls(const uint16_t rd, const uint16_t rs, const uint16_t size);
+ void execute_muls_ss(const uint16_t rd, const uint16_t rs, const uint16_t size);
void unimplemented_opcode(uint16_t op);
void unimplemented_opcode(uint16_t op, uint16_t ximm);
void unimplemented_opcode(uint16_t op, uint16_t ximm, uint16_t ximm_2);
diff --git a/src/devices/cpu/unsp/unsp_fxxx.cpp b/src/devices/cpu/unsp/unsp_fxxx.cpp
index 7bd76da1270..27359d8f916 100644
--- a/src/devices/cpu/unsp/unsp_fxxx.cpp
+++ b/src/devices/cpu/unsp/unsp_fxxx.cpp
@@ -453,10 +453,10 @@ inline void unsp_device::execute_fxxx_110_group(uint16_t op)
const uint16_t size = ((op >> 3) & 7) ? ((op >> 3) & 7) : 16;
const uint16_t rd = (op >> 9) & 7;
const uint16_t rs = op & 7;
- execute_muls(rd, rs, size);
+ execute_muls_ss(rd, rs, size);
}
-inline void unsp_device::execute_muls(const uint16_t rd, const uint16_t rs, const uint16_t size)
+void unsp_device::execute_muls_ss(const uint16_t rd, const uint16_t rs, const uint16_t size)
{
const uint32_t rdv = m_core->m_r[rd];
const uint32_t rsv = m_core->m_r[rs];
@@ -503,7 +503,7 @@ inline void unsp_device::execute_fxxx_111_group(uint16_t op)
// MULS ss with upper size bit set.
const uint16_t rd = (op >> 9) & 7;
const uint16_t rs = op & 7;
- execute_muls(rd, rs, ((op >> 3) & 7) + 8);
+ execute_muls_ss(rd, rs, ((op >> 3) & 7) + 8);
}
void unsp_device::execute_fxxx_group(uint16_t op)
diff --git a/src/devices/cpu/unsp/unspdrc.cpp b/src/devices/cpu/unsp/unspdrc.cpp
index 3b0b1e6db59..6a12a58a762 100644
--- a/src/devices/cpu/unsp/unspdrc.cpp
+++ b/src/devices/cpu/unsp/unspdrc.cpp
@@ -1,3 +1,4 @@
+
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz
@@ -82,6 +83,20 @@ static void ccfunc_log_write(void *param)
}
#endif
+void unsp_device::cfunc_muls()
+{
+ const uint32_t op = m_core->m_arg0;
+ const uint16_t size = ((op >> 3) & 15) ? ((op >> 3) & 15) : 16;
+ const uint16_t rd = (op >> 9) & 7;
+ const uint16_t rs = op & 7;
+ execute_muls_ss(rd, rs, size);
+}
+
+static void ccfunc_muls(void *param)
+{
+ ((unsp_device *)param)->cfunc_muls();
+}
+
/***************************************************************************
CACHE MANAGEMENT
***************************************************************************/
@@ -634,12 +649,9 @@ void unsp_device::generate_add_lpc(drcuml_block &block, int32_t offset)
void unsp_device::generate_update_nzsc(drcuml_block &block)
{
- UML_XOR(block, I1, I1, 0x0000ffff);
- UML_SEXT(block, I1, I1, SIZE_WORD);
- UML_SEXT(block, I2, I2, SIZE_WORD);
- UML_CMP(block, I2, I1);
- UML_SETc(block, uml::COND_L, I1);
- UML_ROLINS(block, mem(&m_core->m_r[REG_SR]), I1, UNSP_S_SHIFT, UNSP_S);
+ UML_XOR(block, I1, I1, I2);
+ UML_TEST(block, I1, 0x8000);
+ UML_SETc(block, uml::COND_NZ, I2);
UML_TEST(block, I3, 0x8000);
UML_SETc(block, uml::COND_NZ, I1);
@@ -648,6 +660,9 @@ void unsp_device::generate_update_nzsc(drcuml_block &block)
UML_TEST(block, I3, 0x10000);
UML_SETc(block, uml::COND_NZ, I1);
UML_ROLINS(block, mem(&m_core->m_r[REG_SR]), I1, UNSP_C_SHIFT, UNSP_C);
+ UML_CMP(block, I2, I1);
+ UML_SETc(block, uml::COND_NE, I1);
+ UML_ROLINS(block, mem(&m_core->m_r[REG_SR]), I1, UNSP_S_SHIFT, UNSP_S);
UML_TEST(block, I3, 0x0000ffff);
UML_SETc(block, uml::COND_Z, I1);
@@ -769,6 +784,20 @@ bool unsp_device::generate_opcode(drcuml_block &block, compiler_state &compiler,
UML_JMPc(block, uml::COND_NZ, skip_branch);
break;
+ case 12: // JVC
+ UML_ROLAND(block, I0, mem(&m_core->m_r[REG_SR]), 32-UNSP_S_SHIFT, 1);
+ UML_ROLAND(block, I1, mem(&m_core->m_r[REG_SR]), 32-UNSP_N_SHIFT, 1);
+ UML_CMP(block, I0, I1);
+ UML_JMPc(block, uml::COND_NE, skip_branch);
+ break;
+
+ case 13: // JVS
+ UML_ROLAND(block, I0, mem(&m_core->m_r[REG_SR]), 32-UNSP_S_SHIFT, 1);
+ UML_ROLAND(block, I1, mem(&m_core->m_r[REG_SR]), 32-UNSP_N_SHIFT, 1);
+ UML_CMP(block, I0, I1);
+ UML_JMPc(block, uml::COND_E, skip_branch);
+ break;
+
case 14: // JMP
UML_SUB(block, mem(&m_core->m_icount), mem(&m_core->m_icount), 4);
UML_MOV(block, I0, desc->targetpc);
@@ -970,6 +999,14 @@ bool unsp_device::generate_opcode(drcuml_block &block, compiler_state &compiler,
UML_MOV(block, mem(&m_core->m_enable_fiq), 1);
break;
+ case 4:
+ UML_MOV(block, mem(&m_core->m_fir_move), 1);
+ break;
+
+ case 5:
+ UML_MOV(block, mem(&m_core->m_fir_move), 0);
+ break;
+
case 8:
UML_MOV(block, mem(&m_core->m_enable_irq), 0);
break;
@@ -990,18 +1027,22 @@ bool unsp_device::generate_opcode(drcuml_block &block, compiler_state &compiler,
// nop
break;
- case 4: // should be 1.2 only but jak_care triggers, see notes in non-drc
- break;
-
- case 5: // ^^
- break;
-
default:
logerror("unsp drc interrupt flags %02x\n", op & 0x3f);
return false;
}
return true;
+ case 0x06:
+ case 0x07:
+ if (opa == 7)
+ return false;
+
+ // MULS
+ UML_MOV(block, mem(&m_core->m_arg0), desc->opptr.w[0]);
+ UML_CALLC(block, ccfunc_muls, this);
+ return true;
+
default:
return false;
}
diff --git a/src/devices/cpu/unsp/unspfe.cpp b/src/devices/cpu/unsp/unspfe.cpp
index 8e2cef76111..5da9b6febdc 100644
--- a/src/devices/cpu/unsp/unspfe.cpp
+++ b/src/devices/cpu/unsp/unspfe.cpp
@@ -67,6 +67,8 @@ bool unsp_frontend::describe(opcode_desc &desc, const opcode_desc *prev)
case 9: // JA
case 10: // JLE
case 11: // JG
+ case 12: // JVC
+ case 13: // JVS
desc.regin[0] |= 1 << unsp_device::REG_SR;
desc.regout[0] |= 1 << unsp_device::REG_SR;
desc.regout[0] |= 1 << unsp_device::REG_PC;
@@ -186,18 +188,28 @@ bool unsp_frontend::describe(opcode_desc &desc, const opcode_desc *prev)
case 1:
case 2:
case 3:
+ case 4:
+ case 5:
case 8:
case 9:
case 12:
case 14:
case 37:
-
- case 4: // should be 1.2 only but jak_care triggers, see notes in non-drc
- case 5: // ^^
return true;
}
return false;
+ case 0x06:
+ case 0x07: // MULS
+ desc.regin[0] |= 1 << opa;
+ desc.regin[0] |= 1 << opb;
+ desc.regout[0] |= 1 << opa;
+ desc.regout[0] |= 1 << opb;
+ desc.regout[0] |= 1 << unsp_device::REG_R3;
+ desc.regout[0] |= 1 << unsp_device::REG_R4;
+ desc.flags = OPFLAG_READS_MEMORY | OPFLAG_WRITES_MEMORY;
+ return true;
+
default:
return false;
}