summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/lc8670
diff options
context:
space:
mode:
author Olivier Galibert <galibert@pobox.com>2017-07-05 11:44:49 +0200
committer Olivier Galibert <galibert@pobox.com>2017-11-26 17:41:27 +0100
commit6caef2579a1490f05d28bcede731cbdd45fc5c65 (patch)
tree8055384e183be3cb27e7d0894ac53dc96c09e6fa /src/devices/cpu/lc8670
parent34b222062c89adbeed822f56be6130421777e11f (diff)
dvdisasm: Overhaul [O. Galibert]
Disassemblers are now independant classes. Not only the code is cleaner, but unidasm has access to all the cpu cores again. The interface to the disassembly method has changed from byte buffers to objects that give a result to read methods. This also adds support for lfsr and/or paged PCs.
Diffstat (limited to 'src/devices/cpu/lc8670')
-rw-r--r--src/devices/cpu/lc8670/lc8670.cpp6
-rw-r--r--src/devices/cpu/lc8670/lc8670.h32
-rw-r--r--src/devices/cpu/lc8670/lc8670dsm.cpp61
-rw-r--r--src/devices/cpu/lc8670/lc8670dsm.h54
4 files changed, 102 insertions, 51 deletions
diff --git a/src/devices/cpu/lc8670/lc8670.cpp b/src/devices/cpu/lc8670/lc8670.cpp
index c78a0acd4c8..e93c134cab5 100644
--- a/src/devices/cpu/lc8670/lc8670.cpp
+++ b/src/devices/cpu/lc8670/lc8670.cpp
@@ -18,6 +18,7 @@
#include "emu.h"
#include "debugger.h"
#include "lc8670.h"
+#include "lc8670dsm.h"
//***************************************************************************
// DEBUGGING
@@ -1777,3 +1778,8 @@ int lc8670_cpu_device::op_xor()
return 1;
}
+
+util::disasm_interface *lc8670_cpu_device::create_disassembler()
+{
+ return new lc8670_disassembler;
+}
diff --git a/src/devices/cpu/lc8670/lc8670.h b/src/devices/cpu/lc8670/lc8670.h
index a6de4f7c98a..40727da5fb9 100644
--- a/src/devices/cpu/lc8670/lc8670.h
+++ b/src/devices/cpu/lc8670/lc8670.h
@@ -115,9 +115,7 @@ protected:
virtual space_config_vector memory_space_config() const override;
// device_disasm_interface overrides
- virtual uint32_t disasm_min_opcode_bytes() const override { return 1; }
- virtual uint32_t disasm_max_opcode_bytes() const override { return 4; }
- virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) override;
+ virtual util::disasm_interface *create_disassembler() override;
private:
// helpers
@@ -142,7 +140,6 @@ private:
void timer0_tick(bool ext_line = false);
void timer1_tick();
void base_timer_tick();
- static void dasm_arg(uint8_t op, char *buffer, offs_t pc, int arg, const uint8_t *oprom, int &pos);
// opcodes handlers
int op_nop();
@@ -240,33 +237,6 @@ private:
// opcodes table
typedef int (lc8670_cpu_device::*op_handler)();
static const op_handler s_opcode_table[80];
-
- // disassembler
- enum
- {
- OP_NULL,
- OP_R8,
- OP_R8RI,
- OP_R16,
- OP_RI,
- OP_A12,
- OP_A16,
- OP_I8,
- OP_B3,
- OP_D9,
- OP_D9B3,
- OP_RII8
- };
-
- // disasm table
- struct dasm_entry
- {
- const char *str;
- uint8_t arg1;
- uint8_t arg2;
- bool inv;
- };
- static const dasm_entry s_dasm_table[80];
};
DECLARE_DEVICE_TYPE(LC8670, lc8670_cpu_device)
diff --git a/src/devices/cpu/lc8670/lc8670dsm.cpp b/src/devices/cpu/lc8670/lc8670dsm.cpp
index d1a223fc3a8..540b4d55377 100644
--- a/src/devices/cpu/lc8670/lc8670dsm.cpp
+++ b/src/devices/cpu/lc8670/lc8670dsm.cpp
@@ -7,10 +7,14 @@
******************************************************************************/
#include "emu.h"
-#include "debugger.h"
-#include "lc8670.h"
+#include "lc8670dsm.h"
-const lc8670_cpu_device::dasm_entry lc8670_cpu_device::s_dasm_table[] =
+u32 lc8670_disassembler::opcode_alignment() const
+{
+ return 1;
+}
+
+const lc8670_disassembler::dasm_entry lc8670_disassembler::s_dasm_table[] =
{
{ "NOP" , OP_NULL, OP_NULL, 0 }, // 0x0*
{ "BR" , OP_R8 , OP_NULL, 0 },
@@ -94,7 +98,7 @@ const lc8670_cpu_device::dasm_entry lc8670_cpu_device::s_dasm_table[] =
{ "SET1", OP_D9B3, OP_NULL, 0 },
};
-void lc8670_cpu_device::dasm_arg(uint8_t op, char *buffer, offs_t pc, int arg, const uint8_t *oprom, int &pos)
+void lc8670_disassembler::dasm_arg(uint8_t op, char *buffer, offs_t pc, int arg, const data_buffer &opcodes, offs_t &pos)
{
switch( arg )
{
@@ -105,71 +109,88 @@ void lc8670_cpu_device::dasm_arg(uint8_t op, char *buffer, offs_t pc, int arg, c
pc++;
// fall through
case OP_R8RI:
- buffer += sprintf(buffer, "%04x", (pc + 1 + oprom[pos] - (oprom[pos]&0x80 ? 0x100 : 0)) & 0xffff);
+ buffer += sprintf(buffer, "%04x", (pc + 1 + opcodes.r8(pos) - (opcodes.r8(pos)&0x80 ? 0x100 : 0)) & 0xffff);
pos++;
break;
case OP_R16:
- buffer += sprintf(buffer, "%04x", (pc + 2 + ((oprom[pos+1]<<8) | oprom[pos])) & 0xffff);
+ buffer += sprintf(buffer, "%04x", (pc + 2 + ((opcodes.r8(pos+1)<<8) | opcodes.r8(pos))) & 0xffff);
pos += 2;
break;
case OP_RI:
buffer += sprintf(buffer, "@%x", op & 0x03);
break;
case OP_A12:
- buffer += sprintf(buffer, "%04x", ((pc + 2) & 0xf000) | ((op & 0x10)<<7) | ((op & 0x07)<<8) | oprom[pos]);
+ buffer += sprintf(buffer, "%04x", ((pc + 2) & 0xf000) | ((op & 0x10)<<7) | ((op & 0x07)<<8) | opcodes.r8(pos));
pos++;
break;
case OP_A16:
- buffer += sprintf(buffer, "%04x", (oprom[pos]<<8) | oprom[pos+1]);
+ buffer += sprintf(buffer, "%04x", (opcodes.r8(pos)<<8) | opcodes.r8(pos+1));
pos += 2;
break;
case OP_I8:
- buffer += sprintf(buffer, "#$%02x", oprom[pos++]);
+ buffer += sprintf(buffer, "#$%02x", opcodes.r8(pos++));
break;
case OP_B3:
buffer += sprintf(buffer, "%x", op & 0x07);
break;
case OP_D9:
- buffer += sprintf(buffer, "($%03x)", ((op & 0x01)<<8) | oprom[pos]);
+ buffer += sprintf(buffer, "($%03x)", ((op & 0x01)<<8) | opcodes.r8(pos));
pos++;
break;
case OP_D9B3:
- buffer += sprintf(buffer, "($%03x)", ((op & 0x10)<<4) | oprom[pos]);
+ buffer += sprintf(buffer, "($%03x)", ((op & 0x10)<<4) | opcodes.r8(pos));
buffer += sprintf(buffer, ",%x", op & 0x07);
pos++;
break;
case OP_RII8:
buffer += sprintf(buffer, "@%x", op & 0x03);
- buffer += sprintf(buffer, ",#$%02x", oprom[pos]);
+ buffer += sprintf(buffer, ",#$%02x", opcodes.r8(pos));
pos++;
break;
}
}
//-------------------------------------------------
-// disasm_disassemble - call the disassembly
+// disassemble - call the disassembly
// helper function
//-------------------------------------------------
-offs_t lc8670_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options)
+offs_t lc8670_disassembler::disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer &params)
{
- int pos = 0;
+ offs_t pos = pc;
char arg1[16], arg2[16];
- uint8_t op = oprom[pos++];
+ uint8_t op = opcodes.r8(pos);
+
+ int idx;
+ switch (op & 0x0f)
+ {
+ case 0: case 1:
+ idx = op & 0x0f;
+ break;
+ case 2: case 3:
+ idx = 2;
+ break;
+ case 4: case 5: case 6: case 7:
+ idx = 3;
+ break;
+ default:
+ idx = 4;
+ break;
+ }
- int op_idx = decode_op(op);
+ int op_idx = ((op>>4) & 0x0f) * 5 + idx;
const dasm_entry *inst = &s_dasm_table[op_idx];
util::stream_format(stream, "%-8s", inst->str);
- dasm_arg(op, inst->inv ? arg2 : arg1, pc+0, inst->arg1, oprom, pos);
- dasm_arg(op, inst->inv ? arg1 : arg2, pc+1, inst->arg2, oprom, pos);
+ dasm_arg(op, inst->inv ? arg2 : arg1, pc+0, inst->arg1, opcodes, pos);
+ dasm_arg(op, inst->inv ? arg1 : arg2, pc+1, inst->arg2, opcodes, pos);
stream << arg1;
if (inst->arg2 != OP_NULL)
stream << "," << arg2;
- return pos;
+ return pos - pc;
}
diff --git a/src/devices/cpu/lc8670/lc8670dsm.h b/src/devices/cpu/lc8670/lc8670dsm.h
new file mode 100644
index 00000000000..c59da2add6d
--- /dev/null
+++ b/src/devices/cpu/lc8670/lc8670dsm.h
@@ -0,0 +1,54 @@
+// license:BSD-3-Clause
+// copyright-holders:Sandro Ronco
+/******************************************************************************
+
+ Sanyo LC8670 disassembler
+
+******************************************************************************/
+
+#ifndef MAME_CPU_LC8670_LC8670DSM_H
+#define MAME_CPU_LC8670_LC8670DSM_H
+
+#pragma once
+
+class lc8670_disassembler : public util::disasm_interface
+{
+public:
+ lc8670_disassembler() = default;
+ virtual ~lc8670_disassembler() = default;
+
+ virtual u32 opcode_alignment() const override;
+ virtual offs_t disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer &params) override;
+
+private:
+ // disassembler
+ enum
+ {
+ OP_NULL,
+ OP_R8,
+ OP_R8RI,
+ OP_R16,
+ OP_RI,
+ OP_A12,
+ OP_A16,
+ OP_I8,
+ OP_B3,
+ OP_D9,
+ OP_D9B3,
+ OP_RII8
+ };
+
+ // disasm table
+ struct dasm_entry
+ {
+ const char *str;
+ uint8_t arg1;
+ uint8_t arg2;
+ bool inv;
+ };
+ static const dasm_entry s_dasm_table[80];
+
+ void dasm_arg(uint8_t op, char *buffer, offs_t pc, int arg, const data_buffer &opcodes, offs_t &pos);
+};
+
+#endif