From 90fef4da1613750f5fc5baf094a9385645003c59 Mon Sep 17 00:00:00 2001 From: DavidHaywood <28625134+DavidHaywood@users.noreply.github.com> Date: Fri, 14 Dec 2018 11:54:49 +0000 Subject: add derived CPU type for AX51-CORE (used by AX208 and others) so that we can start to customize disassembly and execution --- scripts/src/cpu.lua | 4 +++ src/devices/cpu/mcs51/axc51-core.cpp | 28 +++++++++++++++++++++ src/devices/cpu/mcs51/axc51-core.h | 32 +++++++++++++++++++++++ src/devices/cpu/mcs51/axc51-core_dasm.cpp | 42 +++++++++++++++++++++++++++++++ src/devices/cpu/mcs51/axc51-core_dasm.h | 31 +++++++++++++++++++++++ src/devices/cpu/mcs51/mcs51dasm.cpp | 13 +++++++--- src/devices/cpu/mcs51/mcs51dasm.h | 7 ++++-- src/mame/drivers/monon_color.cpp | 6 ++--- src/tools/unidasm.cpp | 2 ++ 9 files changed, 156 insertions(+), 9 deletions(-) create mode 100644 src/devices/cpu/mcs51/axc51-core.cpp create mode 100644 src/devices/cpu/mcs51/axc51-core.h create mode 100644 src/devices/cpu/mcs51/axc51-core_dasm.cpp create mode 100644 src/devices/cpu/mcs51/axc51-core_dasm.h diff --git a/scripts/src/cpu.lua b/scripts/src/cpu.lua index afb42dd1dd7..081269edf63 100644 --- a/scripts/src/cpu.lua +++ b/scripts/src/cpu.lua @@ -988,12 +988,16 @@ if (CPUS["MCS51"]~=null) then MAME_DIR .. "src/devices/cpu/mcs51/mcs51.cpp", MAME_DIR .. "src/devices/cpu/mcs51/mcs51.h", MAME_DIR .. "src/devices/cpu/mcs51/mcs51ops.hxx", + MAME_DIR .. "src/devices/cpu/mcs51/axc51-core.cpp", + MAME_DIR .. "src/devices/cpu/mcs51/axc51-core.h", } end if (CPUS["MCS51"]~=null or _OPTIONS["with-tools"]) then table.insert(disasm_files , MAME_DIR .. "src/devices/cpu/mcs51/mcs51dasm.cpp") table.insert(disasm_files , MAME_DIR .. "src/devices/cpu/mcs51/mcs51dasm.h") + table.insert(disasm_files , MAME_DIR .. "src/devices/cpu/mcs51/axc51-core_dasm.cpp") + table.insert(disasm_files , MAME_DIR .. "src/devices/cpu/mcs51/axc51-core_dasm.h") end -------------------------------------------------- diff --git a/src/devices/cpu/mcs51/axc51-core.cpp b/src/devices/cpu/mcs51/axc51-core.cpp new file mode 100644 index 00000000000..a2c1790e3f7 --- /dev/null +++ b/src/devices/cpu/mcs51/axc51-core.cpp @@ -0,0 +1,28 @@ +// license:BSD-3-Clause +// copyright-holders:David Haywood +/***************************************************************************** + + AXC51-CORE (AppoTech Inc.) + + used in + + AX208 SoC + + *****************************************************************************/ + +#include "emu.h" +#include "debugger.h" +#include "axc51-core.h" +#include "axc51-core_dasm.h" + +DEFINE_DEVICE_TYPE(AX208, ax208_cpu_device, "ax208", "AppoTech AX208 (AXC51-CORE)") + +ax208_cpu_device::ax208_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : mcs51_cpu_device(mconfig, AX208, tag, owner, clock, 0, 7) +{ +} + +std::unique_ptr ax208_cpu_device::create_disassembler() +{ + return std::make_unique(); +} diff --git a/src/devices/cpu/mcs51/axc51-core.h b/src/devices/cpu/mcs51/axc51-core.h new file mode 100644 index 00000000000..3d2429bb55a --- /dev/null +++ b/src/devices/cpu/mcs51/axc51-core.h @@ -0,0 +1,32 @@ +// license:BSD-3-Clause +// copyright-holders:David Haywood +/***************************************************************************** + + AXC51-CORE (AppoTech Inc.) + + used in + + AX208 SoC + + *****************************************************************************/ + +#ifndef MAME_CPU_MCS51_AXC51_CORE_H +#define MAME_CPU_MCS51_AXC51_CORE_H + +#pragma once + +#include "mcs51.h" + +DECLARE_DEVICE_TYPE(AX208, ax208_cpu_device) + +class ax208_cpu_device : public mcs51_cpu_device +{ +public: + // construction/destruction + ax208_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + +protected: + virtual std::unique_ptr create_disassembler() override; +}; + +#endif // MAME_CPU_MCS51_AXC51_CORE_H diff --git a/src/devices/cpu/mcs51/axc51-core_dasm.cpp b/src/devices/cpu/mcs51/axc51-core_dasm.cpp new file mode 100644 index 00000000000..dd9677965bc --- /dev/null +++ b/src/devices/cpu/mcs51/axc51-core_dasm.cpp @@ -0,0 +1,42 @@ +// license:BSD-3-Clause +// copyright-holders:David Haywood +/***************************************************************************** + + AXC51-CORE (AppoTech Inc.) + + used in + + AX208 SoC + + *****************************************************************************/ + +#include "emu.h" +#include "axc51-core_dasm.h" + +axc51core_disassembler::axc51core_disassembler() : mcs51_disassembler(default_names) +{ +} + + +offs_t axc51core_disassembler::disassemble_op(std::ostream &stream, unsigned PC, offs_t pc, const data_buffer &opcodes, const data_buffer ¶ms, uint8_t op) +{ + uint32_t flags = 0; + uint8_t prm = 0; + + switch( op ) + { + // unknown, probably the 16-bit extended ocpodes, see page 14 of AX208-SP-101-EN manual, encodings not specified! + // note, the other AXC51-CORE based manuals don't seem to mention these, are they really AX208 specific? + case 0xa5: + prm = params.r8(PC++); + util::stream_format(stream, "unknown ax208 a5 $%02X", prm); + break; + + default: + return mcs51_disassembler::disassemble_op(stream, PC, pc, opcodes, params, op); + } + + return (PC - pc) | flags | SUPPORTED; +} + + diff --git a/src/devices/cpu/mcs51/axc51-core_dasm.h b/src/devices/cpu/mcs51/axc51-core_dasm.h new file mode 100644 index 00000000000..222d3c1a16a --- /dev/null +++ b/src/devices/cpu/mcs51/axc51-core_dasm.h @@ -0,0 +1,31 @@ +// license:BSD-3-Clause +// copyright-holders:David Haywood +/***************************************************************************** + + AXC51-CORE (AppoTech Inc.) + + used in + + AX208 SoC + + *****************************************************************************/ + +#ifndef MAME_CPU_MCS51_AXC51_CORE_DASM_H +#define MAME_CPU_MCS51_AXC51_CORE_DASM_H + +#pragma once + +#include "mcs51dasm.h" + +class axc51core_disassembler : public mcs51_disassembler +{ +public: + axc51core_disassembler(); + virtual ~axc51core_disassembler() = default; + +protected: + virtual offs_t disassemble_op(std::ostream &stream, unsigned PC, offs_t pc, const data_buffer &opcodes, const data_buffer ¶ms, uint8_t op) override; +}; + + +#endif // MAME_CPU_MCS51_AXC51_CORE_DASM_H diff --git a/src/devices/cpu/mcs51/mcs51dasm.cpp b/src/devices/cpu/mcs51/mcs51dasm.cpp index fce9b90208f..2b857f74307 100644 --- a/src/devices/cpu/mcs51/mcs51dasm.cpp +++ b/src/devices/cpu/mcs51/mcs51dasm.cpp @@ -293,16 +293,14 @@ std::string mcs51_disassembler::get_bit_address( uint8_t arg ) const } } -offs_t mcs51_disassembler::disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer ¶ms) +offs_t mcs51_disassembler::disassemble_op(std::ostream &stream, unsigned PC, offs_t pc, const data_buffer &opcodes, const data_buffer ¶ms, uint8_t op) { uint32_t flags = 0; - unsigned PC = pc; std::string sym, sym2; - uint8_t op, data; + uint8_t data; uint16_t addr; int8_t rel; - op = opcodes.r8(PC++); switch( op ) { //NOP @@ -1109,6 +1107,13 @@ offs_t mcs51_disassembler::disassemble(std::ostream &stream, offs_t pc, const da return (PC - pc) | flags | SUPPORTED; } +offs_t mcs51_disassembler::disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer ¶ms) +{ + unsigned PC = pc; + uint8_t op = opcodes.r8(PC++); + return disassemble_op(stream, PC, pc, opcodes, params, op); +} + i8051_disassembler::i8051_disassembler() : mcs51_disassembler(default_names) { } diff --git a/src/devices/cpu/mcs51/mcs51dasm.h b/src/devices/cpu/mcs51/mcs51dasm.h index e00c755bb33..9cf7702361f 100644 --- a/src/devices/cpu/mcs51/mcs51dasm.h +++ b/src/devices/cpu/mcs51/mcs51dasm.h @@ -63,11 +63,14 @@ public: 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: - std::unordered_map m_names; +protected: + virtual offs_t disassemble_op(std::ostream &stream, unsigned PC, offs_t pc, const data_buffer &opcodes, const data_buffer ¶ms, uint8_t op); std::string get_data_address( uint8_t arg ) const; std::string get_bit_address( uint8_t arg ) const; +private: + std::unordered_map m_names; + }; class i8051_disassembler : public mcs51_disassembler diff --git a/src/mame/drivers/monon_color.cpp b/src/mame/drivers/monon_color.cpp index 4e8b760fb09..de441dd1195 100644 --- a/src/mame/drivers/monon_color.cpp +++ b/src/mame/drivers/monon_color.cpp @@ -7,13 +7,13 @@ https://gbatemp.net/threads/the-monon-color-a-new-video-game-console-from-china.467788/ https://twitter.com/Splatoon2weird/status/1072182093206052864 - uses AX208 CPU (8051 @ 96Mhz with single cycle instructions + integrated video, jpeg decoder etc.) + uses AX208 CPU (custom 8051 @ 96Mhz with single cycle instructions, extended '16 bit' opcodes + integrated video, jpeg decoder etc.) https://docplayer.net/52724058-Ax208-product-specification.html ***************************************************************************/ #include "emu.h" -#include "cpu/mcs51/mcs51.h" +#include "cpu/mcs51/axc51-core.h" #include "emupal.h" #include "screen.h" #include "speaker.h" @@ -75,7 +75,7 @@ INPUT_PORTS_END MACHINE_CONFIG_START(monon_color_state::monon_color) /* basic machine hardware */ - MCFG_DEVICE_ADD("maincpu", I8051, 96000000) // AX208! (needs custom core) + MCFG_DEVICE_ADD("maincpu", AX208, 96000000) // (8051 / MCS51 derived) incomplete core! /* video hardware */ MCFG_SCREEN_ADD("screen", RASTER) diff --git a/src/tools/unidasm.cpp b/src/tools/unidasm.cpp index 23da7bb1669..e811991b872 100644 --- a/src/tools/unidasm.cpp +++ b/src/tools/unidasm.cpp @@ -87,6 +87,7 @@ using util::BIT; #include "cpu/mcs40/mcs40dasm.h" #include "cpu/mcs48/mcs48dsm.h" #include "cpu/mcs51/mcs51dasm.h" +#include "cpu/mcs51/axc51-core_dasm.h" #include "cpu/mcs96/i8x9xd.h" #include "cpu/mcs96/i8xc196d.h" #include "cpu/melps4/melps4d.h" @@ -315,6 +316,7 @@ static const dasm_table_entry dasm_table[] = { "arm7thumbb", be, 0, []() -> util::disasm_interface * { arm7_unidasm.t_flag = true; return new arm7_disassembler(&arm7_unidasm); } }, { "asap", le, 0, []() -> util::disasm_interface * { return new asap_disassembler; } }, { "avr8", le, 0, []() -> util::disasm_interface * { return new avr8_disassembler; } }, + { "axc51core", le, 0, []() -> util::disasm_interface * { return new axc51core_disassembler; } }, { "capricorn", le, 0, []() -> util::disasm_interface * { return new capricorn_disassembler; } }, { "ccpu", le, 0, []() -> util::disasm_interface * { return new ccpu_disassembler; } }, { "cdp1801", le, 0, []() -> util::disasm_interface * { return new cosmac_disassembler(cosmac_disassembler::TYPE_1801); } }, -- cgit v1.2.3