diff options
Diffstat (limited to 'src/devices/cpu/cop400')
-rw-r--r-- | src/devices/cpu/cop400/cop400.cpp | 68 | ||||
-rw-r--r-- | src/devices/cpu/cop400/cop400.h | 15 | ||||
-rw-r--r-- | src/devices/cpu/cop400/cop410ds.cpp | 22 | ||||
-rw-r--r-- | src/devices/cpu/cop400/cop410ds.h | 26 | ||||
-rw-r--r-- | src/devices/cpu/cop400/cop420ds.cpp | 22 | ||||
-rw-r--r-- | src/devices/cpu/cop400/cop420ds.h | 26 | ||||
-rw-r--r-- | src/devices/cpu/cop400/cop424ds.cpp | 22 | ||||
-rw-r--r-- | src/devices/cpu/cop400/cop424ds.h | 26 | ||||
-rw-r--r-- | src/devices/cpu/cop400/cop444ds.cpp | 22 | ||||
-rw-r--r-- | src/devices/cpu/cop400/cop444ds.h | 26 |
10 files changed, 196 insertions, 79 deletions
diff --git a/src/devices/cpu/cop400/cop400.cpp b/src/devices/cpu/cop400/cop400.cpp index 30b1680150a..03416a54b28 100644 --- a/src/devices/cpu/cop400/cop400.cpp +++ b/src/devices/cpu/cop400/cop400.cpp @@ -56,6 +56,10 @@ #include "emu.h" #include "debugger.h" #include "cop400.h" +#include "cop410ds.h" +#include "cop420ds.h" +#include "cop424ds.h" +#include "cop444ds.h" DEFINE_DEVICE_TYPE(COP401, cop401_cpu_device, "cop401", "COP401") @@ -1064,7 +1068,7 @@ void cop400_cpu_device::device_start() { /* find address spaces */ m_program = &space(AS_PROGRAM); - m_direct = &m_program->direct(); + m_direct = m_program->direct<0>(); m_data = &space(AS_DATA); /* find i/o handlers */ @@ -1117,9 +1121,10 @@ void cop400_cpu_device::device_start() // setup debugger state display offs_t pc_mask = m_program->addrmask(); + using namespace std::placeholders; state_add(STATE_GENPC, "GENPC", m_pc).mask(pc_mask).noshow(); state_add(STATE_GENPCBASE, "CURPC", m_prevpc).mask(pc_mask).noshow(); - state_add(STATE_GENFLAGS, "GENFLAGS", m_flags).mask(0x7).callimport().callexport().noshow().formatstr("%3s"); + state_add<uint8_t>(STATE_GENFLAGS, "GENFLAGS", std::bind(&cop400_cpu_device::get_flags, this), std::bind(&cop400_cpu_device::set_flags, this, _1)).mask(0x7).noshow().formatstr("%3s"); state_add(COP400_PC, "PC", m_pc).mask(pc_mask); state_add(COP400_SA, "SA", m_sa).mask(pc_mask); state_add(COP400_SB, "SB", m_sb).mask(pc_mask); @@ -1127,7 +1132,7 @@ void cop400_cpu_device::device_start() state_add(COP400_SC, "SC", m_sc).mask(pc_mask); state_add(COP400_B, "B", m_b); state_add(COP400_A, "A", m_a).mask(0xf); - state_add(COP400_M, "M", m_temp_m).mask(0xf).callimport().callexport(); + state_add<uint8_t>(COP400_M, "M", std::bind(&cop400_cpu_device::get_m, this), std::bind(&cop400_cpu_device::set_m, this, _1)).mask(0xf); state_add(COP400_G, "G", m_g).mask(0xf); state_add(COP400_Q, "Q", m_q); state_add(COP400_SIO, "SIO", m_sio).mask(0xf).formatstr("%4s"); @@ -1145,8 +1150,6 @@ void cop400_cpu_device::device_start() m_sb = 0; m_sc = 0; m_sio = 0; - m_flags = 0; - m_temp_m = 0; m_il = 0; m_in[0] = m_in[1] = m_in[2] = m_in[3] = 0; m_si = 0; @@ -1309,36 +1312,28 @@ void cop400_cpu_device::execute_run() GENERAL CONTEXT ACCESS ***************************************************************************/ -void cop400_cpu_device::state_import(const device_state_entry &entry) +uint8_t cop400_cpu_device::get_flags() const { - switch (entry.index()) - { - case STATE_GENFLAGS: - m_skt_latch = BIT(m_flags, 2); - m_c = BIT(m_flags, 1); - m_skl = BIT(m_flags, 0); - break; + return (m_skt_latch ? 0x04 : 0x00) | (m_c ? 0x02 : 0x00) | (m_skl ? 0x01 : 0x00); +} - case COP400_M: - auto dis = machine().disable_side_effect(); - RAM_W(B, m_temp_m); - break; - } +void cop400_cpu_device::set_flags(uint8_t flags) +{ + m_skt_latch = BIT(flags, 2); + m_c = BIT(flags, 1); + m_skl = BIT(flags, 0); } -void cop400_cpu_device::state_export(const device_state_entry &entry) +uint8_t cop400_cpu_device::get_m() const { - switch (entry.index()) - { - case STATE_GENFLAGS: - m_flags = (m_skt_latch ? 0x04 : 0x00) | (m_c ? 0x02 : 0x00) | (m_skl ? 0x01 : 0x00); - break; + auto dis = machine().disable_side_effect(); + return RAM_R(B); +} - case COP400_M: - auto dis = machine().disable_side_effect(); - m_temp_m = RAM_R(B); - break; - } +void cop400_cpu_device::set_m(uint8_t m) +{ + auto dis = machine().disable_side_effect(); + RAM_W(B, m); } void cop400_cpu_device::state_string_export(const device_state_entry &entry, std::string &str) const @@ -1371,29 +1366,24 @@ void cop400_cpu_device::state_string_export(const device_state_entry &entry, std } -offs_t cop400_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +util::disasm_interface *cop400_cpu_device::create_disassembler() { - extern CPU_DISASSEMBLE( cop410 ); - extern CPU_DISASSEMBLE( cop420 ); - extern CPU_DISASSEMBLE( cop444 ); - extern CPU_DISASSEMBLE( cop424 ); - if ( m_featuremask & COP424C_FEATURE ) { - return CPU_DISASSEMBLE_NAME(cop424)(this, stream, pc, oprom, opram, options); + return new cop424_disassembler; } if ( m_featuremask & COP444L_FEATURE ) { - return CPU_DISASSEMBLE_NAME(cop444)(this, stream, pc, oprom, opram, options); + return new cop444_disassembler; } if ( m_featuremask & COP420_FEATURE ) { - return CPU_DISASSEMBLE_NAME(cop420)(this, stream, pc, oprom, opram, options); + return new cop420_disassembler; } - return CPU_DISASSEMBLE_NAME(cop410)(this, stream, pc, oprom, opram, options); + return new cop410_disassembler; } READ8_MEMBER( cop400_cpu_device::microbus_rd ) diff --git a/src/devices/cpu/cop400/cop400.h b/src/devices/cpu/cop400/cop400.h index 13461ffe583..d98d7bbbc6f 100644 --- a/src/devices/cpu/cop400/cop400.h +++ b/src/devices/cpu/cop400/cop400.h @@ -162,14 +162,10 @@ protected: virtual space_config_vector memory_space_config() const override; // device_state_interface overrides - virtual void state_import(const device_state_entry &entry) override; - virtual void state_export(const device_state_entry &entry) override; 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 2; } - 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 m_program_config; address_space_config m_data_config; @@ -209,7 +205,7 @@ protected: bool m_has_inil; address_space *m_program; - direct_read_data *m_direct; + direct_read_data<0> *m_direct; address_space *m_data; uint8_t m_featuremask; @@ -226,8 +222,6 @@ protected: uint16_t m_sa, m_sb, m_sc; /* subroutine save registers */ uint8_t m_sio; /* 4-bit shift register and counter */ int m_skl; /* 1-bit latch for SK output */ - uint8_t m_flags; // used for debugger state only - uint8_t m_temp_m; // 4-bit RAM at B (for debugger state only) /* counter */ uint8_t m_t; /* 8-bit timer */ @@ -289,6 +283,11 @@ protected: void skip(); void sk_update(); + uint8_t get_flags() const; + void set_flags(uint8_t flags); + uint8_t get_m() const; + void set_m(uint8_t m); + void illegal(uint8_t operand); void asc(uint8_t operand); void add(uint8_t operand); diff --git a/src/devices/cpu/cop400/cop410ds.cpp b/src/devices/cpu/cop400/cop410ds.cpp index 4570417538f..9da69df8034 100644 --- a/src/devices/cpu/cop400/cop410ds.cpp +++ b/src/devices/cpu/cop400/cop410ds.cpp @@ -9,11 +9,17 @@ ***************************************************************************/ #include "emu.h" +#include "cop410ds.h" -CPU_DISASSEMBLE(cop410) +u32 cop410_disassembler::opcode_alignment() const { - uint8_t opcode = oprom[0]; - uint8_t next_opcode = oprom[1]; + return 1; +} + +offs_t cop410_disassembler::disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer ¶ms) +{ + uint8_t opcode = opcodes.r8(pc); + uint8_t next_opcode = opcodes.r8(pc+1); uint16_t address; uint32_t flags = 0; int bytes = 1; @@ -38,7 +44,7 @@ CPU_DISASSEMBLE(cop410) { address = (uint16_t)(0x80 | (opcode & 0x3F)); util::stream_format(stream, "JSRP %03X", address); - flags = DASMFLAG_STEP_OVER; + flags = STEP_OVER; } } } @@ -72,7 +78,7 @@ CPU_DISASSEMBLE(cop410) { address = ((opcode & 0x01) << 8) | next_opcode; util::stream_format(stream, "JSR %03X", address); - flags = DASMFLAG_STEP_OVER; + flags = STEP_OVER; bytes = 2; } else if (opcode >= 0x70 && opcode <= 0x7F) @@ -302,12 +308,12 @@ CPU_DISASSEMBLE(cop410) case 0x48: util::stream_format(stream, "RET"); - flags = DASMFLAG_STEP_OUT; + flags = STEP_OUT; break; case 0x49: util::stream_format(stream, "RETSK"); - flags = DASMFLAG_STEP_OUT; + flags = STEP_OUT; break; case 0x4B: @@ -348,5 +354,5 @@ CPU_DISASSEMBLE(cop410) } } - return bytes | flags | DASMFLAG_SUPPORTED; + return bytes | flags | SUPPORTED; } diff --git a/src/devices/cpu/cop400/cop410ds.h b/src/devices/cpu/cop400/cop410ds.h new file mode 100644 index 00000000000..c1841ec996c --- /dev/null +++ b/src/devices/cpu/cop400/cop410ds.h @@ -0,0 +1,26 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/*************************************************************************** + + cop410ds.c + + National Semiconductor COP410 Emulator. + +***************************************************************************/ + +#ifndef MAME_CPU_COP410_COP410DS_H +#define MAME_CPU_COP410_COP410DS_H + +#pragma once + +class cop410_disassembler : public util::disasm_interface +{ +public: + cop410_disassembler() = default; + virtual ~cop410_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 ¶ms) override; +}; + +#endif diff --git a/src/devices/cpu/cop400/cop420ds.cpp b/src/devices/cpu/cop400/cop420ds.cpp index 39ea87ba9b4..f8f910f174b 100644 --- a/src/devices/cpu/cop400/cop420ds.cpp +++ b/src/devices/cpu/cop400/cop420ds.cpp @@ -9,11 +9,17 @@ ***************************************************************************/ #include "emu.h" +#include "cop420ds.h" -CPU_DISASSEMBLE(cop420) +u32 cop420_disassembler::opcode_alignment() const { - uint8_t opcode = oprom[0]; - uint8_t next_opcode = oprom[1]; + return 1; +} + +offs_t cop420_disassembler::disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer ¶ms) +{ + uint8_t opcode = opcodes.r8(pc); + uint8_t next_opcode = opcodes.r8(pc+1); uint16_t address; uint32_t flags = 0; int bytes = 1; @@ -38,7 +44,7 @@ CPU_DISASSEMBLE(cop420) { address = (uint16_t)(0x80 | (opcode & 0x3F)); util::stream_format(stream, "JSRP %03X", address); - flags = DASMFLAG_STEP_OVER; + flags = STEP_OVER; } } } @@ -72,7 +78,7 @@ CPU_DISASSEMBLE(cop420) { address = ((opcode & 0x03) << 8) | next_opcode; util::stream_format(stream, "JSR %03X", address); - flags = DASMFLAG_STEP_OVER; + flags = STEP_OVER; bytes = 2; } else if (opcode >= 0x70 && opcode <= 0x7F) @@ -346,12 +352,12 @@ CPU_DISASSEMBLE(cop420) case 0x48: util::stream_format(stream, "RET"); - flags = DASMFLAG_STEP_OUT; + flags = STEP_OUT; break; case 0x49: util::stream_format(stream, "RETSK"); - flags = DASMFLAG_STEP_OUT; + flags = STEP_OUT; break; case 0x4A: @@ -396,5 +402,5 @@ CPU_DISASSEMBLE(cop420) } } - return bytes | flags | DASMFLAG_SUPPORTED; + return bytes | flags | SUPPORTED; } diff --git a/src/devices/cpu/cop400/cop420ds.h b/src/devices/cpu/cop400/cop420ds.h new file mode 100644 index 00000000000..a92ba84a54f --- /dev/null +++ b/src/devices/cpu/cop400/cop420ds.h @@ -0,0 +1,26 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/*************************************************************************** + + cop420ds.c + + National Semiconductor COP420 Emulator. + +***************************************************************************/ + +#ifndef MAME_CPU_COP420_COP420DS_H +#define MAME_CPU_COP420_COP420DS_H + +#pragma once + +class cop420_disassembler : public util::disasm_interface +{ +public: + cop420_disassembler() = default; + virtual ~cop420_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 ¶ms) override; +}; + +#endif diff --git a/src/devices/cpu/cop400/cop424ds.cpp b/src/devices/cpu/cop400/cop424ds.cpp index fc8396f4903..e42c5dc3120 100644 --- a/src/devices/cpu/cop400/cop424ds.cpp +++ b/src/devices/cpu/cop400/cop424ds.cpp @@ -9,11 +9,17 @@ ***************************************************************************/ #include "emu.h" +#include "cop424ds.h" -CPU_DISASSEMBLE(cop424) +u32 cop424_disassembler::opcode_alignment() const { - uint8_t opcode = oprom[0]; - uint8_t next_opcode = oprom[1]; + return 1; +} + +offs_t cop424_disassembler::disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer ¶ms) +{ + uint8_t opcode = opcodes.r8(pc); + uint8_t next_opcode = opcodes.r8(pc+1); uint16_t address; uint32_t flags = 0; int bytes = 1; @@ -38,7 +44,7 @@ CPU_DISASSEMBLE(cop424) { address = (uint16_t)(0x80 | (opcode & 0x3F)); util::stream_format(stream, "JSRP %03X", address); - flags = DASMFLAG_STEP_OVER; + flags = STEP_OVER; } } } @@ -72,7 +78,7 @@ CPU_DISASSEMBLE(cop424) { address = ((opcode & 0x07) << 8) | next_opcode; util::stream_format(stream, "JSR %03X", address); - flags = DASMFLAG_STEP_OVER; + flags = STEP_OVER; bytes = 2; } else if (opcode >= 0x70 && opcode <= 0x7F) @@ -347,12 +353,12 @@ CPU_DISASSEMBLE(cop424) case 0x48: util::stream_format(stream, "RET"); - flags = DASMFLAG_STEP_OUT; + flags = STEP_OUT; break; case 0x49: util::stream_format(stream, "RETSK"); - flags = DASMFLAG_STEP_OUT; + flags = STEP_OUT; break; case 0x4A: @@ -397,5 +403,5 @@ CPU_DISASSEMBLE(cop424) } } - return bytes | flags | DASMFLAG_SUPPORTED; + return bytes | flags | SUPPORTED; } diff --git a/src/devices/cpu/cop400/cop424ds.h b/src/devices/cpu/cop400/cop424ds.h new file mode 100644 index 00000000000..e093568a913 --- /dev/null +++ b/src/devices/cpu/cop400/cop424ds.h @@ -0,0 +1,26 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/*************************************************************************** + + cop424ds.c + + National Semiconductor COP424 Emulator. + +***************************************************************************/ + +#ifndef MAME_CPU_COP424_COP424DS_H +#define MAME_CPU_COP424_COP424DS_H + +#pragma once + +class cop424_disassembler : public util::disasm_interface +{ +public: + cop424_disassembler() = default; + virtual ~cop424_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 ¶ms) override; +}; + +#endif diff --git a/src/devices/cpu/cop400/cop444ds.cpp b/src/devices/cpu/cop400/cop444ds.cpp index cae2274546c..23e6cd23cec 100644 --- a/src/devices/cpu/cop400/cop444ds.cpp +++ b/src/devices/cpu/cop400/cop444ds.cpp @@ -9,11 +9,17 @@ ***************************************************************************/ #include "emu.h" +#include "cop444ds.h" -CPU_DISASSEMBLE(cop444) +u32 cop444_disassembler::opcode_alignment() const { - uint8_t opcode = oprom[0]; - uint8_t next_opcode = oprom[1]; + return 1; +} + +offs_t cop444_disassembler::disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer ¶ms) +{ + uint8_t opcode = opcodes.r8(pc); + uint8_t next_opcode = opcodes.r8(pc+1); uint16_t address; uint32_t flags = 0; int bytes = 1; @@ -38,7 +44,7 @@ CPU_DISASSEMBLE(cop444) { address = (uint16_t)(0x80 | (opcode & 0x3F)); util::stream_format(stream, "JSRP %03X", address); - flags = DASMFLAG_STEP_OVER; + flags = STEP_OVER; } } } @@ -72,7 +78,7 @@ CPU_DISASSEMBLE(cop444) { address = ((opcode & 0x07) << 8) | next_opcode; util::stream_format(stream, "JSR %03X", address); - flags = DASMFLAG_STEP_OVER; + flags = STEP_OVER; bytes = 2; } else if (opcode >= 0x70 && opcode <= 0x7F) @@ -330,12 +336,12 @@ CPU_DISASSEMBLE(cop444) case 0x48: util::stream_format(stream, "RET"); - flags = DASMFLAG_STEP_OUT; + flags = STEP_OUT; break; case 0x49: util::stream_format(stream, "RETSK"); - flags = DASMFLAG_STEP_OUT; + flags = STEP_OUT; break; case 0x4A: @@ -380,5 +386,5 @@ CPU_DISASSEMBLE(cop444) } } - return bytes | flags | DASMFLAG_SUPPORTED; + return bytes | flags | SUPPORTED; } diff --git a/src/devices/cpu/cop400/cop444ds.h b/src/devices/cpu/cop400/cop444ds.h new file mode 100644 index 00000000000..c268616f846 --- /dev/null +++ b/src/devices/cpu/cop400/cop444ds.h @@ -0,0 +1,26 @@ +// license:BSD-3-Clause +// copyright-holders:Curt Coder +/*************************************************************************** + + cop444ds.c + + National Semiconductor COP444 Emulator. + +***************************************************************************/ + +#ifndef MAME_CPU_COP444_COP444DS_H +#define MAME_CPU_COP444_COP444DS_H + +#pragma once + +class cop444_disassembler : public util::disasm_interface +{ +public: + cop444_disassembler() = default; + virtual ~cop444_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 ¶ms) override; +}; + +#endif |