diff options
Diffstat (limited to 'src/devices/cpu/sc61860')
-rw-r--r-- | src/devices/cpu/sc61860/sc61860.cpp | 10 | ||||
-rw-r--r-- | src/devices/cpu/sc61860/sc61860.h | 6 | ||||
-rw-r--r-- | src/devices/cpu/sc61860/scdasm.cpp | 49 | ||||
-rw-r--r-- | src/devices/cpu/sc61860/scdasm.h | 50 |
4 files changed, 75 insertions, 40 deletions
diff --git a/src/devices/cpu/sc61860/sc61860.cpp b/src/devices/cpu/sc61860/sc61860.cpp index a4f82ccdedc..7277cbc444c 100644 --- a/src/devices/cpu/sc61860/sc61860.cpp +++ b/src/devices/cpu/sc61860/sc61860.cpp @@ -19,7 +19,7 @@ #include "emu.h" #include "sc61860.h" - +#include "scdasm.h" #include "debugger.h" @@ -69,11 +69,9 @@ device_memory_interface::space_config_vector sc61860_device::memory_space_config }; } - -offs_t sc61860_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +util::disasm_interface *sc61860_device::create_disassembler() { - extern CPU_DISASSEMBLE( sc61860 ); - return CPU_DISASSEMBLE_NAME(sc61860)(this, stream, pc, oprom, opram, options); + return new sc61860_disassembler; } @@ -112,7 +110,7 @@ void sc61860_device::device_start() m_2ms_tick_timer->adjust(attotime::from_hz(500), 0, attotime::from_hz(500)); m_program = &space(AS_PROGRAM); - m_direct = &m_program->direct(); + m_direct = m_program->direct<0>(); m_reset.resolve(); m_brk.resolve(); m_x.resolve(); diff --git a/src/devices/cpu/sc61860/sc61860.h b/src/devices/cpu/sc61860/sc61860.h index de7653b73be..3b9e6745e4d 100644 --- a/src/devices/cpu/sc61860/sc61860.h +++ b/src/devices/cpu/sc61860/sc61860.h @@ -109,9 +109,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 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: address_space_config m_program_config; @@ -137,7 +135,7 @@ private: emu_timer *m_2ms_tick_timer; address_space *m_program; - direct_read_data *m_direct; + direct_read_data<0> *m_direct; int m_icount; uint8_t m_ram[0x100]; // internal special ram, should be 0x60, 0x100 to avoid memory corruption for now diff --git a/src/devices/cpu/sc61860/scdasm.cpp b/src/devices/cpu/sc61860/scdasm.cpp index 050dfaa3b1d..8b14a920d62 100644 --- a/src/devices/cpu/sc61860/scdasm.cpp +++ b/src/devices/cpu/sc61860/scdasm.cpp @@ -11,9 +11,7 @@ *****************************************************************************/ #include "emu.h" -#include "debugger.h" - -#include "sc61860.h" +#include "scdasm.h" /* new: @@ -67,21 +65,7 @@ ex exchange */ - -enum Adr -{ - Ill, - Imp, - Imm, ImmW, - RelP, RelM, - Abs, - Ptc, - Etc, - Cal, - Lp -}; - -static const struct { const char *mnemonic; Adr adr; } table[]={ +const sc61860_disassembler::opcode sc61860_disassembler::table[]={ { "LII", Imm }, { "LIJ", Imm }, { "LIA", Imm }, { "LIB", Imm }, { "IX", Imp }, { "DX", Imp }, { "IY", Imp }, { "DY", Imp }, { "MVW", Imp }, { "EXW", Imp }, { "MVB", Imp }, { "EXB", Imp }, @@ -152,10 +136,15 @@ static const struct { const char *mnemonic; Adr adr; } table[]={ { nullptr }, { nullptr }, { nullptr }, { nullptr }, { nullptr }, { nullptr }, { nullptr }, { nullptr }, }; -CPU_DISASSEMBLE(sc61860) +u32 sc61860_disassembler::opcode_alignment() const +{ + return 1; +} + +offs_t sc61860_disassembler::disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer ¶ms) { - const uint8_t *base_oprom = oprom; - int oper=*(oprom++); + offs_t pos = pc; + int oper=opcodes.r8(pos++); int t; uint16_t adr; @@ -167,32 +156,32 @@ CPU_DISASSEMBLE(sc61860) switch(oper&0xe0) { case 0xe0: util::stream_format(stream,"%-6s%04x",table[oper&0xe0].mnemonic, - *(oprom++)|((oper&0x1f)<<8)); + opcodes.r8(pos++)|((oper&0x1f)<<8)); break; default: switch (table[oper].adr) { case Ill: util::stream_format(stream,"?%02x",oper);break; case Imp: util::stream_format(stream,"%s",table[oper].mnemonic); break; - case Imm: util::stream_format(stream,"%-6s%02x",table[oper].mnemonic, *(oprom++)); break; + case Imm: util::stream_format(stream,"%-6s%02x",table[oper].mnemonic, opcodes.r8(pos++)); break; case ImmW: - adr=(oprom[0]<<8)|oprom[1];oprom+=2; + adr=opcodes.r16(pos); pos+=2; util::stream_format(stream,"%-6s%04x",table[oper].mnemonic, adr); break; case Abs: - adr=(oprom[0]<<8)|oprom[1];oprom+=2; + adr=opcodes.r16(pos); pos+=2; util::stream_format(stream,"%-6s%04x",table[oper].mnemonic, adr); break; case RelM: - adr=pc-*(oprom++); + adr=pc-opcodes.r8(pos++); util::stream_format(stream,"%-6s%04x",table[oper].mnemonic, adr&0xffff); break; case RelP: - adr=pc+*(oprom++); + adr=pc+opcodes.r8(pos++); util::stream_format(stream,"%-6s%04x",table[oper].mnemonic, adr&0xffff); break; case Ptc: - t=*(oprom++); - adr=(oprom[0]<<8)|oprom[1];oprom+=2; + t=opcodes.r8(pos++); + adr=opcodes.r16(pos); pos+=2; util::stream_format(stream,"%-6s%02x,%04x",table[oper].mnemonic,t, adr); break; case Etc: @@ -206,5 +195,5 @@ CPU_DISASSEMBLE(sc61860) } break; } - return oprom - base_oprom; + return pos - pc; } diff --git a/src/devices/cpu/sc61860/scdasm.h b/src/devices/cpu/sc61860/scdasm.h new file mode 100644 index 00000000000..575106ac2c8 --- /dev/null +++ b/src/devices/cpu/sc61860/scdasm.h @@ -0,0 +1,50 @@ +// license:BSD-3-Clause +// copyright-holders:Peter Trauner +/***************************************************************************** + * + * scdasm.c + * portable sharp 61860 emulator interface + * (sharp pocket computers) + * + * Copyright Peter Trauner, all rights reserved. + * + *****************************************************************************/ + +#ifndef MAME_CPU_SC61860_SCDASM_H +#define MAME_CPU_SC61860_SCDASM_H + +#pragma once + +class sc61860_disassembler : public util::disasm_interface +{ +public: + sc61860_disassembler() = default; + virtual ~sc61860_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; + +private: + enum Adr + { + Ill, + Imp, + Imm, ImmW, + RelP, RelM, + Abs, + Ptc, + Etc, + Cal, + Lp + }; + + struct opcode { + const char *mnemonic; + Adr adr; + }; + + static const opcode table[]; + +}; + +#endif |