summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/ks0164/ks0164d.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/cpu/ks0164/ks0164d.cpp')
-rw-r--r--src/devices/cpu/ks0164/ks0164d.cpp71
1 files changed, 33 insertions, 38 deletions
diff --git a/src/devices/cpu/ks0164/ks0164d.cpp b/src/devices/cpu/ks0164/ks0164d.cpp
index 5aeb65caec4..dfdb4e79ce7 100644
--- a/src/devices/cpu/ks0164/ks0164d.cpp
+++ b/src/devices/cpu/ks0164/ks0164d.cpp
@@ -20,6 +20,11 @@ s32 ks0164_disassembler::off10(u32 opcode)
return opcode & 0x200 ? opcode | 0xfffffc00 : opcode & 0x3ff;
}
+std::string ks0164_disassembler::imm8(s8 dt)
+{
+ return dt < 0 ? util::string_format("-%x", -dt) : util::string_format("%x", dt);
+}
+
std::string ks0164_disassembler::off16(s16 dt)
{
return dt < 0 ? util::string_format(" - %x", -dt) : dt ? util::string_format(" + %x", dt) : "";
@@ -35,7 +40,7 @@ const ks0164_disassembler::instruction ks0164_disassembler::instructions[] {
{ 0x1400, 0xfc00, [](P) -> u32 { util::stream_format(stream, "bmi %04x", (pc + 2 + off10(opcode)) & 0xffff); return 2; } },
{ 0x1800, 0xfc00, [](P) -> u32 { util::stream_format(stream, "bvc %04x", (pc + 2 + off10(opcode)) & 0xffff); return 2; } },
{ 0x1c00, 0xfc00, [](P) -> u32 { util::stream_format(stream, "bvs %04x", (pc + 2 + off10(opcode)) & 0xffff); return 2; } },
- { 0x2000, 0xfc00, [](P) -> u32 { util::stream_format(stream, "b?8 %04x", (pc + 2 + off10(opcode)) & 0xffff); return 2; } },
+ { 0x2000, 0xfc00, [](P) -> u32 { util::stream_format(stream, "bnv %04x", (pc + 2 + off10(opcode)) & 0xffff); return 2; } },
{ 0x2400, 0xfc00, [](P) -> u32 { util::stream_format(stream, "bgtu %04x", (pc + 2 + off10(opcode)) & 0xffff); return 2; } },
{ 0x2800, 0xfc00, [](P) -> u32 { util::stream_format(stream, "bleu %04x", (pc + 2 + off10(opcode)) & 0xffff); return 2; } },
{ 0x2c00, 0xfc00, [](P) -> u32 { util::stream_format(stream, "bgts %04x", (pc + 2 + off10(opcode)) & 0xffff); return 2; } },
@@ -44,14 +49,14 @@ const ks0164_disassembler::instruction ks0164_disassembler::instructions[] {
{ 0x3800, 0xfc00, [](P) -> u32 { util::stream_format(stream, "blts %04x", (pc + 2 + off10(opcode)) & 0xffff); return 2; } },
{ 0x3c00, 0xfc00, [](P) -> u32 { util::stream_format(stream, "bra %04x", (pc + 2 + off10(opcode)) & 0xffff); return 2; } },
- { 0x4000, 0xf800, [](P) -> u32 { util::stream_format(stream, "%s += %02x", regs[(opcode >> 8) & 7], opcode & 0xff); return 2; } },
- { 0x4800, 0xf800, [](P) -> u32 { util::stream_format(stream, "%s -= %02x", regs[(opcode >> 8) & 7], opcode & 0xff); return 2; } },
- { 0x5000, 0xf800, [](P) -> u32 { util::stream_format(stream, "cmp %s, %02x", regs[(opcode >> 8) & 7], opcode & 0xff); return 2; } },
- { 0x5800, 0xf800, [](P) -> u32 { util::stream_format(stream, "%s &= %02x", regs[(opcode >> 8) & 7], opcode & 0xff); return 2; } },
- { 0x6000, 0xf800, [](P) -> u32 { util::stream_format(stream, "%s |= %02x", regs[(opcode >> 8) & 7], opcode & 0xff); return 2; } },
- { 0x6800, 0xf800, [](P) -> u32 { util::stream_format(stream, "%s ?5 %02x", regs[(opcode >> 8) & 7], opcode & 0xff); return 2; } },
- { 0x7000, 0xf800, [](P) -> u32 { util::stream_format(stream, "%s = %02x", regs[(opcode >> 8) & 7], opcode & 0xff); return 2; } },
- { 0x7800, 0xf800, [](P) -> u32 { util::stream_format(stream, "%s *= %02x", regs[(opcode >> 8) & 7], opcode & 0xff); return 2; } },
+ { 0x4000, 0xf800, [](P) -> u32 { util::stream_format(stream, "%s += %s", regs[(opcode >> 8) & 7], imm8(opcode)); return 2; } },
+ { 0x4800, 0xf800, [](P) -> u32 { util::stream_format(stream, "%s -= %s", regs[(opcode >> 8) & 7], imm8(opcode)); return 2; } },
+ { 0x5000, 0xf800, [](P) -> u32 { util::stream_format(stream, "cmp %s, %s", regs[(opcode >> 8) & 7], imm8(opcode)); return 2; } },
+ { 0x5800, 0xf800, [](P) -> u32 { util::stream_format(stream, "%s &= %s", regs[(opcode >> 8) & 7], imm8(opcode)); return 2; } },
+ { 0x6000, 0xf800, [](P) -> u32 { util::stream_format(stream, "%s |= %s", regs[(opcode >> 8) & 7], imm8(opcode)); return 2; } },
+ { 0x6800, 0xf800, [](P) -> u32 { util::stream_format(stream, "%s ^= %s", regs[(opcode >> 8) & 7], imm8(opcode)); return 2; } },
+ { 0x7000, 0xf800, [](P) -> u32 { util::stream_format(stream, "%s = %s", regs[(opcode >> 8) & 7], imm8(opcode)); return 2; } },
+ { 0x7800, 0xf800, [](P) -> u32 { util::stream_format(stream, "%s *= %s", regs[(opcode >> 8) & 7], imm8(opcode)); return 2; } },
{ 0x8004, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s += %s.bu", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
{ 0x8084, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s += %s.bs", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
@@ -68,9 +73,9 @@ const ks0164_disassembler::instruction ks0164_disassembler::instructions[] {
{ 0xa004, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s |= %s.bu", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
{ 0xa084, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s |= %s.bs", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
{ 0xa00c, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s |= %s", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
- { 0xa804, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s ?5 %s.bu", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
- { 0xa884, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s ?5 %s.bs", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
- { 0xa80c, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s ?5 %s", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0xa804, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s ^= %s.bu", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0xa884, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s ^= %s.bs", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0xa80c, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s ^= %s", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
{ 0xb004, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s = %s.bu", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
{ 0xb084, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s = %s.bs", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
{ 0xb00c, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s = %s", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
@@ -88,8 +93,8 @@ const ks0164_disassembler::instruction ks0164_disassembler::instructions[] {
{ 0x987d, 0xf8ff, [](P) -> u32 { u16 imm = opcodes.r16(pc+2); util::stream_format(stream, "%s &= %04x", regs[(opcode >> 8) & 7], imm); return 4; } },
{ 0xa075, 0xf8ff, [](P) -> u32 { u16 imm = opcodes.r16(pc+2); util::stream_format(stream, "%s |= %02x", regs[(opcode >> 8) & 7], imm); return 4; } },
{ 0xa07d, 0xf8ff, [](P) -> u32 { u16 imm = opcodes.r16(pc+2); util::stream_format(stream, "%s |= %04x", regs[(opcode >> 8) & 7], imm); return 4; } },
- { 0xa875, 0xf8ff, [](P) -> u32 { u16 imm = opcodes.r16(pc+2); util::stream_format(stream, "%s ?5 %02x", regs[(opcode >> 8) & 7], imm); return 4; } },
- { 0xa87d, 0xf8ff, [](P) -> u32 { u16 imm = opcodes.r16(pc+2); util::stream_format(stream, "%s ?5 %04x", regs[(opcode >> 8) & 7], imm); return 4; } },
+ { 0xa875, 0xf8ff, [](P) -> u32 { u16 imm = opcodes.r16(pc+2); util::stream_format(stream, "%s ^= %02x", regs[(opcode >> 8) & 7], imm); return 4; } },
+ { 0xa87d, 0xf8ff, [](P) -> u32 { u16 imm = opcodes.r16(pc+2); util::stream_format(stream, "%s ^= %04x", regs[(opcode >> 8) & 7], imm); return 4; } },
{ 0xb075, 0xf8ff, [](P) -> u32 { u16 imm = opcodes.r16(pc+2); util::stream_format(stream, "%s = %02x", regs[(opcode >> 8) & 7], imm); return 4; } },
{ 0xb07d, 0xf8ff, [](P) -> u32 { u16 imm = opcodes.r16(pc+2); util::stream_format(stream, "%s = %04x", regs[(opcode >> 8) & 7], imm); return 4; } },
{ 0xb875, 0xf8ff, [](P) -> u32 { u16 imm = opcodes.r16(pc+2); util::stream_format(stream, "%s *u= %02x", regs[(opcode >> 8) & 7], imm); return 4; } },
@@ -111,9 +116,9 @@ const ks0164_disassembler::instruction ks0164_disassembler::instructions[] {
{ 0xa006, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s |= (%s).bu", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
{ 0xa086, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s |= (%s).bs", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
{ 0xa00e, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s |= (%s).w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
- { 0xa806, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s ?5 (%s).bu", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
- { 0xa886, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s ?5 (%s).bs", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
- { 0xa80e, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s ?5 (%s).w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0xa806, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s ^= (%s).bu", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0xa886, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s ^= (%s).bs", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
+ { 0xa80e, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s ^= (%s).w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
{ 0xb006, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s = (%s).bu", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
{ 0xb086, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s = (%s).bs", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
{ 0xb00e, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s = (%s).w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]); return 2; } },
@@ -136,9 +141,9 @@ const ks0164_disassembler::instruction ks0164_disassembler::instructions[] {
{ 0xa077, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s |= (%04x).bu", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
{ 0xa0f7, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s |= (%04x).bs", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
{ 0xa07f, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s |= (%04x).w", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
- { 0xa877, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s ?5 (%04x).bu", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
- { 0xa8f7, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s ?5 (%04x).bs", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
- { 0xa87f, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s ?5 (%04x).w", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
+ { 0xa877, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s ^= (%04x).bu", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
+ { 0xa8f7, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s ^= (%04x).bs", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
+ { 0xa87f, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s ^= (%04x).w", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
{ 0xb077, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s = (%04x).bu", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
{ 0xb0f7, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s = (%04x).bs", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
{ 0xb07f, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s = (%04x).w", regs[(opcode >> 8) & 7], opcodes.r16(pc+2)); return 4; } },
@@ -161,9 +166,9 @@ const ks0164_disassembler::instruction ks0164_disassembler::instructions[] {
{ 0xa007, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s |= (%s%s).bu", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
{ 0xa087, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s |= (%s%s).bs", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
{ 0xa00f, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s |= (%s%s).w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
- { 0xa807, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s ?5 (%s%s).bu", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
- { 0xa887, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s ?5 (%s%s).bs", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
- { 0xa80f, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s ?5 (%s%s).w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
+ { 0xa807, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s ^= (%s%s).bu", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
+ { 0xa887, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s ^= (%s%s).bs", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
+ { 0xa80f, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s ^= (%s%s).w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
{ 0xb007, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s = (%s%s).bu", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
{ 0xb087, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s = (%s%s).bs", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
{ 0xb00f, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s = (%s%s).w", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], off16(opcodes.r16(pc+2))); return 4; } },
@@ -188,9 +193,9 @@ const ks0164_disassembler::instruction ks0164_disassembler::instructions[] {
{ 0xd088, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s = maxs(%s, %04x)", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], opcodes.r16(pc+2)); return 4; } },
{ 0xd888, 0xf88f, [](P) -> u32 { util::stream_format(stream, "%s = mins(%s, %04x)", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7], opcodes.r16(pc+2)); return 4; } },
{ 0xd001, 0xffff, [](P) -> u32 { util::stream_format(stream, "jmp %04x", opcodes.r16(pc+2)); return 4; } },
- { 0xd002, 0xffff, [](P) -> u32 { util::stream_format(stream, "jsr %04x", opcodes.r16(pc+2)); return 4; } },
- { 0xd003, 0xffff, [](P) -> u32 { util::stream_format(stream, "rts"); return 2; } },
- { 0xd004, 0xffff, [](P) -> u32 { util::stream_format(stream, "rti"); return 2; } },
+ { 0xd002, 0xffff, [](P) -> u32 { util::stream_format(stream, "jsr %04x", opcodes.r16(pc+2)); return 4 | STEP_OVER; } },
+ { 0xd003, 0xffff, [](P) -> u32 { util::stream_format(stream, "rts"); return 2 | STEP_OUT; } },
+ { 0xd004, 0xffff, [](P) -> u32 { util::stream_format(stream, "rti"); return 2 | STEP_OUT; } },
{ 0xd005, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s = ~%s", regs[(opcode >> 8) & 7], regs[(opcode >> 8) & 7]); return 2; } },
{ 0xd085, 0xf8ff, [](P) -> u32 { util::stream_format(stream, "%s = -%s", regs[(opcode >> 8) & 7], regs[(opcode >> 8) & 7]); return 2; } },
@@ -225,16 +230,6 @@ offs_t ks0164_disassembler::disassemble(std::ostream &stream, offs_t pc, const d
for(u32 i=0;; i++)
if((opcode & instructions[i].mask) == instructions[i].value)
- return instructions[i].cb(stream, opcode, opcodes, pc);
-
- abort();
-
-#if 0
- } else if((opcode & 0xf80f) == 0xc800) // c808?
- util::stream_format(stream, "store.w -(%s), %s", regs[(opcode >> 4) & 7], regs[(opcode >> 7) & 7]);
-
- else if( (opcode & 0xf88f) == 0xc00a)
- util::stream_format(stream, "load.w %s, (%s)+ ?2", regs[(opcode >> 8) & 7], regs[(opcode >> 4) & 7]);
-
-#endif
+ return instructions[i].cb(stream, opcode, opcodes, pc) | SUPPORTED;
+ return 0;
}