summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Andrew Gardner <andrew-gardner@users.noreply.github.com>2013-01-12 20:34:11 +0000
committer Andrew Gardner <andrew-gardner@users.noreply.github.com>2013-01-12 20:34:11 +0000
commit9031b5884216e485cc748825fe5e93fb6c82df69 (patch)
tree7dc0d9454f2b60b104204abc528995f8c26e4618 /src
parent3309f6f59fa567a4b99ed37445b4e11a0eb64adb (diff)
DSP16: Additional opcodes & disassembly fixes. [Andrew Gardner]
Diffstat (limited to 'src')
-rw-r--r--src/emu/cpu/dsp16/dsp16.c82
-rw-r--r--src/emu/cpu/dsp16/dsp16.h17
-rw-r--r--src/emu/cpu/dsp16/dsp16dis.c10
-rw-r--r--src/emu/cpu/dsp16/dsp16ops.c116
4 files changed, 151 insertions, 74 deletions
diff --git a/src/emu/cpu/dsp16/dsp16.c b/src/emu/cpu/dsp16/dsp16.c
index c2cb8b72401..ce0b3907388 100644
--- a/src/emu/cpu/dsp16/dsp16.c
+++ b/src/emu/cpu/dsp16/dsp16.c
@@ -30,42 +30,43 @@ const device_type DSP16 = &device_creator<dsp16_device>;
dsp16_device::dsp16_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: cpu_device(mconfig, DSP16, "DSP16", tag, owner, clock),
- m_program_config("program", ENDIANNESS_LITTLE, 16, 16, -1),
- m_data_config("data", ENDIANNESS_LITTLE, 16, 16, -1),
- m_i(0),
- m_pc(0),
- m_pt(0),
- m_pr(0),
- m_pi(0),
- m_j(0),
- m_k(0),
- m_rb(0),
- m_re(0),
- m_r0(0),
- m_r1(0),
- m_r2(0),
- m_r3(0),
- m_x(0),
- m_y(0),
- m_p(0),
- m_a0(0),
- m_a1(0),
- m_auc(0),
- m_psw(0),
- m_c0(0),
- m_c1(0),
- m_c2(0),
- m_sioc(0),
- m_pioc(0),
- m_ppc(0),
- m_cacheStart(CACHE_INVALID),
- m_cacheEnd(CACHE_INVALID),
- m_cacheRedoNextPC(CACHE_INVALID),
- m_cacheIterations(0),
- m_program(NULL),
- m_data(NULL),
- m_direct(NULL),
- m_icount(0)
+ m_program_config("program", ENDIANNESS_LITTLE, 16, 16, -1),
+ m_data_config("data", ENDIANNESS_LITTLE, 16, 16, -1),
+ m_i(0),
+ m_pc(0),
+ m_pt(0),
+ m_pr(0),
+ m_pi(0),
+ m_j(0),
+ m_k(0),
+ m_rb(0),
+ m_re(0),
+ m_r0(0),
+ m_r1(0),
+ m_r2(0),
+ m_r3(0),
+ m_x(0),
+ m_y(0),
+ m_p(0),
+ m_a0(0),
+ m_a1(0),
+ m_auc(0),
+ m_psw(0),
+ m_c0(0),
+ m_c1(0),
+ m_c2(0),
+ m_sioc(0),
+ m_srta(0),
+ m_pioc(0),
+ m_ppc(0),
+ m_cacheStart(CACHE_INVALID),
+ m_cacheEnd(CACHE_INVALID),
+ m_cacheRedoNextPC(CACHE_INVALID),
+ m_cacheIterations(0),
+ m_program(NULL),
+ m_data(NULL),
+ m_direct(NULL),
+ m_icount(0)
{
// Allocate & setup
}
@@ -106,6 +107,7 @@ void dsp16_device::device_start()
state_add(DSP16_C1, "C1", m_c1);
state_add(DSP16_C2, "C2", m_c2);
state_add(DSP16_SIOC, "SIOC", m_sioc).formatstr("%16s");
+ state_add(DSP16_SRTA, "SRTA", m_srta);
state_add(DSP16_PIOC, "PIOC", m_pioc); //.formatstr("%16s");
// register our state for saving
@@ -133,6 +135,7 @@ void dsp16_device::device_start()
save_item(NAME(m_c1));
save_item(NAME(m_c2));
save_item(NAME(m_sioc));
+ save_item(NAME(m_srta));
save_item(NAME(m_pioc));
save_item(NAME(m_ppc));
save_item(NAME(m_cacheStart));
@@ -159,6 +162,7 @@ void dsp16_device::device_reset()
// Page 7-5
m_pc = 0x0000;
m_sioc = 0x0000;
+ // SRTA is unaltered by reset
m_pioc = 0x0008;
m_rb = 0x0000;
m_re = 0x0000;
@@ -182,8 +186,8 @@ void dsp16_device::device_reset()
const address_space_config *dsp16_device::memory_space_config(address_spacenum spacenum) const
{
return (spacenum == AS_PROGRAM) ? &m_program_config :
- (spacenum == AS_DATA) ? &m_data_config :
- NULL;
+ (spacenum == AS_DATA) ? &m_data_config :
+ NULL;
}
@@ -312,7 +316,7 @@ void dsp16_device::execute_run()
do
{
// debugging
- m_ppc = m_pc; // copy PC to previous PC
+ m_ppc = m_pc; // copy PC to previous PC
debugger_instruction_hook(this, m_pc);
// instruction fetch & execute
diff --git a/src/emu/cpu/dsp16/dsp16.h b/src/emu/cpu/dsp16/dsp16.h
index 4b83dd07be6..09f27800eb3 100644
--- a/src/emu/cpu/dsp16/dsp16.h
+++ b/src/emu/cpu/dsp16/dsp16.h
@@ -55,7 +55,7 @@ protected:
// CPU registers
// ROM Address Arithmetic Unit (XAAU)
- UINT16 m_i; // 12 bits
+ UINT16 m_i; // 12 bits
UINT16 m_pc;
UINT16 m_pt;
UINT16 m_pr;
@@ -73,15 +73,16 @@ protected:
UINT16 m_x;
UINT32 m_y;
UINT32 m_p;
- UINT64 m_a0; // 36 bits
- UINT64 m_a1; // 36 bits
- UINT8 m_auc; // 6 bits
+ UINT64 m_a0; // 36 bits
+ UINT64 m_a1; // 36 bits
+ UINT8 m_auc; // 6 bits
UINT16 m_psw;
UINT8 m_c0;
UINT8 m_c1;
UINT8 m_c2;
// Serial and parallel interfaces
UINT16 m_sioc;
+ UINT16 m_srta;
UINT16 m_pioc;
// internal stuff
@@ -123,6 +124,7 @@ protected:
// helpers
void* addressYL();
void writeRegister(void* reg, const UINT16& value);
+ bool conditionTest(const UINT8& CON);
};
@@ -136,12 +138,12 @@ extern const device_type DSP16;
enum
{
- DSP16_I, // ROM Address Arithmetic Unit (XAAU)
+ DSP16_I, // ROM Address Arithmetic Unit (XAAU)
DSP16_PC,
DSP16_PT,
DSP16_PR,
DSP16_PI,
- DSP16_J, // RAM Address Arithmetic Unit (YAAU)
+ DSP16_J, // RAM Address Arithmetic Unit (YAAU)
DSP16_K,
DSP16_RB,
DSP16_RE,
@@ -149,7 +151,7 @@ enum
DSP16_R1,
DSP16_R2,
DSP16_R3,
- DSP16_X, // Data Arithmetic Unit (DAU)
+ DSP16_X, // Data Arithmetic Unit (DAU)
DSP16_Y,
DSP16_P,
DSP16_A0,
@@ -160,6 +162,7 @@ enum
DSP16_C1,
DSP16_C2,
DSP16_SIOC,
+ DSP16_SRTA,
DSP16_PIOC
};
diff --git a/src/emu/cpu/dsp16/dsp16dis.c b/src/emu/cpu/dsp16/dsp16dis.c
index 1be3ad654dd..f8669164430 100644
--- a/src/emu/cpu/dsp16/dsp16dis.c
+++ b/src/emu/cpu/dsp16/dsp16dis.c
@@ -111,7 +111,7 @@ astring disasmF2Field(const UINT8& F2, const UINT8& D, const UINT8& S)
default: return "UNKNOWN";
}
- return "";
+ return ret;
}
astring disasmCONField(const UINT8& CON)
@@ -234,8 +234,8 @@ bool disasmSIField(const UINT8& SI)
{
switch (SI)
{
- case 0x00: return 0; // Not a software interrupt
- case 0x01: return 1; // Software Interrupt
+ case 0x00: return 0; // Not a software interrupt
+ case 0x01: return 1; // Software Interrupt
}
return false;
}
@@ -270,13 +270,15 @@ CPU_DISASSEMBLE( dsp16a )
{
// F1 Y=a0[1] | F1 Y=a1[1]
const UINT8 Y = (op & 0x000f);
+ const UINT8 X = (op & 0x0010) >> 4;
const UINT8 S = (op & 0x0200) >> 9;
const UINT8 D = (op & 0x0400) >> 10;
const UINT8 F1 = (op & 0x01e0) >> 5;
astring yString = disasmYField(Y);
astring fString = disasmF1Field(F1, D, S);
astring aString = (opcode == 0x1c) ? "a0" : "a1";
- sprintf(buffer, "%s = %s, %s", yString.cstr(), aString.cstr(), fString.cstr());
+ astring xString = (X) ? "" : "l";
+ sprintf(buffer, "%s = %s%s, %s", yString.cstr(), aString.cstr(), xString.cstr(), fString.cstr());
break;
}
case 0x16:
diff --git a/src/emu/cpu/dsp16/dsp16ops.c b/src/emu/cpu/dsp16/dsp16ops.c
index 3f4523b0a3b..7170d9e6474 100644
--- a/src/emu/cpu/dsp16/dsp16ops.c
+++ b/src/emu/cpu/dsp16/dsp16ops.c
@@ -45,6 +45,34 @@ void dsp16_device::writeRegister(void* reg, const UINT16 &value)
}
+bool dsp16_device::conditionTest(const UINT8& CON)
+{
+ switch (CON)
+ {
+ case 0x00: return (m_psw & 0x8000);
+ case 0x01: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
+ case 0x02: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
+ case 0x03: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
+ case 0x04: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
+ case 0x05: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
+ case 0x06: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
+ case 0x07: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
+ case 0x08: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
+ case 0x09: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
+ case 0x0a: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
+ case 0x0b: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
+ case 0x0c: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
+ case 0x0d: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
+ case 0x0e: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
+ case 0x0f: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
+ case 0x10: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
+ case 0x11: printf("UNIMPLEMENTED condition check @ PC 0x%04x\n", m_pc); return false;
+ default: logerror("Unrecognized condition at PC=0x%04x\n", m_pc); break;
+ }
+ return false;
+}
+
+
void* dsp16_device::registerFromRImmediateField(const UINT8& R)
{
switch (R)
@@ -90,7 +118,7 @@ void* dsp16_device::registerFromRTable(const UINT8 &R)
case 0x16: return (void*)&m_c1;
case 0x17: return (void*)&m_c2;
case 0x18: return (void*)&m_sioc;
- //case 0x19: return (void*)&m_srta;
+ case 0x19: return (void*)&m_srta;
//case 0x1a: return (void*)&m_sdx;
//case 0x1b: return (void*)&m_tdms;
case 0x1c: return (void*)&m_pioc;
@@ -109,20 +137,20 @@ void dsp16_device::executeF1Field(const UINT8& F1, const UINT8& D, const UINT8&
//UINT64* destinationReg = NULL;
//switch (D)
//{
- // case 0x00: destinationReg = &m_a0;
- // case 0x01: destinationReg = &m_a1;
- // default: break;
+ // case 0x00: destinationReg = &m_a0;
+ // case 0x01: destinationReg = &m_a1;
+ // default: break;
//}
// Which source is being used?
//UINT64* sourceReg = NULL;
//switch (S)
//{
- // case 0x00: sourceReg = &m_a0;
- // case 0x01: sourceReg = &m_a1;
- // default: break;
+ // case 0x00: sourceReg = &m_a0;
+ // case 0x01: sourceReg = &m_a1;
+ // default: break;
//}
-
+
switch (F1)
{
case 0x00: printf("UNIMPLEMENTED F1 operation @ PC 0x%04x\n", m_pc); break;
@@ -173,7 +201,7 @@ void dsp16_device::executeYFieldPost(const UINT8& Y)
case 0x03: opReg = &m_r3; break;
default: break;
}
-
+
const UINT8 lower = Y & 0x03;
switch (lower)
{
@@ -209,11 +237,27 @@ void dsp16_device::execute_one(const UINT16& op, UINT8& cycles, UINT8& pcAdvance
}
case 0x04: case 0x1c:
{
- // F1 Y=a0[1] | F1 Y=a1[1]
- //const UINT8 Y = (op & 0x000f);
- //const UINT8 S = (op & 0x0200) >> 9;
- //const UINT8 D = (op & 0x0400) >> 10;
- //const UINT8 F1 = (op & 0x01e0) >> 5;
+ // F1 Y=a0[1] | F1 Y=a1[1] : (page 3-40)
+ const UINT8 Y = (op & 0x000f);
+ const UINT8 X = (op & 0x0010) >> 4;
+ const UINT8 S = (op & 0x0200) >> 9;
+ const UINT8 D = (op & 0x0400) >> 10;
+ const UINT8 F1 = (op & 0x01e0) >> 5;
+ UINT16* destinationReg = (UINT16*)registerFromYFieldUpper(Y);
+ UINT16 aRegValue = 0x0000;
+ if (op & 0xc000)
+ {
+ aRegValue = (X) ? (m_a0 & 0x0ffff0000) >> 16 : m_a0 & 0x00000ffff;
+ }
+ else
+ {
+ aRegValue = (X) ? (m_a1 & 0x0ffff0000) >> 16 : m_a1 & 0x00000ffff;
+ }
+ data_write(*destinationReg, aRegValue);
+ executeYFieldPost(Y);
+ executeF1Field(F1, D, S);
+ cycles = 2;
+ pcAdvance = 1;
break;
}
case 0x16:
@@ -259,7 +303,8 @@ void dsp16_device::execute_one(const UINT16& op, UINT8& cycles, UINT8& pcAdvance
}
case 0x19: case 0x1b:
{
- // F1, y = a0|1, x = *pt++[i]
+ // NEXT!
+ // F1, y = a0|1, x = *pt++[i] : (page 3-48)
//const UINT8 Y = (op & 0x000f);
//const UINT8 X = (op & 0x0010) >> 4;
//const UINT8 S = (op & 0x0200) >> 9;
@@ -355,10 +400,17 @@ void dsp16_device::execute_one(const UINT16& op, UINT8& cycles, UINT8& pcAdvance
case 0x13:
{
// if|ifc CON F2
- //const UINT8 CON = (op & 0x001f);
+ const UINT8 CON = (op & 0x001f);
//const UINT8 S = (op & 0x0200) >> 9;
//const UINT8 D = (op & 0x0400) >> 10;
//const UINT8 F2 = (op & 0x01e0) >> 5;
+ bool conditionFulfilled = conditionTest(CON);
+ if (conditionFulfilled)
+ {
+ printf("Fulfilled condition not yet implemented @ PC=0x%04x", m_pc);
+ }
+ cycles = 1;
+ pcAdvance = 1;
break;
}
@@ -387,8 +439,18 @@ void dsp16_device::execute_one(const UINT16& op, UINT8& cycles, UINT8& pcAdvance
// Format 5: Branch Indirect Group
case 0x18:
{
- // goto B
- //const UINT8 B = (op & 0x0700) >> 8;
+ // goto B : (page 3-21)
+ const UINT8 B = (op & 0x0700) >> 8;
+ switch (B)
+ {
+ case 0x00: m_pc = m_pr; break;
+ case 0x01: printf("UNIMPLEMENTED branch instruction @ PC 0x%04x\n", m_pc); break;
+ case 0x02: printf("UNIMPLEMENTED branch instruction @ PC 0x%04x\n", m_pc); break;
+ case 0x03: printf("UNIMPLEMENTED branch instruction @ PC 0x%04x\n", m_pc); break;
+ default: logerror("DSP16: Invalid branch indirect instruction executed at PC=0x%04x\n.", m_pc); break;
+ }
+ cycles = 2;
+ pcAdvance = 0;
break;
}
@@ -417,9 +479,15 @@ void dsp16_device::execute_one(const UINT16& op, UINT8& cycles, UINT8& pcAdvance
}
case 0x0f:
{
- // R = Y
- //const UINT8 Y = (op & 0x000f);
- //const UINT8 R = (op & 0x03f0) >> 4;
+ // R = Y : (page 3-32)
+ const UINT8 Y = (op & 0x000f);
+ const UINT8 R = (op & 0x03f0) >> 4;
+ UINT16* sourceReg = (UINT16*)registerFromYFieldUpper(Y);
+ void* destinationReg = registerFromRTable(R);
+ writeRegister(destinationReg, data_read(*sourceReg));
+ executeYFieldPost(Y);
+ cycles = 2;
+ pcAdvance = 1;
break;
}
case 0x0c:
@@ -463,7 +531,7 @@ void dsp16_device::execute_one(const UINT16& op, UINT8& cycles, UINT8& pcAdvance
const INT8 M = (op & 0x00ff);
const UINT8 R = (op & 0x0e00) >> 9;
void* reg = registerFromRImmediateField(R);
- writeRegister(reg, (INT16)M); // Sign extend 8 bit int
+ writeRegister(reg, (INT16)M); // Sign extend 8 bit int
cycles = 1;
pcAdvance = 1;
break;
@@ -480,14 +548,14 @@ void dsp16_device::execute_one(const UINT16& op, UINT8& cycles, UINT8& pcAdvance
// Do
m_cacheStart = m_pc + 1;
m_cacheEnd = m_pc + NI + 1;
- m_cacheIterations = K-1; // -1 because we check the counter below
+ m_cacheIterations = K-1; // -1 because we check the counter below
cycles = 1;
pcAdvance = 1;
}
else
{
// Redo
- m_cacheIterations = K-1; // -1 because we check the counter below
+ m_cacheIterations = K-1; // -1 because we check the counter below
m_cacheRedoNextPC = m_pc + 1;
m_pc = m_cacheStart;
pcAdvance = 0;