summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/mc68hc11
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/cpu/mc68hc11')
-rw-r--r--src/devices/cpu/mc68hc11/hc11dasm.cpp133
-rw-r--r--src/devices/cpu/mc68hc11/hc11dasm.h55
-rw-r--r--src/devices/cpu/mc68hc11/mc68hc11.cpp8
-rw-r--r--src/devices/cpu/mc68hc11/mc68hc11.h6
4 files changed, 110 insertions, 92 deletions
diff --git a/src/devices/cpu/mc68hc11/hc11dasm.cpp b/src/devices/cpu/mc68hc11/hc11dasm.cpp
index 20ad20c4d0a..9fdc77409fe 100644
--- a/src/devices/cpu/mc68hc11/hc11dasm.cpp
+++ b/src/devices/cpu/mc68hc11/hc11dasm.cpp
@@ -7,33 +7,9 @@
*/
#include "emu.h"
+#include "hc11dasm.h"
-enum
-{
- EA_IMM8 = 1,
- EA_IMM16,
- EA_EXT,
- EA_REL,
- EA_DIRECT,
- EA_DIRECT_IMM8,
- EA_DIRECT_IMM8_REL,
- EA_IND_X,
- EA_IND_X_IMM8,
- EA_IND_X_IMM8_REL,
- EA_IND_Y,
- EA_IND_Y_IMM8,
- EA_IND_Y_IMM8_REL,
- PAGE2,
- PAGE3,
- PAGE4
-};
-
-struct M68HC11_OPCODE {
- char mnemonic[32];
- int address_mode;
-};
-
-static const M68HC11_OPCODE opcode_table[256] =
+const hc11_disassembler::M68HC11_OPCODE hc11_disassembler::opcode_table[256] =
{
/* 0x00 - 0x0f */
{ "test", 0, },
@@ -313,7 +289,7 @@ static const M68HC11_OPCODE opcode_table[256] =
/*****************************************************************************/
-static const M68HC11_OPCODE opcode_table_page2[256] =
+const hc11_disassembler::M68HC11_OPCODE hc11_disassembler::opcode_table_page2[256] =
{
/* 0x00 - 0x0f */
{ "?", 0, },
@@ -593,7 +569,7 @@ static const M68HC11_OPCODE opcode_table_page2[256] =
/*****************************************************************************/
-static const M68HC11_OPCODE opcode_table_page3[256] =
+const hc11_disassembler::M68HC11_OPCODE hc11_disassembler::opcode_table_page3[256] =
{
/* 0x00 - 0x0f */
{ "?", 0, },
@@ -873,7 +849,7 @@ static const M68HC11_OPCODE opcode_table_page3[256] =
/*****************************************************************************/
-static const M68HC11_OPCODE opcode_table_page4[256] =
+const hc11_disassembler::M68HC11_OPCODE hc11_disassembler::opcode_table_page4[256] =
{
/* 0x00 - 0x0f */
{ "?", 0, },
@@ -1152,137 +1128,126 @@ static const M68HC11_OPCODE opcode_table_page4[256] =
/*****************************************************************************/
-static const uint8_t *rombase;
-
-static uint8_t fetch(void)
+u32 hc11_disassembler::opcode_alignment() const
{
- return *rombase++;
+ return 1;
}
-static uint16_t fetch16(void)
+offs_t hc11_disassembler::disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer &params)
{
- uint16_t w;
- w = (rombase[0] << 8) | rombase[1];
- rombase+=2;
- return w;
-}
+ offs_t cpc = pc;
+
+ uint8_t opcode = opcodes.r8(cpc++);
+ const M68HC11_OPCODE *op_table = &opcode_table[opcode];
-static uint32_t decode_opcode(std::ostream &stream, uint32_t pc, const M68HC11_OPCODE *op_table)
-{
uint8_t imm8, mask;
int8_t rel8;
uint16_t imm16;
uint8_t op2;
uint32_t flags = 0;
+ loop:
if (!strcmp(op_table->mnemonic, "jsr") || !strcmp(op_table->mnemonic, "bsr"))
- flags = DASMFLAG_STEP_OVER;
+ flags = STEP_OVER;
else if (!strcmp(op_table->mnemonic, "rts") || !strcmp(op_table->mnemonic, "rti"))
- flags = DASMFLAG_STEP_OUT;
+ flags = STEP_OUT;
switch(op_table->address_mode)
{
case EA_IMM8:
- imm8 = fetch();
+ imm8 = opcodes.r8(cpc++);
util::stream_format(stream, "%s 0x%02X", op_table->mnemonic, imm8);
break;
case EA_IMM16:
- imm16 = fetch16();
+ imm16 = opcodes.r16(cpc++);
+ cpc += 2;
util::stream_format(stream, "%s 0x%04X", op_table->mnemonic, imm16);
break;
case EA_DIRECT:
- imm8 = fetch();
+ imm8 = opcodes.r8(cpc++);
util::stream_format(stream, "%s (0x%04X)", op_table->mnemonic, imm8);
break;
case EA_EXT:
- imm16 = fetch16();
+ imm16 = opcodes.r16(cpc++);
+ cpc += 2;
util::stream_format(stream, "%s (0x%04X)", op_table->mnemonic, imm16);
break;
case EA_IND_X:
- imm8 = fetch();
+ imm8 = opcodes.r8(cpc++);
util::stream_format(stream, "%s (X+0x%02X)", op_table->mnemonic, imm8);
break;
case EA_REL:
- rel8 = fetch();
+ rel8 = opcodes.r8(cpc++);
util::stream_format(stream, "%s [0x%04X]", op_table->mnemonic, pc+2+rel8);
break;
case EA_DIRECT_IMM8:
- imm8 = fetch();
- mask = fetch();
+ imm8 = opcodes.r8(cpc++);
+ mask = opcodes.r8(cpc++);
util::stream_format(stream, "%s (0x%04X), 0x%02X", op_table->mnemonic, imm8, mask);
break;
case EA_IND_X_IMM8:
- imm8 = fetch();
- mask = fetch();
+ imm8 = opcodes.r8(cpc++);
+ mask = opcodes.r8(cpc++);
util::stream_format(stream, "%s (X+0x%02X), 0x%02X", op_table->mnemonic, imm8, mask);
break;
case EA_DIRECT_IMM8_REL:
- imm8 = fetch();
- mask = fetch();
- rel8 = fetch();
+ imm8 = opcodes.r8(cpc++);
+ mask = opcodes.r8(cpc++);
+ rel8 = opcodes.r8(cpc++);
util::stream_format(stream, "%s (0x%04X), 0x%02X, [0x%04X]", op_table->mnemonic, imm8, mask, pc+4+rel8);
break;
case EA_IND_X_IMM8_REL:
- imm8 = fetch();
- mask = fetch();
- rel8 = fetch();
+ imm8 = opcodes.r8(cpc++);
+ mask = opcodes.r8(cpc++);
+ rel8 = opcodes.r8(cpc++);
util::stream_format(stream, "%s (X+0x%02X), 0x%02X, [0x%04X]", op_table->mnemonic, imm8, mask, pc+4+rel8);
break;
case EA_IND_Y:
- imm8 = fetch();
+ imm8 = opcodes.r8(cpc++);
util::stream_format(stream, "%s (Y+0x%02X)", op_table->mnemonic, imm8);
break;
case EA_IND_Y_IMM8:
- imm8 = fetch();
- mask = fetch();
+ imm8 = opcodes.r8(cpc++);
+ mask = opcodes.r8(cpc++);
util::stream_format(stream, "%s (Y+0x%02X), 0x%02X", op_table->mnemonic, imm8, mask);
break;
case EA_IND_Y_IMM8_REL:
- imm8 = fetch();
- mask = fetch();
- rel8 = fetch();
+ imm8 = opcodes.r8(cpc++);
+ mask = opcodes.r8(cpc++);
+ rel8 = opcodes.r8(cpc++);
util::stream_format(stream, "%s (Y+0x%02X), 0x%02X, [0x%04X]", op_table->mnemonic, imm8, mask, pc+2+rel8);
break;
case PAGE2:
- op2 = fetch();
- return decode_opcode(stream, pc, &opcode_table_page2[op2]);
+ op2 = opcodes.r8(cpc++);
+ op_table = &opcode_table_page2[op2];
+ goto loop;
case PAGE3:
- op2 = fetch();
- return decode_opcode(stream, pc, &opcode_table_page3[op2]);
+ op2 = opcodes.r8(cpc++);
+ op_table = &opcode_table_page3[op2];
+ goto loop;
case PAGE4:
- op2 = fetch();
- return decode_opcode(stream, pc, &opcode_table_page4[op2]);
+ op2 = opcodes.r8(cpc++);
+ op_table = &opcode_table_page4[op2];
+ goto loop;
default:
util::stream_format(stream, "%s", op_table->mnemonic);
}
- return flags;
-}
-
-CPU_DISASSEMBLE(hc11)
-{
- uint32_t flags;
- uint8_t opcode;
-
- rombase = oprom;
-
- opcode = fetch();
- flags = decode_opcode(stream, pc, &opcode_table[opcode]);
- return (rombase-oprom) | flags | DASMFLAG_SUPPORTED;
+ return (cpc - pc) | flags | SUPPORTED;
}
diff --git a/src/devices/cpu/mc68hc11/hc11dasm.h b/src/devices/cpu/mc68hc11/hc11dasm.h
new file mode 100644
index 00000000000..d1c606a964d
--- /dev/null
+++ b/src/devices/cpu/mc68hc11/hc11dasm.h
@@ -0,0 +1,55 @@
+// license:BSD-3-Clause
+// copyright-holders:Ville Linde
+/*
+ Motorola M68HC11 disassembler
+
+ Written by Ville Linde
+*/
+
+#ifndef MAME_CPU_MC68HC11_HC11DASM_H
+#define MAME_CPU_MC68HC11_HC11DASM_H
+
+#pragma once
+
+class hc11_disassembler : public util::disasm_interface
+{
+public:
+ hc11_disassembler() = default;
+ virtual ~hc11_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
+ {
+ EA_IMM8 = 1,
+ EA_IMM16,
+ EA_EXT,
+ EA_REL,
+ EA_DIRECT,
+ EA_DIRECT_IMM8,
+ EA_DIRECT_IMM8_REL,
+ EA_IND_X,
+ EA_IND_X_IMM8,
+ EA_IND_X_IMM8_REL,
+ EA_IND_Y,
+ EA_IND_Y_IMM8,
+ EA_IND_Y_IMM8_REL,
+ PAGE2,
+ PAGE3,
+ PAGE4
+ };
+
+ struct M68HC11_OPCODE {
+ char mnemonic[32];
+ int address_mode;
+ };
+
+ static const M68HC11_OPCODE opcode_table[256];
+ static const M68HC11_OPCODE opcode_table_page2[256];
+ static const M68HC11_OPCODE opcode_table_page3[256];
+ static const M68HC11_OPCODE opcode_table_page4[256];
+};
+
+#endif
diff --git a/src/devices/cpu/mc68hc11/mc68hc11.cpp b/src/devices/cpu/mc68hc11/mc68hc11.cpp
index 1ecd2793529..76d4ef56c56 100644
--- a/src/devices/cpu/mc68hc11/mc68hc11.cpp
+++ b/src/devices/cpu/mc68hc11/mc68hc11.cpp
@@ -16,6 +16,7 @@ TODO:
#include "emu.h"
#include "debugger.h"
#include "mc68hc11.h"
+#include "hc11dasm.h"
enum
{
@@ -61,10 +62,9 @@ device_memory_interface::space_config_vector mc68hc11_cpu_device::memory_space_c
};
}
-offs_t mc68hc11_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options)
+util::disasm_interface *mc68hc11_cpu_device::create_disassembler()
{
- extern CPU_DISASSEMBLE( hc11 );
- return CPU_DISASSEMBLE_NAME(hc11)(this, stream, pc, oprom, opram, options);
+ return new hc11_disassembler;
}
@@ -397,7 +397,7 @@ void mc68hc11_cpu_device::device_start()
m_internal_ram.resize(m_internal_ram_size);
m_program = &space(AS_PROGRAM);
- m_direct = &m_program->direct();
+ m_direct = m_program->direct<0>();
m_io = &space(AS_IO);
save_item(NAME(m_pc));
diff --git a/src/devices/cpu/mc68hc11/mc68hc11.h b/src/devices/cpu/mc68hc11/mc68hc11.h
index e2a1f52f3d7..35b0cb98170 100644
--- a/src/devices/cpu/mc68hc11/mc68hc11.h
+++ b/src/devices/cpu/mc68hc11/mc68hc11.h
@@ -70,9 +70,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;
@@ -102,7 +100,7 @@ private:
int m_ad_channel;
uint8_t m_irq_state[2];
- direct_read_data *m_direct;
+ direct_read_data<0> *m_direct;
address_space *m_program;
address_space *m_io;
int m_icount;