summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/h8
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/cpu/h8')
-rw-r--r--src/devices/cpu/h8/h8.cpp258
-rw-r--r--src/devices/cpu/h8/h8.h78
-rw-r--r--src/devices/cpu/h8/h8_adc.cpp2
-rw-r--r--src/devices/cpu/h8/h8_port.cpp2
-rw-r--r--src/devices/cpu/h8/h8d.cpp262
-rw-r--r--src/devices/cpu/h8/h8d.h101
-rw-r--r--src/devices/cpu/h8/h8h.cpp5
-rw-r--r--src/devices/cpu/h8/h8h.h4
-rw-r--r--src/devices/cpu/h8/h8hd.cpp17
-rw-r--r--src/devices/cpu/h8/h8hd.h28
-rw-r--r--src/devices/cpu/h8/h8make.py58
-rw-r--r--src/devices/cpu/h8/h8s2000.cpp5
-rw-r--r--src/devices/cpu/h8/h8s2000.h4
-rw-r--r--src/devices/cpu/h8/h8s2000d.cpp17
-rw-r--r--src/devices/cpu/h8/h8s2000d.h28
-rw-r--r--src/devices/cpu/h8/h8s2600.cpp5
-rw-r--r--src/devices/cpu/h8/h8s2600.h4
-rw-r--r--src/devices/cpu/h8/h8s2600d.cpp17
-rw-r--r--src/devices/cpu/h8/h8s2600d.h28
19 files changed, 556 insertions, 367 deletions
diff --git a/src/devices/cpu/h8/h8.cpp b/src/devices/cpu/h8/h8.cpp
index 516c2253496..e54155b120d 100644
--- a/src/devices/cpu/h8/h8.cpp
+++ b/src/devices/cpu/h8/h8.cpp
@@ -14,6 +14,7 @@
#include "h8.h"
#include "h8_dma.h"
#include "h8_dtc.h"
+#include "h8d.h"
h8_device::h8_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, bool mode_a16, address_map_delegate map_delegate) :
cpu_device(mconfig, type, tag, owner, clock),
@@ -31,7 +32,7 @@ h8_device::h8_device(const machine_config &mconfig, device_type type, const char
void h8_device::device_start()
{
program = &space(AS_PROGRAM);
- direct = &program->direct();
+ direct = program->direct<0>();
io = &space(AS_IO);
state_add(STATE_GENPC, "GENPC", NPC).noshow();
@@ -324,256 +325,6 @@ void h8_device::state_string_export(const device_state_entry &entry, std::string
}
}
-
-uint32_t h8_device::disasm_min_opcode_bytes() const
-{
- return 2;
-}
-
-uint32_t h8_device::disasm_max_opcode_bytes() const
-{
- return 10;
-}
-
-void h8_device::disassemble_am(std::ostream &stream, int am, offs_t pc, const uint8_t *oprom, uint32_t opcode, int slot, int offset)
-{
- static const char *const r8_names[16] = {
- "r0h", "r1h", "r2h", "r3h", "r4h", "r5h", "r6h", "r7h",
- "r0l", "r1l", "r2l", "r3l", "r4l", "r5l", "r6l", "r7l"
- };
-
- static const char *const r16_names[16] = {
- "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
- "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7",
- };
-
- static const char *const r32_names[8] = {
- "er0", "er1", "er2", "er3", "er4", "er5", "er6", "sp",
- };
-
- switch(am) {
- case DASM_r8l:
- util::stream_format(stream, "%s", r8_names[opcode & 15]);
- break;
-
- case DASM_r8h:
- util::stream_format(stream, "%s", r8_names[(opcode >> 4) & 15]);
- break;
-
- case DASM_r8u:
- util::stream_format(stream, "%s", r8_names[(opcode >> 8) & 15]);
- break;
-
- case DASM_r16l:
- util::stream_format(stream, "%s", r16_names[opcode & 15]);
- break;
-
- case DASM_r16h:
- util::stream_format(stream, "%s", r16_names[(opcode >> 4) & 15]);
- break;
-
- case DASM_r32l:
- util::stream_format(stream, "%s", r32_names[opcode & 7]);
- break;
-
- case DASM_r32h:
- util::stream_format(stream, "%s", r32_names[(opcode >> 4) & 7]);
- break;
-
- case DASM_r16ih:
- util::stream_format(stream, "@%s", r16_names[(opcode >> 4) & 7]);
- break;
-
- case DASM_r16ihh:
- util::stream_format(stream, "@%s", r16_names[(opcode >> 20) & 7]);
- break;
-
- case DASM_pr16h:
- util::stream_format(stream, "@-%s", r16_names[(opcode >> 4) & 7]);
- break;
-
- case DASM_r16ph:
- util::stream_format(stream, "@%s+", r16_names[(opcode >> 4) & 7]);
- break;
-
- case DASM_r16d16h:
- util::stream_format(stream, "@(%x, %s)", (oprom[offset-2] << 8) | oprom[offset-1], r16_names[(opcode >> 4) & 7]);
- break;
-
- case DASM_r32ih:
- util::stream_format(stream, "@%s", r32_names[(opcode >> 4) & 7]);
- break;
-
- case DASM_r32ihh:
- util::stream_format(stream, "@%s", r32_names[(opcode >> 20) & 7]);
- break;
-
- case DASM_pr32h:
- util::stream_format(stream, "@-%s", r32_names[(opcode >> 4) & 7]);
- break;
-
- case DASM_r32pl:
- util::stream_format(stream, "@%s+", r32_names[opcode & 7]);
- break;
-
- case DASM_r32ph:
- util::stream_format(stream, "@%s+", r32_names[(opcode >> 4) & 7]);
- break;
-
- case DASM_r32d16h:
- util::stream_format(stream, "@(%x, %s)", (oprom[offset-2] << 8) | oprom[offset-1], r32_names[(opcode >> 4) & 7]);
- break;
-
- case DASM_r32d32hh:
- util::stream_format(stream, "@(%x, %s)", (oprom[offset-4] << 24) | (oprom[offset-3] << 16) | (oprom[offset-2] << 8) | oprom[offset-1], r32_names[(opcode >> 20) & 7]);
- break;
-
- case DASM_psp:
- util::stream_format(stream, "@-sp");
- break;
-
- case DASM_spp:
- util::stream_format(stream, "@sp+");
- break;
-
- case DASM_r32n2l:
- util::stream_format(stream, "%s-%s", r32_names[opcode & 6], r32_names[(opcode & 6) + 1]);
- break;
-
- case DASM_r32n3l:
- util::stream_format(stream, "%s-%s", r32_names[opcode & 4], r32_names[(opcode & 4) + 2]);
- break;
-
- case DASM_r32n4l:
- util::stream_format(stream, "%s-%s", r32_names[opcode & 4], r32_names[(opcode & 4) + 3]);
- break;
-
- case DASM_abs8:
- util::stream_format(stream, "@%08x", 0xffffff00 | oprom[1]);
- break;
-
- case DASM_abs16:
- if(offset >= 6)
- util::stream_format(stream, "@%08x", int16_t((oprom[offset-4] << 8) | oprom[offset-3]));
- else
- util::stream_format(stream, "@%08x", int16_t((oprom[offset-2] << 8) | oprom[offset-1]));
- break;
-
- case DASM_abs32:
- if(slot == 3)
- util::stream_format(stream, "@%08x", (oprom[offset-6] << 24) | (oprom[offset-5] << 16) | (oprom[offset-4] << 8) | oprom[offset-3]);
- else
- util::stream_format(stream, "@%08x", (oprom[offset-4] << 24) | (oprom[offset-3] << 16) | (oprom[offset-2] << 8) | oprom[offset-1]);
- break;
-
- case DASM_abs8i:
- util::stream_format(stream, "@%02x", oprom[1]);
- break;
-
- case DASM_abs16e:
- util::stream_format(stream, "%04x", (oprom[2] << 8) | oprom[3]);
- break;
-
- case DASM_abs24e:
- util::stream_format(stream, "%08x", (oprom[1] << 16) | (oprom[2] << 8) | oprom[3]);
- break;
-
- case DASM_rel8:
- util::stream_format(stream, "%08x", pc + 2 + int8_t(oprom[1]));
- break;
-
- case DASM_rel16:
- util::stream_format(stream, "%08x", pc + 4 + int16_t((oprom[2] << 8) | oprom[3]));
- break;
-
- case DASM_one:
- util::stream_format(stream, "#1");
- break;
-
- case DASM_two:
- util::stream_format(stream, "#2");
- break;
-
- case DASM_four:
- util::stream_format(stream, "#4");
- break;
-
- case DASM_imm2:
- util::stream_format(stream, "#%x", (opcode >> 4) & 3);
- break;
-
- case DASM_imm3:
- util::stream_format(stream, "#%x", (opcode >> 4) & 7);
- break;
-
- case DASM_imm8:
- util::stream_format(stream, "#%02x", oprom[1]);
- break;
-
- case DASM_imm16:
- util::stream_format(stream, "#%04x", (oprom[2] << 8) | oprom[3]);
- break;
-
- case DASM_imm32:
- util::stream_format(stream, "#%08x", (oprom[2] << 16) | (oprom[3] << 16) | (oprom[4] << 8) | oprom[5]);
- break;
-
- case DASM_ccr:
- util::stream_format(stream, "ccr");
- break;
-
- case DASM_exr:
- util::stream_format(stream, "exr");
- break;
-
- case DASM_macl:
- util::stream_format(stream, "macl");
- break;
-
- case DASM_mach:
- util::stream_format(stream, "mach");
- break;
-
- default:
- util::stream_format(stream, "<%d>", am);
- break;
- }
-}
-
-offs_t h8_device::disassemble_generic(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options, const disasm_entry *table)
-{
- uint32_t slot[5];
- slot[0] = (oprom[0] << 8) | oprom[1];
- slot[1] = (oprom[0] << 24) | (oprom[1] << 16) | (oprom[2] << 8) | oprom[3];
- slot[2] = (oprom[0] << 24) | (oprom[1] << 16) | (oprom[4] << 8) | oprom[5];
- slot[3] = (oprom[0] << 24) | (oprom[1] << 16) | (oprom[6] << 8) | oprom[7];
- slot[4] = (oprom[2] << 24) | (oprom[3] << 16) | (oprom[4] << 8) | oprom[5];
-
- int inst;
- for(inst=0;; inst++) {
- const disasm_entry &e = table[inst];
- if((slot[e.slot] & e.mask) == e.val && (slot[0] & e.mask0) == e.val0)
- break;
- }
- const disasm_entry &e = table[inst];
- stream << e.opcode;
-
- if(e.am1 != DASM_none) {
- stream << ' ';
- disassemble_am(stream, e.am1, pc, oprom, slot[e.slot], e.slot, e.flags & DASMFLAG_LENGTHMASK);
- }
- if(e.am2 != DASM_none) {
- stream << ", ";
- disassemble_am(stream, e.am2, pc, oprom, slot[e.slot], e.slot, e.flags & DASMFLAG_LENGTHMASK);
- }
- return e.flags | DASMFLAG_SUPPORTED;
-}
-
-offs_t h8_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options)
-{
- return disassemble_generic(stream, pc, oprom, opram, options, disasm_entries);
-}
-
uint16_t h8_device::read16i(uint32_t adr)
{
icount--;
@@ -1592,4 +1343,9 @@ void h8_device::set_nz32(uint32_t v)
CCR |= F_N;
}
+util::disasm_interface *h8_device::create_disassembler()
+{
+ return new h8_disassembler;
+}
+
#include "cpu/h8/h8.hxx"
diff --git a/src/devices/cpu/h8/h8.h b/src/devices/cpu/h8/h8.h
index 3df33f8de1b..78ce598bb84 100644
--- a/src/devices/cpu/h8/h8.h
+++ b/src/devices/cpu/h8/h8.h
@@ -72,15 +72,6 @@ public:
bool access_is_dma() const { return inst_state == STATE_DMA || inst_state == STATE_DTC; }
protected:
- struct disasm_entry {
- int slot;
- uint32_t val, mask;
- uint16_t val0, mask0;
- const char *opcode;
- int am1, am2;
- offs_t flags;
- };
-
enum {
F_I = 0x80,
F_UI = 0x40,
@@ -96,64 +87,6 @@ protected:
EXR_I = 0x07
};
- enum {
- DASM_none, /* no additional arguments */
-
- DASM_r8l, /* 8-bits register in bits 0-3 */
- DASM_r8h, /* 8-bits register in bits 4-7 */
- DASM_r8u, /* 8-bits register in bits 8-15 */
- DASM_r16l, /* 16-bits register in bits 0-3 */
- DASM_r16h, /* 16-bits register in bits 4-7 */
- DASM_r32l, /* 32-bits register in bits 0-3 */
- DASM_r32h, /* 32-bits register in bits 4-7 */
-
- DASM_r16ih, /* indexed through 16-bits register in bits 4-6 */
- DASM_r16ihh, /* indexed through 16-bits register in bits 4-6 in 4-bytes instruction */
- DASM_pr16h, /* indexed through predecremented 16-bits register in bits 4-6 */
- DASM_r16ph, /* indexed through postincremented 16-bits register in bits 4-6 */
- DASM_r16d16h, /* indexed through 16-bits register in bits 4-6 with 16-bits displacement at end of instruction */
-
- DASM_r32ih, /* indexed through 32-bits register in bits 4-6 */
- DASM_r32ihh, /* indexed through 32-bits register in bits 4-6 in 4-bytes instruction */
- DASM_pr32h, /* indexed through predecremented 32-bits register in bits 4-6 */
- DASM_r32pl, /* indexed through postincremented 32-bits register in bits 0-2 */
- DASM_r32ph, /* indexed through postincremented 32-bits register in bits 4-6 */
- DASM_r32d16h, /* indexed through 32-bits register in bits 4-6 with 16-bits displacement at end of instruction */
- DASM_r32d32hh, /* indexed through 32-bits register in bits 20-22 with 32-bits displacement at end of instruction */
-
- DASM_psp, /* indexed through predecremented stack pointer */
- DASM_spp, /* indexed through postincremented stack pointer */
-
- DASM_r32n2l, /* Block of 2 registers */
- DASM_r32n3l, /* Block of 3 registers */
- DASM_r32n4l, /* Block of 4 registers */
-
- DASM_abs8, /* 8-bit address present at +1 */
- DASM_abs16, /* 16-bit address present at end of instruction */
- DASM_abs32, /* 32-bit address present at end of instruction */
- DASM_abs8i, /* 8-bit indirect jump address present at +1 */
- DASM_abs16e, /* 16-bit jump address present at +2 */
- DASM_abs24e, /* 24-bit jump address present at +1 */
-
- DASM_rel8, /* 8-bit pc-relative jump address at +1, offset=2 */
- DASM_rel16, /* 16-bit pc-relative jump address at +2, offset=4 */
-
- DASM_one, /* immediate value 1 */
- DASM_two, /* immediate value 2 */
- DASM_four, /* immediate value 4 */
-
- DASM_imm2, /* 2-bit immediate in bits 4-5 (trapa) */
- DASM_imm3, /* 3-bit immediate in bits 4-6 (bit selection */
- DASM_imm8, /* 8-bit immediate at +1 */
- DASM_imm16, /* 16-bit immediate at +2 */
- DASM_imm32, /* 32-bit immediate at +2 */
-
- DASM_ccr, /* internal register ccr */
- DASM_exr, /* internal register exr */
- DASM_macl, /* internal register macl */
- DASM_mach /* internal register mach */
- };
-
h8_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, bool mode_a16, address_map_delegate map_delegate);
// device-level overrides
@@ -175,13 +108,11 @@ 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;
- virtual uint32_t disasm_max_opcode_bytes() const override;
- 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;
address_space_config program_config, io_config;
address_space *program, *io;
- direct_read_data *direct;
+ direct_read_data<0> *direct;
h8_dma_device *dma_device;
h8_dtc_device *dtc_device;
h8_dma_state *current_dma;
@@ -208,11 +139,6 @@ protected:
int irq_level, taken_irq_level;
bool irq_required, irq_nmi;
- static const disasm_entry disasm_entries[];
-
- offs_t disassemble_generic(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options, const disasm_entry *table);
- void disassemble_am(std::ostream &stream, int am, offs_t pc, const uint8_t *oprom, uint32_t opcode, int slot, int offset);
-
virtual void do_exec_full();
virtual void do_exec_partial();
static void add_event(uint64_t &event_time, uint64_t new_event);
diff --git a/src/devices/cpu/h8/h8_adc.cpp b/src/devices/cpu/h8/h8_adc.cpp
index 979b13fe631..76b03584e6d 100644
--- a/src/devices/cpu/h8/h8_adc.cpp
+++ b/src/devices/cpu/h8/h8_adc.cpp
@@ -168,7 +168,7 @@ void h8_adc_device::conversion_wait(bool first, bool poweron, uint64_t current_t
void h8_adc_device::buffer_value(int port, int buffer)
{
- buf[buffer] = io->read_word(2*(h8_device::ADC_0 + port));
+ buf[buffer] = io->read_word(h8_device::ADC_0 + port);
if(V>=1) logerror("adc buffer %d -> %d:%03x\n", port, buffer, buf[buffer]);
}
diff --git a/src/devices/cpu/h8/h8_port.cpp b/src/devices/cpu/h8/h8_port.cpp
index ae63eedad51..bc21c99d6df 100644
--- a/src/devices/cpu/h8/h8_port.cpp
+++ b/src/devices/cpu/h8/h8_port.cpp
@@ -13,7 +13,7 @@ h8_port_device::h8_port_device(const machine_config &mconfig, const char *tag, d
void h8_port_device::set_info(int _address, uint8_t _default_ddr, uint8_t _mask)
{
- address = 2*_address;
+ address = _address;
default_ddr = _default_ddr;
mask = _mask;
}
diff --git a/src/devices/cpu/h8/h8d.cpp b/src/devices/cpu/h8/h8d.cpp
new file mode 100644
index 00000000000..b157aedd3c7
--- /dev/null
+++ b/src/devices/cpu/h8/h8d.cpp
@@ -0,0 +1,262 @@
+// license:BSD-3-Clause
+// copyright-holders:Olivier Galibert
+/***************************************************************************
+
+ h8d.h
+
+ H8-300 base cpu emulation, disassembler
+
+***************************************************************************/
+
+#include "emu.h"
+#include "h8d.h"
+#include "cpu/h8/h8d.hxx"
+
+h8_disassembler::h8_disassembler(const disasm_entry *_table) : table(_table)
+{
+}
+
+h8_disassembler::h8_disassembler() : h8_disassembler(disasm_entries)
+{
+}
+
+u32 h8_disassembler::opcode_alignment() const
+{
+ return 2;
+}
+
+void h8_disassembler::disassemble_am(std::ostream &stream, int am, offs_t pc, const data_buffer &opcodes, u32 opcode, int slot, int offset)
+{
+ static const char *const r8_names[16] = {
+ "r0h", "r1h", "r2h", "r3h", "r4h", "r5h", "r6h", "r7h",
+ "r0l", "r1l", "r2l", "r3l", "r4l", "r5l", "r6l", "r7l"
+ };
+
+ static const char *const r16_names[16] = {
+ "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
+ "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7",
+ };
+
+ static const char *const r32_names[8] = {
+ "er0", "er1", "er2", "er3", "er4", "er5", "er6", "sp",
+ };
+
+ offs_t epc = pc + offset;
+
+ switch(am) {
+ case DASM_r8l:
+ util::stream_format(stream, "%s", r8_names[opcode & 15]);
+ break;
+
+ case DASM_r8h:
+ util::stream_format(stream, "%s", r8_names[(opcode >> 4) & 15]);
+ break;
+
+ case DASM_r8u:
+ util::stream_format(stream, "%s", r8_names[(opcode >> 8) & 15]);
+ break;
+
+ case DASM_r16l:
+ util::stream_format(stream, "%s", r16_names[opcode & 15]);
+ break;
+
+ case DASM_r16h:
+ util::stream_format(stream, "%s", r16_names[(opcode >> 4) & 15]);
+ break;
+
+ case DASM_r32l:
+ util::stream_format(stream, "%s", r32_names[opcode & 7]);
+ break;
+
+ case DASM_r32h:
+ util::stream_format(stream, "%s", r32_names[(opcode >> 4) & 7]);
+ break;
+
+ case DASM_r16ih:
+ util::stream_format(stream, "@%s", r16_names[(opcode >> 4) & 7]);
+ break;
+
+ case DASM_r16ihh:
+ util::stream_format(stream, "@%s", r16_names[(opcode >> 20) & 7]);
+ break;
+
+ case DASM_pr16h:
+ util::stream_format(stream, "@-%s", r16_names[(opcode >> 4) & 7]);
+ break;
+
+ case DASM_r16ph:
+ util::stream_format(stream, "@%s+", r16_names[(opcode >> 4) & 7]);
+ break;
+
+ case DASM_r16d16h:
+ util::stream_format(stream, "@(%x, %s)", opcodes.r16(epc-2), r16_names[(opcode >> 4) & 7]);
+ break;
+
+ case DASM_r32ih:
+ util::stream_format(stream, "@%s", r32_names[(opcode >> 4) & 7]);
+ break;
+
+ case DASM_r32ihh:
+ util::stream_format(stream, "@%s", r32_names[(opcode >> 20) & 7]);
+ break;
+
+ case DASM_pr32h:
+ util::stream_format(stream, "@-%s", r32_names[(opcode >> 4) & 7]);
+ break;
+
+ case DASM_r32pl:
+ util::stream_format(stream, "@%s+", r32_names[opcode & 7]);
+ break;
+
+ case DASM_r32ph:
+ util::stream_format(stream, "@%s+", r32_names[(opcode >> 4) & 7]);
+ break;
+
+ case DASM_r32d16h:
+ util::stream_format(stream, "@(%x, %s)", opcodes.r16(epc-2), r32_names[(opcode >> 4) & 7]);
+ break;
+
+ case DASM_r32d32hh:
+ util::stream_format(stream, "@(%x, %s)", opcodes.r32(epc-4), r32_names[(opcode >> 20) & 7]);
+ break;
+
+ case DASM_psp:
+ util::stream_format(stream, "@-sp");
+ break;
+
+ case DASM_spp:
+ util::stream_format(stream, "@sp+");
+ break;
+
+ case DASM_r32n2l:
+ util::stream_format(stream, "%s-%s", r32_names[opcode & 6], r32_names[(opcode & 6) + 1]);
+ break;
+
+ case DASM_r32n3l:
+ util::stream_format(stream, "%s-%s", r32_names[opcode & 4], r32_names[(opcode & 4) + 2]);
+ break;
+
+ case DASM_r32n4l:
+ util::stream_format(stream, "%s-%s", r32_names[opcode & 4], r32_names[(opcode & 4) + 3]);
+ break;
+
+ case DASM_abs8:
+ util::stream_format(stream, "@%08x", 0xffffff00 | opcodes.r8(pc+1));
+ break;
+
+ case DASM_abs16:
+ if(offset >= 6)
+ util::stream_format(stream, "@%08x", s16(opcodes.r16(epc-4)));
+ else
+ util::stream_format(stream, "@%08x", s16(opcodes.r16(epc-2)));
+ break;
+
+ case DASM_abs32:
+ if(slot == 3)
+ util::stream_format(stream, "@%08x", opcodes.r32(epc-6));
+ else
+ util::stream_format(stream, "@%08x", opcodes.r32(epc-4));
+ break;
+
+ case DASM_abs8i:
+ util::stream_format(stream, "@%02x", opcodes.r8(pc+1));
+ break;
+
+ case DASM_abs16e:
+ util::stream_format(stream, "%04x", opcodes.r16(pc+2));
+ break;
+
+ case DASM_abs24e:
+ util::stream_format(stream, "%08x", opcodes.r32(pc) & 0xffffff);
+ break;
+
+ case DASM_rel8:
+ util::stream_format(stream, "%08x", pc + 2 + s8(opcodes.r8(pc+1)));
+ break;
+
+ case DASM_rel16:
+ util::stream_format(stream, "%08x", pc + 4 + s16(opcodes.r16(pc+2)));
+ break;
+
+ case DASM_one:
+ util::stream_format(stream, "#1");
+ break;
+
+ case DASM_two:
+ util::stream_format(stream, "#2");
+ break;
+
+ case DASM_four:
+ util::stream_format(stream, "#4");
+ break;
+
+ case DASM_imm2:
+ util::stream_format(stream, "#%x", (opcode >> 4) & 3);
+ break;
+
+ case DASM_imm3:
+ util::stream_format(stream, "#%x", (opcode >> 4) & 7);
+ break;
+
+ case DASM_imm8:
+ util::stream_format(stream, "#%02x", opcodes.r8(pc+1));
+ break;
+
+ case DASM_imm16:
+ util::stream_format(stream, "#%04x", opcodes.r16(pc+2));
+ break;
+
+ case DASM_imm32:
+ util::stream_format(stream, "#%08x", opcodes.r32(pc+2));
+ break;
+
+ case DASM_ccr:
+ util::stream_format(stream, "ccr");
+ break;
+
+ case DASM_exr:
+ util::stream_format(stream, "exr");
+ break;
+
+ case DASM_macl:
+ util::stream_format(stream, "macl");
+ break;
+
+ case DASM_mach:
+ util::stream_format(stream, "mach");
+ break;
+
+ default:
+ util::stream_format(stream, "<%d>", am);
+ break;
+ }
+}
+
+offs_t h8_disassembler::disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer &params)
+{
+ u32 slot[5];
+ slot[0] = opcodes.r16(pc);
+ slot[1] = opcodes.r32(pc);
+ slot[2] = (opcodes.r16(pc) << 16) | opcodes.r16(pc+4);
+ slot[3] = (opcodes.r16(pc) << 16) | opcodes.r16(pc+6);
+ slot[4] = opcodes.r32(pc+2);
+
+ int inst;
+ for(inst=0;; inst++) {
+ const disasm_entry &e = table[inst];
+ if((slot[e.slot] & e.mask) == e.val && (slot[0] & e.mask0) == e.val0)
+ break;
+ }
+ const disasm_entry &e = table[inst];
+ stream << e.opcode;
+
+ if(e.am1 != DASM_none) {
+ stream << ' ';
+ disassemble_am(stream, e.am1, pc, opcodes, slot[e.slot], e.slot, e.flags & LENGTHMASK);
+ }
+ if(e.am2 != DASM_none) {
+ stream << ", ";
+ disassemble_am(stream, e.am2, pc, opcodes, slot[e.slot], e.slot, e.flags & LENGTHMASK);
+ }
+ return e.flags | SUPPORTED;
+}
diff --git a/src/devices/cpu/h8/h8d.h b/src/devices/cpu/h8/h8d.h
new file mode 100644
index 00000000000..65ba1d7fd97
--- /dev/null
+++ b/src/devices/cpu/h8/h8d.h
@@ -0,0 +1,101 @@
+// license:BSD-3-Clause
+// copyright-holders:Olivier Galibert
+/***************************************************************************
+
+ h8d.h
+
+ H8-300 base cpu emulation, disassembler
+
+***************************************************************************/
+
+#ifndef MAME_CPU_H8_H8D_H
+#define MAME_CPU_H8_H8D_H
+
+#pragma once
+
+class h8_disassembler : public util::disasm_interface
+{
+protected:
+ struct disasm_entry {
+ int slot;
+ u32 val, mask;
+ u16 val0, mask0;
+ const char *opcode;
+ int am1, am2;
+ offs_t flags;
+ };
+
+public:
+ h8_disassembler(const disasm_entry *_table);
+ h8_disassembler();
+
+ 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;
+
+protected:
+ enum {
+ DASM_none, /* no additional arguments */
+
+ DASM_r8l, /* 8-bits register in bits 0-3 */
+ DASM_r8h, /* 8-bits register in bits 4-7 */
+ DASM_r8u, /* 8-bits register in bits 8-15 */
+ DASM_r16l, /* 16-bits register in bits 0-3 */
+ DASM_r16h, /* 16-bits register in bits 4-7 */
+ DASM_r32l, /* 32-bits register in bits 0-3 */
+ DASM_r32h, /* 32-bits register in bits 4-7 */
+
+ DASM_r16ih, /* indexed through 16-bits register in bits 4-6 */
+ DASM_r16ihh, /* indexed through 16-bits register in bits 4-6 in 4-bytes instruction */
+ DASM_pr16h, /* indexed through predecremented 16-bits register in bits 4-6 */
+ DASM_r16ph, /* indexed through postincremented 16-bits register in bits 4-6 */
+ DASM_r16d16h, /* indexed through 16-bits register in bits 4-6 with 16-bits displacement at end of instruction */
+
+ DASM_r32ih, /* indexed through 32-bits register in bits 4-6 */
+ DASM_r32ihh, /* indexed through 32-bits register in bits 4-6 in 4-bytes instruction */
+ DASM_pr32h, /* indexed through predecremented 32-bits register in bits 4-6 */
+ DASM_r32pl, /* indexed through postincremented 32-bits register in bits 0-2 */
+ DASM_r32ph, /* indexed through postincremented 32-bits register in bits 4-6 */
+ DASM_r32d16h, /* indexed through 32-bits register in bits 4-6 with 16-bits displacement at end of instruction */
+ DASM_r32d32hh, /* indexed through 32-bits register in bits 20-22 with 32-bits displacement at end of instruction */
+
+ DASM_psp, /* indexed through predecremented stack pointer */
+ DASM_spp, /* indexed through postincremented stack pointer */
+
+ DASM_r32n2l, /* Block of 2 registers */
+ DASM_r32n3l, /* Block of 3 registers */
+ DASM_r32n4l, /* Block of 4 registers */
+
+ DASM_abs8, /* 8-bit address present at +1 */
+ DASM_abs16, /* 16-bit address present at end of instruction */
+ DASM_abs32, /* 32-bit address present at end of instruction */
+ DASM_abs8i, /* 8-bit indirect jump address present at +1 */
+ DASM_abs16e, /* 16-bit jump address present at +2 */
+ DASM_abs24e, /* 24-bit jump address present at +1 */
+
+ DASM_rel8, /* 8-bit pc-relative jump address at +1, offset=2 */
+ DASM_rel16, /* 16-bit pc-relative jump address at +2, offset=4 */
+
+ DASM_one, /* immediate value 1 */
+ DASM_two, /* immediate value 2 */
+ DASM_four, /* immediate value 4 */
+
+ DASM_imm2, /* 2-bit immediate in bits 4-5 (trapa) */
+ DASM_imm3, /* 3-bit immediate in bits 4-6 (bit selection */
+ DASM_imm8, /* 8-bit immediate at +1 */
+ DASM_imm16, /* 16-bit immediate at +2 */
+ DASM_imm32, /* 32-bit immediate at +2 */
+
+ DASM_ccr, /* internal register ccr */
+ DASM_exr, /* internal register exr */
+ DASM_macl, /* internal register macl */
+ DASM_mach /* internal register mach */
+ };
+
+ void disassemble_am(std::ostream &stream, int am, offs_t pc, const data_buffer &opcodes, u32 opcode, int slot, int offset);
+
+ const disasm_entry *table;
+
+ static const disasm_entry disasm_entries[];
+};
+
+#endif
diff --git a/src/devices/cpu/h8/h8h.cpp b/src/devices/cpu/h8/h8h.cpp
index 37756da3d12..97b945d8166 100644
--- a/src/devices/cpu/h8/h8h.cpp
+++ b/src/devices/cpu/h8/h8h.cpp
@@ -2,6 +2,7 @@
// copyright-holders:Olivier Galibert
#include "emu.h"
#include "h8h.h"
+#include "h8hd.h"
h8h_device::h8h_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, address_map_delegate map_delegate) :
h8_device(mconfig, type, tag, owner, clock, false, map_delegate)
@@ -10,9 +11,9 @@ h8h_device::h8h_device(const machine_config &mconfig, device_type type, const ch
mode_advanced = true;
}
-offs_t h8h_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options)
+util::disasm_interface *h8h_device::create_disassembler()
{
- return disassemble_generic(stream, pc, oprom, opram, options, disasm_entries);
+ return new h8h_disassembler;
}
#include "cpu/h8/h8h.hxx"
diff --git a/src/devices/cpu/h8/h8h.h b/src/devices/cpu/h8/h8h.h
index 460ddcefc3a..4c8c226a516 100644
--- a/src/devices/cpu/h8/h8h.h
+++ b/src/devices/cpu/h8/h8h.h
@@ -20,11 +20,9 @@
class h8h_device : public h8_device {
protected:
- static const disasm_entry disasm_entries[];
-
h8h_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, address_map_delegate map_delegate);
- 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;
virtual void do_exec_full() override;
virtual void do_exec_partial() override;
diff --git a/src/devices/cpu/h8/h8hd.cpp b/src/devices/cpu/h8/h8hd.cpp
new file mode 100644
index 00000000000..c6cb3238784
--- /dev/null
+++ b/src/devices/cpu/h8/h8hd.cpp
@@ -0,0 +1,17 @@
+// license:BSD-3-Clause
+// copyright-holders:Olivier Galibert
+/***************************************************************************
+
+ h8d.h
+
+ H8-300H base cpu emulation, disassembler
+
+***************************************************************************/
+
+#include "emu.h"
+#include "h8hd.h"
+#include "cpu/h8/h8hd.hxx"
+
+h8h_disassembler::h8h_disassembler() : h8_disassembler(disasm_entries)
+{
+}
diff --git a/src/devices/cpu/h8/h8hd.h b/src/devices/cpu/h8/h8hd.h
new file mode 100644
index 00000000000..5123ee32563
--- /dev/null
+++ b/src/devices/cpu/h8/h8hd.h
@@ -0,0 +1,28 @@
+// license:BSD-3-Clause
+// copyright-holders:Olivier Galibert
+/***************************************************************************
+
+ h8hd.h
+
+ H8-300H base cpu emulation, disassembler
+
+***************************************************************************/
+
+#ifndef MAME_CPU_H8_H8HD_H
+#define MAME_CPU_H8_H8HD_H
+
+#pragma once
+
+#include "h8d.h"
+
+class h8h_disassembler : public h8_disassembler
+{
+public:
+ h8h_disassembler();
+ virtual ~h8h_disassembler() = default;
+
+protected:
+ static const disasm_entry disasm_entries[];
+};
+
+#endif
diff --git a/src/devices/cpu/h8/h8make.py b/src/devices/cpu/h8/h8make.py
index e5aee1dbb96..99883e92c2a 100644
--- a/src/devices/cpu/h8/h8make.py
+++ b/src/devices/cpu/h8/h8make.py
@@ -5,7 +5,7 @@ from __future__ import print_function
USAGE = """
Usage:
-%s h8.lst <type> h8.inc (type = o/h/s20/s26)
+%s h8.lst <mode> <type> h8.inc (mode = s/d, type = o/h/s20/s26)
"""
import sys
@@ -21,14 +21,23 @@ def name_to_type(name):
sys.stderr.write("Unknown chip type name %s\n" % name)
sys.exit(1)
-def type_to_device(dtype):
- if dtype == 0:
- return "h8_device"
- if dtype == 1:
- return "h8h_device"
- if dtype == 2:
- return "h8s2000_device"
- return "h8s2600_device"
+def type_to_device(dtype, mode):
+ if mode == 's':
+ if dtype == 0:
+ return "h8_device"
+ if dtype == 1:
+ return "h8h_device"
+ if dtype == 2:
+ return "h8s2000_device"
+ return "h8s2600_device"
+ else:
+ if dtype == 0:
+ return "h8_disassembler"
+ if dtype == 1:
+ return "h8h_disassembler"
+ if dtype == 2:
+ return "h8s2000_disassembler"
+ return "h8s2600_disassembler"
def hexsplit(str):
res = []
@@ -182,9 +191,9 @@ class Opcode:
size = len(self.val) + 2*self.skip + 2*self.extra_words
if self.name == "jsr" or self.name == "bsr":
- flags = "%d | DASMFLAG_STEP_OVER" % size
+ flags = "%d | STEP_OVER" % size
elif self.name == "rts" or self.name == "rte":
- flags = "%d | DASMFLAG_STEP_OUT" % size
+ flags = "%d | STEP_OUT" % size
else:
flags = "%d" % size
@@ -445,28 +454,31 @@ class OpcodeList:
print("}", file=f)
def main(argv):
- if len(argv) != 4:
+ if len(argv) != 5:
print(USAGE % argv[0])
return 1
- dtype = name_to_type(argv[2])
- dname = type_to_device(dtype)
+ mode = argv[2]
+ dtype = name_to_type(argv[3])
+ dname = type_to_device(dtype, mode)
opcodes = OpcodeList(argv[1], dtype)
try:
- f = open(argv[3], "w")
+ f = open(argv[4], "w")
except Exception:
err = sys.exc_info()[1]
- sys.stderr.write("cannot write file %s [%s]\n" % (argv[3], err))
+ sys.stderr.write("cannot write file %s [%s]\n" % (argv[4], err))
sys.exit(1)
- opcodes.build_dispatch()
- opcodes.save_dasm(f, dname)
- opcodes.save_opcodes(f, dname)
- if dtype == 0:
- opcodes.save_dispatch(f, dname)
- opcodes.save_exec(f, dname, dtype, "full")
- opcodes.save_exec(f, dname, dtype, "partial")
+ if mode == 's':
+ opcodes.build_dispatch()
+ opcodes.save_opcodes(f, dname)
+ if dtype == 0:
+ opcodes.save_dispatch(f, dname)
+ opcodes.save_exec(f, dname, dtype, "full")
+ opcodes.save_exec(f, dname, dtype, "partial")
+ else:
+ opcodes.save_dasm(f, dname)
f.close()
# ======================================================================
diff --git a/src/devices/cpu/h8/h8s2000.cpp b/src/devices/cpu/h8/h8s2000.cpp
index 2af090f5867..95e10cc2c50 100644
--- a/src/devices/cpu/h8/h8s2000.cpp
+++ b/src/devices/cpu/h8/h8s2000.cpp
@@ -2,6 +2,7 @@
// copyright-holders:Olivier Galibert
#include "emu.h"
#include "h8s2000.h"
+#include "h8s2000d.h"
h8s2000_device::h8s2000_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, address_map_delegate map_delegate) :
h8h_device(mconfig, type, tag, owner, clock, map_delegate)
@@ -9,9 +10,9 @@ h8s2000_device::h8s2000_device(const machine_config &mconfig, device_type type,
has_exr = true;
}
-offs_t h8s2000_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options)
+util::disasm_interface *h8s2000_device::create_disassembler()
{
- return disassemble_generic(stream, pc, oprom, opram, options, disasm_entries);
+ return new h8s2000_disassembler;
}
#include "cpu/h8/h8s2000.hxx"
diff --git a/src/devices/cpu/h8/h8s2000.h b/src/devices/cpu/h8/h8s2000.h
index e28e640baec..8aa195df7ad 100644
--- a/src/devices/cpu/h8/h8s2000.h
+++ b/src/devices/cpu/h8/h8s2000.h
@@ -24,9 +24,7 @@ class h8s2000_device : public h8h_device {
protected:
h8s2000_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, address_map_delegate map_delegate);
- static const disasm_entry disasm_entries[];
-
- 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;
virtual void do_exec_full() override;
virtual void do_exec_partial() override;
diff --git a/src/devices/cpu/h8/h8s2000d.cpp b/src/devices/cpu/h8/h8s2000d.cpp
new file mode 100644
index 00000000000..1e0b3830f53
--- /dev/null
+++ b/src/devices/cpu/h8/h8s2000d.cpp
@@ -0,0 +1,17 @@
+// license:BSD-3-Clause
+// copyright-holders:Olivier Galibert
+/***************************************************************************
+
+ h8d.h
+
+ H8S-2000 base cpu emulation, disassembler
+
+***************************************************************************/
+
+#include "emu.h"
+#include "h8s2000d.h"
+#include "cpu/h8/h8s2000d.hxx"
+
+h8s2000_disassembler::h8s2000_disassembler() : h8_disassembler(disasm_entries)
+{
+}
diff --git a/src/devices/cpu/h8/h8s2000d.h b/src/devices/cpu/h8/h8s2000d.h
new file mode 100644
index 00000000000..cf6bc5bfa9e
--- /dev/null
+++ b/src/devices/cpu/h8/h8s2000d.h
@@ -0,0 +1,28 @@
+// license:BSD-3-Clause
+// copyright-holders:Olivier Galibert
+/***************************************************************************
+
+ h8s2000d.h
+
+ H8S-2000 base cpu emulation, disassembler
+
+***************************************************************************/
+
+#ifndef MAME_CPU_H8_H8S2000D_H
+#define MAME_CPU_H8_H8S2000D_H
+
+#pragma once
+
+#include "h8d.h"
+
+class h8s2000_disassembler : public h8_disassembler
+{
+public:
+ h8s2000_disassembler();
+ virtual ~h8s2000_disassembler() = default;
+
+protected:
+ static const disasm_entry disasm_entries[];
+};
+
+#endif
diff --git a/src/devices/cpu/h8/h8s2600.cpp b/src/devices/cpu/h8/h8s2600.cpp
index 188f879279d..171dfef2d9b 100644
--- a/src/devices/cpu/h8/h8s2600.cpp
+++ b/src/devices/cpu/h8/h8s2600.cpp
@@ -2,15 +2,16 @@
// copyright-holders:Olivier Galibert
#include "emu.h"
#include "h8s2600.h"
+#include "h8s2600d.h"
h8s2600_device::h8s2600_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, address_map_delegate map_delegate) :
h8s2000_device(mconfig, type, tag, owner, clock, map_delegate)
{
}
-offs_t h8s2600_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options)
+util::disasm_interface *h8s2600_device::create_disassembler()
{
- return disassemble_generic(stream, pc, oprom, opram, options, disasm_entries);
+ return new h8s2600_disassembler;
}
#include "cpu/h8/h8s2600.hxx"
diff --git a/src/devices/cpu/h8/h8s2600.h b/src/devices/cpu/h8/h8s2600.h
index 45b84bb2f8c..e3b4b7e44a9 100644
--- a/src/devices/cpu/h8/h8s2600.h
+++ b/src/devices/cpu/h8/h8s2600.h
@@ -20,11 +20,9 @@
class h8s2600_device : public h8s2000_device {
protected:
- static const disasm_entry disasm_entries[];
-
h8s2600_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, address_map_delegate map_delegate);
- 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;
virtual void do_exec_full() override;
virtual void do_exec_partial() override;
diff --git a/src/devices/cpu/h8/h8s2600d.cpp b/src/devices/cpu/h8/h8s2600d.cpp
new file mode 100644
index 00000000000..7e55784bed0
--- /dev/null
+++ b/src/devices/cpu/h8/h8s2600d.cpp
@@ -0,0 +1,17 @@
+// license:BSD-3-Clause
+// copyright-holders:Olivier Galibert
+/***************************************************************************
+
+ h8d.h
+
+ H8S-2600 base cpu emulation, disassembler
+
+***************************************************************************/
+
+#include "emu.h"
+#include "h8s2600d.h"
+#include "cpu/h8/h8s2600d.hxx"
+
+h8s2600_disassembler::h8s2600_disassembler() : h8_disassembler(disasm_entries)
+{
+}
diff --git a/src/devices/cpu/h8/h8s2600d.h b/src/devices/cpu/h8/h8s2600d.h
new file mode 100644
index 00000000000..3ee3fbfe133
--- /dev/null
+++ b/src/devices/cpu/h8/h8s2600d.h
@@ -0,0 +1,28 @@
+// license:BSD-3-Clause
+// copyright-holders:Olivier Galibert
+/***************************************************************************
+
+ h8s2600d.h
+
+ H8S-2600 base cpu emulation, disassembler
+
+***************************************************************************/
+
+#ifndef MAME_CPU_H8_H8S2600D_H
+#define MAME_CPU_H8_H8S2600D_H
+
+#pragma once
+
+#include "h8d.h"
+
+class h8s2600_disassembler : public h8_disassembler
+{
+public:
+ h8s2600_disassembler();
+ virtual ~h8s2600_disassembler() = default;
+
+protected:
+ static const disasm_entry disasm_entries[];
+};
+
+#endif