From f954ec9fb39061224acf281beeaae2c50d9e92d8 Mon Sep 17 00:00:00 2001 From: AJR Date: Tue, 21 Jan 2020 17:19:12 -0500 Subject: gigatron: Hook up ROM and skeleton CPU device; add disassembler --- src/devices/cpu/gigatron/gigatron.cpp | 12 ++- src/devices/cpu/gigatron/gigatrondasm.cpp | 140 ++++++++++++++++++++++++++++-- src/devices/cpu/gigatron/gigatrondasm.h | 16 ++-- src/mame/drivers/gigatron.cpp | 22 +++-- src/tools/unidasm.cpp | 2 + 5 files changed, 171 insertions(+), 21 deletions(-) diff --git a/src/devices/cpu/gigatron/gigatron.cpp b/src/devices/cpu/gigatron/gigatron.cpp index 4a56be8ef41..e10da646c61 100644 --- a/src/devices/cpu/gigatron/gigatron.cpp +++ b/src/devices/cpu/gigatron/gigatron.cpp @@ -77,9 +77,13 @@ void gigatron_cpu_device::device_start() set_icountptr(m_icount); } -#if 0 +void gigatron_cpu_device::device_reset() +{ +} + void gigatron_cpu_device::execute_set_input(int irqline, int state) { +#if 0 switch(irqline) { case GTRON_INT_INTRM: // level-sensitive @@ -97,13 +101,13 @@ void gigatron_cpu_device::execute_set_input(int irqline, int state) m_intr_state = (ASSERT_LINE == state); break; } -} #endif +} gigatron_cpu_device::gigatron_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : cpu_device(mconfig, GTRON, tag, owner, clock) - , m_program_config("program", ENDIANNESS_BIG, 8, 32, -1) - , m_data_config("data", ENDIANNESS_BIG, 8, 32, 0) + , m_program_config("program", ENDIANNESS_BIG, 16, 14, -1) + , m_data_config("data", ENDIANNESS_BIG, 8, 15, 0) { } diff --git a/src/devices/cpu/gigatron/gigatrondasm.cpp b/src/devices/cpu/gigatron/gigatrondasm.cpp index 100f8d7e984..a139cea0e47 100644 --- a/src/devices/cpu/gigatron/gigatrondasm.cpp +++ b/src/devices/cpu/gigatron/gigatrondasm.cpp @@ -1,17 +1,147 @@ // license:BSD-3-Clause -// copyright-holders:Sterophonick +// copyright-holders:AJR +/*************************************************************************** -// Gigatron Disassembler + Gigatron disassembler + +***************************************************************************/ #include "emu.h" #include "gigatrondasm.h" +gigatron_disassembler::gigatron_disassembler() + : util::disasm_interface() +{ +} + +const char *const gigatron_disassembler::s_ops[7] = { + "ld", + "anda", + "ora", + "xora", + "adda", + "suba", + "st" +}; + +const char *const gigatron_disassembler::s_jumps[8] = { + "jmp", + "bgt", + "blt", + "bne", + "beq", + "bge", + "ble", + "bra" +}; + u32 gigatron_disassembler::opcode_alignment() const { - return 0; + return 1; } -offs_t gigatron_disassembler::disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer ¶ms) +offs_t gigatron_disassembler::disassemble(std::ostream &stream, offs_t pc, const gigatron_disassembler::data_buffer &opcodes, const gigatron_disassembler::data_buffer ¶ms) { - return 0; + u16 inst = opcodes.r16(pc); + + if (inst >= 0xe000) + { + // Jump instructions use special format + util::stream_format(stream, "%-6s", s_jumps[(inst & 0x1c00) >> 10]); + if ((inst & 0x1c00) == 0) + stream << "y,"; + + switch (inst & 0x0300) + { + case 0x0000: + if ((inst & 0x1c00) == 0) + util::stream_format(stream, "$%02x", inst & 0x00ff); + else + util::stream_format(stream, "$%04x", (pc & 0x3f00) | (inst & 0x00ff)); + break; + + case 0x0100: + util::stream_format(stream, "[$%02x]", inst & 0x00ff); + break; + + case 0x0200: + stream << "ac"; + break; + + case 0x0300: + stream << "in"; + break; + } + } + else if ((inst & 0xe300) == 0xc100) + { + // This was originally an undefined store mode + util::stream_format(stream, "%-6s$%02x", "ctrl", inst & 0x00ff); + } + else + { + util::stream_format(stream, "%-6s", s_ops[(inst & 0xe000) >> 13]); + + // Bus data + switch (inst & 0x0300) + { + case 0x0000: + util::stream_format(stream, "$%02x", inst & 0x00ff); + if (inst >= 0xc000) + stream << ","; + break; + + case 0x0100: + break; + + case 0x0200: + if (inst < 0xc000) + stream << "ac"; // implicit for store instruction + break; + + case 0x0300: + stream << "in"; + if (inst >= 0xc000) + stream << ","; + break; + } + + // RAM source or store destination + if (inst >= 0xc000 || (inst & 0x0300) == 0x0100) + { + switch (inst & 0x1c00) + { + case 0x0000: case 0x1000: case 0x1400: case 0x1800: + util::stream_format(stream, "[$%02x]", inst & 0x00ff); + break; + + case 0x0400: + stream << "[x]"; + break; + + case 0x0800: + util::stream_format(stream, "[y,$%02x]", inst & 0x00ff); + break; + + case 0x0c00: + stream << "[y,x]"; + break; + + case 0x1c00: + stream << "[y,x++]"; + break; + } + } + + // Non-accumulator destinations + if (BIT(inst, 12)) + { + if (!BIT(inst, 11)) + util::stream_format(stream, ",%c", "xy"[BIT(inst, 10)]); + else if (inst < 0xc000) + stream << ",out"; + } + } + + return 1; } diff --git a/src/devices/cpu/gigatron/gigatrondasm.h b/src/devices/cpu/gigatron/gigatrondasm.h index a1e590c0be8..1c8c976b41a 100644 --- a/src/devices/cpu/gigatron/gigatrondasm.h +++ b/src/devices/cpu/gigatron/gigatrondasm.h @@ -1,7 +1,5 @@ // license:BSD-3-Clause -// copyright-holders:Sterophonick - -// Gigatron disassembler +// copyright-holders:AJR #ifndef MAME_CPU_GIGATRON_GIGATRONDASM_H #define MAME_CPU_GIGATRON_GIGATRONDASM_H @@ -11,14 +9,18 @@ class gigatron_disassembler : public util::disasm_interface { public: - gigatron_disassembler() = default; - virtual ~gigatron_disassembler() = default; + // construction/destruction + gigatron_disassembler(); +protected: + // disassembler overrides 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: + // tables + static const char *const s_ops[7]; + static const char *const s_jumps[8]; }; -#endif - +#endif // MAME_CPU_GIGATRON_GIGATRONDASM_H diff --git a/src/mame/drivers/gigatron.cpp b/src/mame/drivers/gigatron.cpp index c14df7cbafd..25dcb6b9bca 100644 --- a/src/mame/drivers/gigatron.cpp +++ b/src/mame/drivers/gigatron.cpp @@ -8,8 +8,7 @@ ***************************************************************************/ #include "emu.h" -#include "cpu/m6502/m6502.h" -//#include "cpu/gigatron/gigatron.h" +#include "cpu/gigatron/gigatron.h" #include "machine/nvram.h" #include "speaker.h" @@ -27,23 +26,36 @@ public: void gigatron(machine_config &config); private: + void prog_map(address_map &map); + void data_map(address_map &map); required_device m_maincpu; }; +void gigatron_state::prog_map(address_map &map) +{ + map(0x0000, 0x3fff).rom().region("maincpu", 0); +} + +void gigatron_state::data_map(address_map &map) +{ +} + static INPUT_PORTS_START(gigatron) INPUT_PORTS_END void gigatron_state::gigatron(machine_config &config) { - M6502(config, m_maincpu, MAIN_CLOCK); // actually its own custom cpu but i cant get it to work - //GTRON(config, m_maincpu, MAIN_CLOCK); + GTRON(config, m_maincpu, MAIN_CLOCK); + m_maincpu->set_addrmap(AS_PROGRAM, &gigatron_state::prog_map); + m_maincpu->set_addrmap(AS_DATA, &gigatron_state::data_map); + SPEAKER(config, "mono").front_center(); } ROM_START( gigatron ) - ROM_REGION( 0x00000, "maincpu", 0 ) + ROM_REGION( 0x20000, "maincpu", 0 ) ROM_LOAD( "gigatron.rom", 0x0000, 0x20000, CRC(78995109) SHA1(2395fc48e64099836111f5aeca39ddbf4650ea4e) ) ROM_END diff --git a/src/tools/unidasm.cpp b/src/tools/unidasm.cpp index 08dad29b6d7..648669f93e3 100644 --- a/src/tools/unidasm.cpp +++ b/src/tools/unidasm.cpp @@ -52,6 +52,7 @@ using util::BIT; #include "cpu/f8/f8dasm.h" #include "cpu/fr/frdasm.h" #include "cpu/g65816/g65816ds.h" +#include "cpu/gigatron/gigatrondasm.h" #include "cpu/h6280/6280dasm.h" #include "cpu/h8/h8d.h" #include "cpu/h8/h8hd.h" @@ -370,6 +371,7 @@ static const dasm_table_entry dasm_table[] = { "f8", be, 0, []() -> util::disasm_interface * { return new f8_disassembler; } }, { "fr", be, 0, []() -> util::disasm_interface * { return new fr_disassembler; } }, { "g65816", le, 0, []() -> util::disasm_interface * { return new g65816_disassembler(&g65816_unidasm); } }, + { "gigatron", be, -1, []() -> util::disasm_interface * { return new gigatron_disassembler; } }, { "h6280", le, 0, []() -> util::disasm_interface * { return new h6280_disassembler; } }, { "h8", be, 0, []() -> util::disasm_interface * { return new h8_disassembler; } }, { "h8h", be, 0, []() -> util::disasm_interface * { return new h8h_disassembler; } }, -- cgit v1.2.3