diff options
Diffstat (limited to 'src/devices/cpu/unsp')
-rw-r--r-- | src/devices/cpu/unsp/unsp.cpp | 10 | ||||
-rw-r--r-- | src/devices/cpu/unsp/unsp.h | 4 | ||||
-rw-r--r-- | src/devices/cpu/unsp/unspdasm.cpp | 23 | ||||
-rw-r--r-- | src/devices/cpu/unsp/unspdasm.h | 32 |
4 files changed, 51 insertions, 18 deletions
diff --git a/src/devices/cpu/unsp/unsp.cpp b/src/devices/cpu/unsp/unsp.cpp index cb14e9cdec4..8ee2111af65 100644 --- a/src/devices/cpu/unsp/unsp.cpp +++ b/src/devices/cpu/unsp/unsp.cpp @@ -10,6 +10,7 @@ #include "emu.h" #include "unsp.h" +#include "unspdasm.h" #include "debugger.h" @@ -30,10 +31,9 @@ device_memory_interface::space_config_vector unsp_device::memory_space_config() }; } -offs_t unsp_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options) +util::disasm_interface *unsp_device::create_disassembler() { - extern CPU_DISASSEMBLE( unsp ); - return CPU_DISASSEMBLE_NAME(unsp)(this, stream, pc, oprom, opram, options); + return new unsp_disassembler; } @@ -116,12 +116,12 @@ void unsp_device::unimplemented_opcode(uint16_t op) uint16_t unsp_device::READ16(uint32_t address) { - return m_program->read_word(address<<1); + return m_program->read_word(address); } void unsp_device::WRITE16(uint32_t address, uint16_t data) { - m_program->write_word(address<<1, data); + m_program->write_word(address, data); } /*****************************************************************************/ diff --git a/src/devices/cpu/unsp/unsp.h b/src/devices/cpu/unsp/unsp.h index 5a445e05099..331bbf46786 100644 --- a/src/devices/cpu/unsp/unsp.h +++ b/src/devices/cpu/unsp/unsp.h @@ -75,9 +75,7 @@ protected: virtual void state_export(const device_state_entry &entry) override; // device_disasm_interface overrides - virtual uint32_t disasm_min_opcode_bytes() const override { return 2; } - 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; diff --git a/src/devices/cpu/unsp/unspdasm.cpp b/src/devices/cpu/unsp/unspdasm.cpp index 68d620fb7b6..bdea7a729a5 100644 --- a/src/devices/cpu/unsp/unspdasm.cpp +++ b/src/devices/cpu/unsp/unspdasm.cpp @@ -9,22 +9,22 @@ \**************************/ #include "emu.h" -#include <stdarg.h> +#include "unspdasm.h" /*****************************************************************************/ -static const char *reg[] = +const char *unsp_disassembler::reg[] = { "sp", "r1", "r2", "r3", "r4", "bp", "sr", "pc" }; -static const char *jmp[] = +const char *unsp_disassembler::jmp[] = { "jb", "jae", "jge", "jl", "jne", "je", "jpl", "jmi", "jbe", "ja", "jle", "jg", "jvc", "jvs", "jmp", "<inv>" }; -static const char *alu[] = +const char *unsp_disassembler::alu[] = { "add", "adc", "sub", "sbc", "cmp", "<inv>", "neg", "<inv>", @@ -44,14 +44,17 @@ static const char *alu[] = /*****************************************************************************/ -#define UNSP_DASM_OK ((OP2X ? 2 : 1) | DASMFLAG_SUPPORTED) +#define UNSP_DASM_OK ((OP2X ? 2 : 1) | SUPPORTED) -CPU_DISASSEMBLE(unsp) +u32 unsp_disassembler::opcode_alignment() const { - uint16_t op = *(uint16_t *)oprom; - uint16_t imm16 = *(uint16_t *)(oprom + 2); - op = big_endianize_int16(op); - imm16 = big_endianize_int16(imm16); + return 1; +} + +offs_t unsp_disassembler::disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer ¶ms) +{ + uint16_t op = opcodes.r16(pc); + uint16_t imm16 = opcodes.r16(pc+1); if(OP0 < 0xf && OPA == 0x7 && OP1 < 2) { diff --git a/src/devices/cpu/unsp/unspdasm.h b/src/devices/cpu/unsp/unspdasm.h new file mode 100644 index 00000000000..ef25b2a433b --- /dev/null +++ b/src/devices/cpu/unsp/unspdasm.h @@ -0,0 +1,32 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz +/**************************\ +* +* SunPlus u'nSP disassembler +* +* by Ryan Holtz +* +\**************************/ + + +#ifndef MAME_CPU_UNSP_UNSPDASM_H +#define MAME_CPU_UNSP_UNSPDASM_H + +#pragma once + +class unsp_disassembler : public util::disasm_interface +{ +public: + unsp_disassembler() = default; + virtual ~unsp_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: + static const char *reg[]; + static const char *jmp[]; + static const char *alu[]; +}; + +#endif |