summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/lh5801
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/cpu/lh5801')
-rw-r--r--src/devices/cpu/lh5801/5801dasm.cpp203
-rw-r--r--src/devices/cpu/lh5801/5801dasm.h110
-rw-r--r--src/devices/cpu/lh5801/lh5801.cpp6
-rw-r--r--src/devices/cpu/lh5801/lh5801.h4
4 files changed, 172 insertions, 151 deletions
diff --git a/src/devices/cpu/lh5801/5801dasm.cpp b/src/devices/cpu/lh5801/5801dasm.cpp
index 2cf6f105b8d..f289f4760a0 100644
--- a/src/devices/cpu/lh5801/5801dasm.cpp
+++ b/src/devices/cpu/lh5801/5801dasm.cpp
@@ -9,104 +9,14 @@
*****************************************************************************/
#include "emu.h"
-#include "debugger.h"
-
-#include "lh5801.h"
+#include "5801dasm.h"
#if defined(SEC)
#undef SEC
#endif
-namespace {
-
-class Entry
-{
-public:
- enum Ins
- {
- ILL, ILL2, PREFD, NOP,
-
- LDA, STA, LDI, LDX, STX,
- LDE, SDE, LIN, SIN,
- TIN, // (x++)->(y++)
- ADC, ADI, ADR, SBC, SBI,
- DCA, DCS, // bcd add and sub
- CPA, CPI, CIN, // A compared with (x++)
- AND, ANI, ORA, ORI, EOR, EAI, BIT, BII,
- INC, DEC,
- DRL, DRR, // digit rotates
- ROL, ROR,
- SHL, SHR,
- AEX, // A nibble swap
-
- BCR, BCS, BHR, BHS, BZR, BZS, BVR, BVS,
- BCH, LOP, // loop with ul
- JMP, SJP, RTN, RTI, HLT,
- VCR, VCS, VHR, VHS, VVS, VZR, VZS,
- VMJ, VEJ,
- PSH, POP, ATT, TTA,
- REC, SEC, RIE, SIE,
-
- AM0, AM1, // load timer reg
- ITA, // reads input port
- ATP, // akku send to data bus
- CDV, // clears internal divider
- OFF, // clears bf flip flop
- RDP, SDP,// reset display flip flop
- RPU, SPU,// flip flop pu off
- RPV, SPV // flip flop pv off
- };
-
- enum Adr
- {
- Imp,
- Reg,
- Vec, // imm byte (vector at 0xffxx)
- Vej,
- Imm,
- RegImm,
- Imm16,
- RegImm16,
- ME0,
- ME0Imm,
- Abs,
- AbsImm,
- ME1,
- ME1Imm,
- ME1Abs,
- ME1AbsImm,
- RelP,
- RelM
- };
-
- enum Regs
- {
- RegNone,
- A,
- XL, XH, X,
- YL, YH, Y,
- UL, UH, U,
- P, S
- };
- const char *ins_name() const { return ins_names[ins]; }
- const char *reg_name() const { return reg_names[reg]; }
-
- Ins ins;
- Adr adr;
- Regs reg;
-
- static const Entry table[0x100];
- static const Entry table_fd[0x100];
-
-protected:
- Entry(Ins i, Adr a = Imp, Regs r = RegNone) : ins(i), adr(a), reg(r) { }
-
- static const char *const ins_names[];
- static const char *const reg_names[];
-};
-
-const char *const Entry::ins_names[]={
+const char *const lh5801_disassembler::ins_names[]={
"ILL", "ILL", nullptr, "NOP",
"LDA", "STA", "LDI", "LDX", "STX",
"LDE", "SDE", "LIN", "SIN",
@@ -138,11 +48,11 @@ const char *const Entry::ins_names[]={
"RPV", "SPV",
};
-const char *const Entry::reg_names[]= {
+const char *const lh5801_disassembler::reg_names[]= {
nullptr, "A", "XL", "XH", "X", "YL", "YH", "Y", "UL", "UH", "U", "P", "S"
};
-const Entry Entry::table[0x100]={
+const lh5801_disassembler::Entry lh5801_disassembler::table[0x100]={
{ SBC, Reg, XL }, // 0
{ SBC, ME0, X },
{ ADC, Reg, XL },
@@ -401,7 +311,7 @@ const Entry Entry::table[0x100]={
{ ILL }
};
-const Entry Entry::table_fd[0x100]={
+const lh5801_disassembler::Entry lh5801_disassembler::table_fd[0x100]={
{ ILL2 }, // 0x00
{ SBC, ME1, X },
{ ILL2 },
@@ -660,90 +570,93 @@ const Entry Entry::table_fd[0x100]={
{ ILL2 }
};
-} // anonymous namespace
+u32 lh5801_disassembler::opcode_alignment() const
+{
+ return 1;
+}
-CPU_DISASSEMBLE(lh5801)
+offs_t lh5801_disassembler::disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer &params)
{
- int pos = 0;
+ offs_t pos = pc;
int oper;
uint16_t absolut;
const Entry *entry;
int temp;
- oper=oprom[pos++];
- entry=Entry::table+oper;
+ oper=opcodes.r8(pos++);
+ entry=table+oper;
- if (Entry::table[oper].ins==Entry::PREFD) {
- oper=oprom[pos++];
- entry=Entry::table_fd+oper;
+ if (table[oper].ins==PREFD) {
+ oper=opcodes.r8(pos++);
+ entry=table_fd+oper;
}
switch (entry->ins) {
- case Entry::ILL:
+ case ILL:
util::stream_format(stream, "%s %02x", entry->ins_name(), oper);break;
- case Entry::ILL2:
+ case ILL2:
util::stream_format(stream, "%s fd%02x", entry->ins_name(), oper);break;
default:
switch(entry->adr) {
- case Entry::Imp:
+ case Imp:
util::stream_format(stream, "%s", entry->ins_name());break;
- case Entry::Reg:
+ case Reg:
util::stream_format(stream, "%s %s", entry->ins_name(),entry->reg_name());break;
- case Entry::RegImm:
+ case RegImm:
util::stream_format(stream, "%s %s,%02x", entry->ins_name(),
- entry->reg_name(), oprom[pos++]);
+ entry->reg_name(), opcodes.r8(pos++));
break;
- case Entry::RegImm16:
- absolut=oprom[pos++]<<8;
- absolut|=oprom[pos++];
+ case RegImm16:
+ absolut=opcodes.r8(pos++)<<8;
+ absolut|=opcodes.r8(pos++);
util::stream_format(stream, "%s %s,%04x", entry->ins_name(),entry->reg_name(),absolut );
break;
- case Entry::Vec:
- util::stream_format(stream, "%s (ff%02x)", entry->ins_name(),oprom[pos++]);break;
- case Entry::Vej:
+ case Vec:
+ util::stream_format(stream, "%s (ff%02x)", entry->ins_name(),opcodes.r8(pos++));break;
+ case Vej:
util::stream_format(stream, "%s (ff%02x)", entry->ins_name(), oper);break;
- case Entry::Imm:
- util::stream_format(stream, "%s %02x", entry->ins_name(),oprom[pos++]);break;
- case Entry::Imm16:
- absolut=oprom[pos++]<<8;
- absolut|=oprom[pos++];
+ case Imm:
+ util::stream_format(stream, "%s %02x", entry->ins_name(),opcodes.r8(pos++));break;
+ case Imm16:
+ absolut=opcodes.r8(pos++)<<8;
+ absolut|=opcodes.r8(pos++);
util::stream_format(stream, "%s %04x", entry->ins_name(),absolut);break;
- case Entry::RelP:
- temp=oprom[pos++];
+ case RelP:
+ temp=opcodes.r8(pos++);
util::stream_format(stream, "%s %04x", entry->ins_name(),pc+pos+temp);break;
- case Entry::RelM:
- temp=oprom[pos++];
+ case RelM:
+ temp=opcodes.r8(pos++);
util::stream_format(stream, "%s %04x", entry->ins_name(),pc+pos-temp);break;
- case Entry::Abs:
- absolut=oprom[pos++]<<8;
- absolut|=oprom[pos++];
+ case Abs:
+ absolut=opcodes.r8(pos++)<<8;
+ absolut|=opcodes.r8(pos++);
util::stream_format(stream, "%s (%04x)", entry->ins_name(),absolut);break;
- case Entry::ME1Abs:
- absolut=oprom[pos++]<<8;
- absolut|=oprom[pos++];
+ case ME1Abs:
+ absolut=opcodes.r8(pos++)<<8;
+ absolut|=opcodes.r8(pos++);
util::stream_format(stream, "%s #(%04x)", entry->ins_name(),absolut);break;
- case Entry::AbsImm:
- absolut=oprom[pos++]<<8;
- absolut|=oprom[pos++];
+ case AbsImm:
+ absolut=opcodes.r8(pos++)<<8;
+ absolut|=opcodes.r8(pos++);
util::stream_format(stream, "%s (%04x),%02x", entry->ins_name(),absolut,
- oprom[pos++]);break;
- case Entry::ME1AbsImm:
- absolut=oprom[pos++]<<8;
- absolut|=oprom[pos++];
+ opcodes.r8(pos++));break;
+ case ME1AbsImm:
+ absolut=opcodes.r8(pos++)<<8;
+ absolut|=opcodes.r8(pos++);
util::stream_format(stream, "%s #(%04x),%02x", entry->ins_name(),absolut,
- oprom[pos++]);break;
- case Entry::ME0:
+ opcodes.r8(pos++));break;
+ case ME0:
util::stream_format(stream, "%s (%s)", entry->ins_name(),entry->reg_name());break;
- case Entry::ME0Imm:
- util::stream_format(stream, "%s (%s),%02x", entry->ins_name(),entry->reg_name(),oprom[pos++]);
+ case ME0Imm:
+ util::stream_format(stream, "%s (%s),%02x", entry->ins_name(),entry->reg_name(),opcodes.r8(pos++));
break;
- case Entry::ME1:
+ case ME1:
util::stream_format(stream, "%s #(%s)", entry->ins_name(),entry->reg_name());break;
- case Entry::ME1Imm:
- util::stream_format(stream, "%s #(%s),%02x", entry->ins_name(),entry->reg_name(),oprom[pos++]);
+ case ME1Imm:
+ util::stream_format(stream, "%s #(%s),%02x", entry->ins_name(),entry->reg_name(),opcodes.r8(pos++));
break;
}
}
- return pos;
+ return pos - pc;
}
diff --git a/src/devices/cpu/lh5801/5801dasm.h b/src/devices/cpu/lh5801/5801dasm.h
new file mode 100644
index 00000000000..9a6b66b0c5b
--- /dev/null
+++ b/src/devices/cpu/lh5801/5801dasm.h
@@ -0,0 +1,110 @@
+// license:BSD-3-Clause
+// copyright-holders:Peter Trauner
+/*****************************************************************************
+ *
+ * disasm.c
+ * portable lh5801 emulator interface
+ *
+ *
+ *****************************************************************************/
+
+#ifndef MAME_CPU_LH5801_5801DASM_H
+#define MAME_CPU_LH5801_5801DASM_H
+
+#pragma once
+
+class lh5801_disassembler : public util::disasm_interface
+{
+public:
+ lh5801_disassembler() = default;
+ virtual ~lh5801_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:
+ enum Ins
+ {
+ ILL, ILL2, PREFD, NOP,
+
+ LDA, STA, LDI, LDX, STX,
+ LDE, SDE, LIN, SIN,
+ TIN, // (x++)->(y++)
+ ADC, ADI, ADR, SBC, SBI,
+ DCA, DCS, // bcd add and sub
+ CPA, CPI, CIN, // A compared with (x++)
+ AND, ANI, ORA, ORI, EOR, EAI, BIT, BII,
+ INC, DEC,
+ DRL, DRR, // digit rotates
+ ROL, ROR,
+ SHL, SHR,
+ AEX, // A nibble swap
+
+ BCR, BCS, BHR, BHS, BZR, BZS, BVR, BVS,
+ BCH, LOP, // loop with ul
+ JMP, SJP, RTN, RTI, HLT,
+ VCR, VCS, VHR, VHS, VVS, VZR, VZS,
+ VMJ, VEJ,
+ PSH, POP, ATT, TTA,
+ REC, SEC, RIE, SIE,
+
+ AM0, AM1, // load timer reg
+ ITA, // reads input port
+ ATP, // akku send to data bus
+ CDV, // clears internal divider
+ OFF, // clears bf flip flop
+ RDP, SDP,// reset display flip flop
+ RPU, SPU,// flip flop pu off
+ RPV, SPV // flip flop pv off
+ };
+
+ enum Adr
+ {
+ Imp,
+ Reg,
+ Vec, // imm byte (vector at 0xffxx)
+ Vej,
+ Imm,
+ RegImm,
+ Imm16,
+ RegImm16,
+ ME0,
+ ME0Imm,
+ Abs,
+ AbsImm,
+ ME1,
+ ME1Imm,
+ ME1Abs,
+ ME1AbsImm,
+ RelP,
+ RelM
+ };
+
+ enum Regs
+ {
+ RegNone,
+ A,
+ XL, XH, X,
+ YL, YH, Y,
+ UL, UH, U,
+ P, S
+ };
+
+ struct Entry {
+ Ins ins;
+ Adr adr;
+ Regs reg;
+
+ const char *ins_name() const { return ins_names[ins]; }
+ const char *reg_name() const { return reg_names[reg]; }
+ Entry(Ins i, Adr a = Imp, Regs r = RegNone) : ins(i), adr(a), reg(r) { }
+ };
+
+ static const char *const ins_names[];
+ static const char *const reg_names[];
+
+ static const Entry table[0x100];
+ static const Entry table_fd[0x100];
+};
+
+#endif
diff --git a/src/devices/cpu/lh5801/lh5801.cpp b/src/devices/cpu/lh5801/lh5801.cpp
index 2b4a3708e44..1a28c90fc05 100644
--- a/src/devices/cpu/lh5801/lh5801.cpp
+++ b/src/devices/cpu/lh5801/lh5801.cpp
@@ -16,6 +16,7 @@
#include "emu.h"
#include "lh5801.h"
+#include "5801dasm.h"
#include "debugger.h"
@@ -256,8 +257,7 @@ void lh5801_cpu_device::execute_set_input(int irqline, int state)
}
}
-offs_t lh5801_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options)
+util::disasm_interface *lh5801_cpu_device::create_disassembler()
{
- extern CPU_DISASSEMBLE( lh5801 );
- return CPU_DISASSEMBLE_NAME(lh5801)(this, stream, pc, oprom, opram, options);
+ return new lh5801_disassembler;
}
diff --git a/src/devices/cpu/lh5801/lh5801.h b/src/devices/cpu/lh5801/lh5801.h
index bc9ce08cdd6..51ffa7c00cd 100644
--- a/src/devices/cpu/lh5801/lh5801.h
+++ b/src/devices/cpu/lh5801/lh5801.h
@@ -93,9 +93,7 @@ protected:
virtual void state_string_export(const device_state_entry &entry, std::string &str) 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 5; }
- 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:
address_space_config m_program_config;