diff options
Diffstat (limited to 'src/devices/cpu/tms1000')
-rw-r--r-- | src/devices/cpu/tms1000/tms0270.cpp | 4 | ||||
-rw-r--r-- | src/devices/cpu/tms1000/tms0980.cpp | 16 | ||||
-rw-r--r-- | src/devices/cpu/tms1000/tms0980.h | 4 | ||||
-rw-r--r-- | src/devices/cpu/tms1000/tms1000.cpp | 22 | ||||
-rw-r--r-- | src/devices/cpu/tms1000/tms1000.h | 17 | ||||
-rw-r--r-- | src/devices/cpu/tms1000/tms1100.cpp | 7 | ||||
-rw-r--r-- | src/devices/cpu/tms1000/tms1100.h | 2 | ||||
-rw-r--r-- | src/devices/cpu/tms1000/tms1400.cpp | 55 | ||||
-rw-r--r-- | src/devices/cpu/tms1000/tms1400.h | 6 | ||||
-rw-r--r-- | src/devices/cpu/tms1000/tms1k_base.cpp | 59 | ||||
-rw-r--r-- | src/devices/cpu/tms1000/tms1k_base.h | 47 | ||||
-rw-r--r-- | src/devices/cpu/tms1000/tms1k_dasm.cpp | 141 | ||||
-rw-r--r-- | src/devices/cpu/tms1000/tms1k_dasm.h | 100 | ||||
-rw-r--r-- | src/devices/cpu/tms1000/tp0320.cpp | 10 | ||||
-rw-r--r-- | src/devices/cpu/tms1000/tp0320.h | 2 |
15 files changed, 319 insertions, 173 deletions
diff --git a/src/devices/cpu/tms1000/tms0270.cpp b/src/devices/cpu/tms1000/tms0270.cpp index 3e66a4cf9bd..1db3bab8da2 100644 --- a/src/devices/cpu/tms1000/tms0270.cpp +++ b/src/devices/cpu/tms1000/tms0270.cpp @@ -23,7 +23,7 @@ DEFINE_DEVICE_TYPE(TMS0270, tms0270_cpu_device, "tms0270", "TMS0270") // 40-pin // internal memory maps static ADDRESS_MAP_START(program_11bit_9, AS_PROGRAM, 16, tms1k_base_device) - AM_RANGE(0x000, 0xfff) AM_ROM + AM_RANGE(0x000, 0x7ff) AM_ROM ADDRESS_MAP_END static ADDRESS_MAP_START(data_144x4, AS_DATA, 8, tms1k_base_device) @@ -34,7 +34,7 @@ ADDRESS_MAP_END // device definitions tms0270_cpu_device::tms0270_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) - : tms0980_cpu_device(mconfig, TMS0270, tag, owner, clock, 16 /* o pins */, 16 /* r pins */, 7 /* pc bits */, 9 /* byte width */, 4 /* x width */, 12 /* prg width */, ADDRESS_MAP_NAME(program_11bit_9), 8 /* data width */, ADDRESS_MAP_NAME(data_144x4)) + : tms0980_cpu_device(mconfig, TMS0270, tag, owner, clock, 16 /* o pins */, 16 /* r pins */, 7 /* pc bits */, 9 /* byte width */, 4 /* x width */, 11 /* prg width */, ADDRESS_MAP_NAME(program_11bit_9), 8 /* data width */, ADDRESS_MAP_NAME(data_144x4)) , m_read_ctl(*this) , m_write_ctl(*this) , m_write_pdc(*this) diff --git a/src/devices/cpu/tms1000/tms0980.cpp b/src/devices/cpu/tms1000/tms0980.cpp index 3059ff7b1d1..622d8ca5be4 100644 --- a/src/devices/cpu/tms1000/tms0980.cpp +++ b/src/devices/cpu/tms1000/tms0980.cpp @@ -8,6 +8,7 @@ #include "emu.h" #include "tms0980.h" +#include "tms1k_dasm.h" #include "debugger.h" // TMS0980 @@ -31,7 +32,7 @@ DEFINE_DEVICE_TYPE(TMS1980, tms1980_cpu_device, "tms1980", "TMS1980") // 28-pin // internal memory maps static ADDRESS_MAP_START(program_11bit_9, AS_PROGRAM, 16, tms1k_base_device) - AM_RANGE(0x000, 0xfff) AM_ROM + AM_RANGE(0x000, 0x7ff) AM_ROM ADDRESS_MAP_END static ADDRESS_MAP_START(data_144x4, AS_DATA, 8, tms1k_base_device) @@ -42,7 +43,7 @@ ADDRESS_MAP_END // device definitions tms0980_cpu_device::tms0980_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) - : tms0980_cpu_device(mconfig, TMS0980, tag, owner, clock, 8 /* o pins */, 9 /* r pins */, 7 /* pc bits */, 9 /* byte width */, 4 /* x width */, 12 /* prg width */, ADDRESS_MAP_NAME(program_11bit_9), 8 /* data width */, ADDRESS_MAP_NAME(data_144x4)) + : tms0980_cpu_device(mconfig, TMS0980, tag, owner, clock, 8 /* o pins */, 9 /* r pins */, 7 /* pc bits */, 9 /* byte width */, 4 /* x width */, 11 /* prg width */, ADDRESS_MAP_NAME(program_11bit_9), 8 /* data width */, ADDRESS_MAP_NAME(data_144x4)) { } @@ -52,7 +53,7 @@ tms0980_cpu_device::tms0980_cpu_device(const machine_config &mconfig, device_typ } tms1980_cpu_device::tms1980_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) - : tms0980_cpu_device(mconfig, TMS1980, tag, owner, clock, 7, 10, 7, 9, 4, 12, ADDRESS_MAP_NAME(program_11bit_9), 8, ADDRESS_MAP_NAME(data_144x4)) + : tms0980_cpu_device(mconfig, TMS1980, tag, owner, clock, 7, 10, 7, 9, 4, 11, ADDRESS_MAP_NAME(program_11bit_9), 8, ADDRESS_MAP_NAME(data_144x4)) { } @@ -84,10 +85,9 @@ MACHINE_CONFIG_END // disasm -offs_t tms0980_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const u8 *oprom, const u8 *opram, u32 options) +util::disasm_interface *tms0980_cpu_device::create_disassembler() { - extern CPU_DISASSEMBLE(tms0980); - return CPU_DISASSEMBLE_NAME(tms0980)(this, stream, pc, oprom, opram, options); + return new tms0980_disassembler; } @@ -173,8 +173,8 @@ u32 tms0980_cpu_device::read_micro() void tms0980_cpu_device::read_opcode() { - debugger_instruction_hook(this, m_rom_address << 1); - m_opcode = m_program->read_word(m_rom_address << 1) & 0x1ff; + debugger_instruction_hook(this, m_rom_address); + m_opcode = m_program->read_word(m_rom_address) & 0x1ff; m_c4 = BITSWAP8(m_opcode,7,6,5,4,0,1,2,3) & 0xf; // opcode operand is bitswapped for most opcodes m_fixed = m_fixed_decode[m_opcode]; diff --git a/src/devices/cpu/tms1000/tms0980.h b/src/devices/cpu/tms1000/tms0980.h index c258eadc12b..2a4fa810008 100644 --- a/src/devices/cpu/tms1000/tms0980.h +++ b/src/devices/cpu/tms1000/tms0980.h @@ -29,9 +29,7 @@ protected: virtual void device_add_mconfig(machine_config &config) override; - virtual u32 disasm_min_opcode_bytes() const override { return 2; } - virtual u32 disasm_max_opcode_bytes() const override { return 2; } - virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const u8 *oprom, const u8 *opram, u32 options) override; + virtual util::disasm_interface *create_disassembler() override; virtual u8 read_k_input() override; virtual void set_cki_bus() override; diff --git a/src/devices/cpu/tms1000/tms1000.cpp b/src/devices/cpu/tms1000/tms1000.cpp index 55ac2a01d8c..813f1da99f8 100644 --- a/src/devices/cpu/tms1000/tms1000.cpp +++ b/src/devices/cpu/tms1000/tms1000.cpp @@ -2,17 +2,19 @@ // copyright-holders:hap /* - TMS1000 family - TMS1000, TMS1070, TMS1040, TMS1200, TMS1700, TMS1730, + TMS1000 family - TMS1000, TMS1000C, TMS1070, TMS1040, TMS1200, TMS1700, TMS1730, and second source Motorola MC141000, MC141200. TODO: - add TMS1270 (10 O pins, how does that work?) - - add TMS1000C, TMS1200C (CMOS, and 3-level stack) + - add TMS1200C (has L input pins like TMS1600) + - add HALT input pin for TMS1000C */ #include "emu.h" #include "tms1000.h" +#include "tms1k_dasm.h" #include "debugger.h" // TMS1000 @@ -31,6 +33,10 @@ DEFINE_DEVICE_TYPE(TMS1200, tms1200_cpu_device, "tms1200", "TMS1200") // 40-p DEFINE_DEVICE_TYPE(TMS1700, tms1700_cpu_device, "tms1700", "TMS1700") // 28-pin DIP, RAM/ROM size halved, 9 R pins DEFINE_DEVICE_TYPE(TMS1730, tms1730_cpu_device, "tms1730", "TMS1730") // 20-pin DIP, same die as TMS1700, package has less pins: 6 R pins, 5 O pins (output PLA is still 8-bit, O1,O3,O5 unused) +// CMOS versions (3-level stack, HALT pin) +DEFINE_DEVICE_TYPE(TMS1000C, tms1000c_cpu_device, "tms1000c", "TMS1000C") // 28-pin SDIP, 10 R pins + +// 2nd source Motorola chips DEFINE_DEVICE_TYPE(MC141000, mc141000_cpu_device, "mc141000", "MC141000") // CMOS, pin-compatible with TMS1000(reverse polarity) DEFINE_DEVICE_TYPE(MC141200, mc141200_cpu_device, "mc141200", "MC141200") // CMOS, 40-pin DIP, 16 R pins @@ -90,6 +96,11 @@ tms1730_cpu_device::tms1730_cpu_device(const machine_config &mconfig, const char { } +tms1000c_cpu_device::tms1000c_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) + : tms1000_cpu_device(mconfig, TMS1000C, tag, owner, clock, 8, 10, 6, 8, 2, 10, ADDRESS_MAP_NAME(program_10bit_8), 6, ADDRESS_MAP_NAME(data_64x4)) +{ +} + mc141000_cpu_device::mc141000_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : tms1000_cpu_device(mconfig, MC141000, tag, owner, clock, 8, 11, 6, 8, 2, 10, ADDRESS_MAP_NAME(program_10bit_8), 6, ADDRESS_MAP_NAME(data_64x4)) { @@ -102,7 +113,7 @@ mc141200_cpu_device::mc141200_cpu_device(const machine_config &mconfig, const ch // machine configs - MACHINE_CONFIG_MEMBER(tms1000_cpu_device::device_add_mconfig) +MACHINE_CONFIG_MEMBER(tms1000_cpu_device::device_add_mconfig) // microinstructions PLA, output PLA MCFG_PLA_ADD("mpla", 8, 16, 30) @@ -112,10 +123,9 @@ mc141200_cpu_device::mc141200_cpu_device(const machine_config &mconfig, const ch MACHINE_CONFIG_END // disasm -offs_t tms1000_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const u8 *oprom, const u8 *opram, u32 options) +util::disasm_interface *tms1000_cpu_device::create_disassembler() { - extern CPU_DISASSEMBLE(tms1000); - return CPU_DISASSEMBLE_NAME(tms1000)(this, stream, pc, oprom, opram, options); + return new tms1000_disassembler; } diff --git a/src/devices/cpu/tms1000/tms1000.h b/src/devices/cpu/tms1000/tms1000.h index ae85b7ed579..9e969dfc356 100644 --- a/src/devices/cpu/tms1000/tms1000.h +++ b/src/devices/cpu/tms1000/tms1000.h @@ -26,8 +26,7 @@ protected: virtual void device_reset() override; virtual void device_add_mconfig(machine_config &config) override; - - virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const u8 *oprom, const u8 *opram, u32 options) override; + virtual util::disasm_interface *create_disassembler() override; }; class tms1070_cpu_device : public tms1000_cpu_device @@ -63,6 +62,19 @@ public: }; +class tms1000c_cpu_device : public tms1000_cpu_device +{ +public: + tms1000c_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); + +protected: + // overrides + virtual void op_br() override { op_br3(); } // 3-level stack + virtual void op_call() override { op_call3(); } // " + virtual void op_retn() override { op_retn3(); } // " +}; + + class mc141000_cpu_device : public tms1000_cpu_device { public: @@ -77,6 +89,7 @@ public: DECLARE_DEVICE_TYPE(TMS1000, tms1000_cpu_device) +DECLARE_DEVICE_TYPE(TMS1000C, tms1000c_cpu_device) DECLARE_DEVICE_TYPE(TMS1070, tms1070_cpu_device) DECLARE_DEVICE_TYPE(TMS1040, tms1040_cpu_device) DECLARE_DEVICE_TYPE(TMS1200, tms1200_cpu_device) diff --git a/src/devices/cpu/tms1000/tms1100.cpp b/src/devices/cpu/tms1000/tms1100.cpp index a67f1261512..70c38bc72c1 100644 --- a/src/devices/cpu/tms1000/tms1100.cpp +++ b/src/devices/cpu/tms1000/tms1100.cpp @@ -8,6 +8,7 @@ #include "emu.h" #include "tms1100.h" +#include "tms1k_dasm.h" #include "debugger.h" // TMS1100 is nearly the same as TMS1000, some different opcodes, and with double the RAM and ROM @@ -55,13 +56,11 @@ tms1370_cpu_device::tms1370_cpu_device(const machine_config &mconfig, const char // disasm -offs_t tms1100_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const u8 *oprom, const u8 *opram, u32 options) +util::disasm_interface *tms1100_cpu_device::create_disassembler() { - extern CPU_DISASSEMBLE(tms1100); - return CPU_DISASSEMBLE_NAME(tms1100)(this, stream, pc, oprom, opram, options); + return new tms1100_disassembler; } - // device_reset void tms1100_cpu_device::device_reset() { diff --git a/src/devices/cpu/tms1000/tms1100.h b/src/devices/cpu/tms1000/tms1100.h index 26a3ffbc578..86a0028a3aa 100644 --- a/src/devices/cpu/tms1000/tms1100.h +++ b/src/devices/cpu/tms1000/tms1100.h @@ -25,7 +25,7 @@ protected: // overrides virtual void device_reset() override; - virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const u8 *oprom, const u8 *opram, u32 options) override; + virtual util::disasm_interface *create_disassembler() override; virtual void op_setr() override; virtual void op_rstr() override; diff --git a/src/devices/cpu/tms1000/tms1400.cpp b/src/devices/cpu/tms1000/tms1400.cpp index 470136a16e5..4c392ec7599 100644 --- a/src/devices/cpu/tms1000/tms1400.cpp +++ b/src/devices/cpu/tms1000/tms1400.cpp @@ -88,58 +88,3 @@ void tms1400_cpu_device::device_reset() // small differences in 00-3f area m_fixed_decode[0x0b] = F_TPC; } - - -// opcode deviations -void tms1400_cpu_device::op_br() -{ - // BR/BL: conditional branch - if (m_status) - { - m_pa = m_pb; // don't care about clatch - m_ca = m_cb; - m_pc = m_opcode & m_pc_mask; - } -} - -void tms1400_cpu_device::op_call() -{ - // CALL/CALLL: conditional call - if (m_status) - { - // 3-level stack, mask clatch 3 bits (no need to mask others) - m_clatch = (m_clatch << 1 | 1) & 7; - - m_sr = m_sr << m_pc_bits | m_pc; - m_pc = m_opcode & m_pc_mask; - - m_ps = m_ps << 4 | m_pa; - m_pa = m_pb; - - m_cs = m_cs << 2 | m_ca; - m_ca = m_cb; - } - else - { - m_pb = m_pa; - m_cb = m_ca; - } -} - -void tms1400_cpu_device::op_retn() -{ - // RETN: return from subroutine - if (m_clatch & 1) - { - m_clatch >>= 1; - - m_pc = m_sr & m_pc_mask; - m_sr >>= m_pc_bits; - - m_pa = m_pb = m_ps & 0xf; - m_ps >>= 4; - - m_ca = m_cb = m_cs & 3; - m_cs >>= 2; - } -} diff --git a/src/devices/cpu/tms1000/tms1400.h b/src/devices/cpu/tms1000/tms1400.h index 59462360457..e6213f028fc 100644 --- a/src/devices/cpu/tms1000/tms1400.h +++ b/src/devices/cpu/tms1000/tms1400.h @@ -26,9 +26,9 @@ protected: virtual void device_reset() override; virtual void device_add_mconfig(machine_config &config) override; - virtual void op_br() override; - virtual void op_call() override; - virtual void op_retn() override; + virtual void op_br() override { op_br3(); } // 3-level stack + virtual void op_call() override { op_call3(); } // " + virtual void op_retn() override { op_retn3(); } // " virtual void op_setr() override { tms1k_base_device::op_setr(); } // no anomaly with MSB of X register virtual void op_rstr() override { tms1k_base_device::op_rstr(); } // " diff --git a/src/devices/cpu/tms1000/tms1k_base.cpp b/src/devices/cpu/tms1000/tms1k_base.cpp index 985784570e8..eb389fc6bc9 100644 --- a/src/devices/cpu/tms1000/tms1k_base.cpp +++ b/src/devices/cpu/tms1000/tms1k_base.cpp @@ -5,7 +5,6 @@ TMS1000 family - base/shared TODO: - - fix debugger disasm view - INIT pin @@ -72,7 +71,7 @@ unknown cycle: CME, SSE, SSS tms1k_base_device::tms1k_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 o_pins, u8 r_pins, u8 pc_bits, u8 byte_bits, u8 x_bits, int prgwidth, address_map_constructor program, int datawidth, address_map_constructor data) : cpu_device(mconfig, type, tag, owner, clock) - , m_program_config("program", ENDIANNESS_BIG, byte_bits > 8 ? 16 : 8, prgwidth, 0, program) + , m_program_config("program", ENDIANNESS_BIG, byte_bits > 8 ? 16 : 8, prgwidth, byte_bits > 8 ? -1 : 0, program) , m_data_config("data", ENDIANNESS_BIG, 8, datawidth, 0, data) , m_mpla(*this, "mpla") , m_ipla(*this, "ipla") @@ -405,6 +404,62 @@ void tms1k_base_device::op_retn() } +// TMS1400/TMS1000C 3-level stack version + +void tms1k_base_device::op_br3() +{ + // BR/BL: conditional branch + if (m_status) + { + m_pa = m_pb; // don't care about clatch + m_ca = m_cb; + m_pc = m_opcode & m_pc_mask; + } +} + +void tms1k_base_device::op_call3() +{ + // CALL/CALLL: conditional call + if (m_status) + { + // mask clatch 3 bits (no need to mask others) + m_clatch = (m_clatch << 1 | 1) & 7; + + m_sr = m_sr << m_pc_bits | m_pc; + m_pc = m_opcode & m_pc_mask; + + m_ps = m_ps << 4 | m_pa; + m_pa = m_pb; + + m_cs = m_cs << 2 | m_ca; + m_ca = m_cb; + } + else + { + m_pb = m_pa; + m_cb = m_ca; + } +} + +void tms1k_base_device::op_retn3() +{ + // RETN: return from subroutine + if (m_clatch & 1) + { + m_clatch >>= 1; + + m_pc = m_sr & m_pc_mask; + m_sr >>= m_pc_bits; + + m_pa = m_pb = m_ps & 0xf; + m_ps >>= 4; + + m_ca = m_cb = m_cs & 3; + m_cs >>= 2; + } +} + + // handle other: // TMS1000/common diff --git a/src/devices/cpu/tms1000/tms1k_base.h b/src/devices/cpu/tms1000/tms1k_base.h index b8cd7e2a589..7ddff2bb68f 100644 --- a/src/devices/cpu/tms1000/tms1k_base.h +++ b/src/devices/cpu/tms1000/tms1k_base.h @@ -93,6 +93,26 @@ public: u8 debug_peek_o_index() { return m_o_index; } // get output PLA index, for debugging (don't use in emulation) +protected: + // construction/destruction + tms1k_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 o_pins, u8 r_pins, u8 pc_bits, u8 byte_bits, u8 x_bits, int prgwidth, address_map_constructor program, int datawidth, address_map_constructor data); + + // device-level overrides + virtual void device_start() override; + virtual void device_reset() override; + + // device_execute_interface overrides + virtual u32 execute_min_cycles() const override { return 1; } + virtual u32 execute_max_cycles() const override { return 6; } + virtual u32 execute_input_lines() const override { return 1; } + virtual void execute_run() override; + + // device_memory_interface overrides + virtual space_config_vector memory_space_config() const override; + + // device_state_interface overrides + virtual void state_string_export(const device_state_entry &entry, std::string &str) const override; + // microinstructions enum { @@ -151,30 +171,6 @@ public: F_XDA = (1<<20) }; -protected: - // construction/destruction - tms1k_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 o_pins, u8 r_pins, u8 pc_bits, u8 byte_bits, u8 x_bits, int prgwidth, address_map_constructor program, int datawidth, address_map_constructor data); - - // device-level overrides - virtual void device_start() override; - virtual void device_reset() override; - - // device_execute_interface overrides - virtual u32 execute_min_cycles() const override { return 1; } - virtual u32 execute_max_cycles() const override { return 6; } - virtual u32 execute_input_lines() const override { return 1; } - virtual void execute_run() override; - - // device_memory_interface overrides - virtual space_config_vector memory_space_config() const override; - - // device_disasm_interface overrides - virtual u32 disasm_min_opcode_bytes() const override { return 1; } - virtual u32 disasm_max_opcode_bytes() const override { return 1; } - - // device_state_interface overrides - virtual void state_string_export(const device_state_entry &entry, std::string &str) const override; - void next_pc(); virtual void write_o_output(u8 index); @@ -186,6 +182,9 @@ protected: virtual void op_br(); virtual void op_call(); virtual void op_retn(); + virtual void op_br3(); + virtual void op_call3(); + virtual void op_retn3(); virtual void op_sbit(); virtual void op_rbit(); diff --git a/src/devices/cpu/tms1000/tms1k_dasm.cpp b/src/devices/cpu/tms1000/tms1k_dasm.cpp index f0afd660470..1cd05a57ab3 100644 --- a/src/devices/cpu/tms1000/tms1k_dasm.cpp +++ b/src/devices/cpu/tms1000/tms1k_dasm.cpp @@ -7,23 +7,9 @@ */ #include "emu.h" -#include "debugger.h" -#include "tms1k_base.h" +#include "tms1k_dasm.h" - -enum e_mnemonics -{ - zILL = 0, - zA10AAC, zA6AAC, zA8AAC, zAC1AC, zACACC, zACNAA, zALEC, zALEM, zAMAAC, zBRANCH, zCALL, zCCLA, - zCLA, zCLO, zCOMC, zCOMX, zCOMX8, zCPAIZ, zCTMDYN, zDAN, zDMAN, zDMEA, zDNAA, - zDYN, zIA, zIMAC, zIYC, zKNEZ, zLDP, zLDX2, zLDX3, zLDX4, zMNEA, zMNEZ, - zNDMEA, zOFF, zRBIT, zREAC, zRETN, zRSTR, zSAL, zSAMAN, zSBIT, - zSBL, zSEAC, zSETR, zTAM, zTAMACS, zTAMDYN, zTAMIY, zTAMIYC, zTAMZA, - zTAY, zTBIT, zTCMIY, zTCY, zTDO, zTKA, zTKM, zTMA, - zTMY, zTYA, zXDA, zXMA, zYMCY, zYNEA, zYNEC -}; - -static const char *const s_mnemonic[] = +const char *const tms1000_base_disassembler::s_mnemonic[] = { "?", "A10AAC", "A6AAC", "A8AAC", "AC1AC", "ACACC", "ACNAA", "ALEC", "ALEM", "AMAAC", "BRANCH", "CALL", "CCLA", @@ -35,29 +21,19 @@ static const char *const s_mnemonic[] = "TMY", "TYA", "XDA", "XMA", "YMCY", "YNEA", "YNEC" }; - -#define _OVER DASMFLAG_STEP_OVER -#define _OUT DASMFLAG_STEP_OUT - -static const u32 s_flags[] = +const u32 tms1000_base_disassembler::s_flags[] = { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _OVER, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, STEP_OVER, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, _OUT, 0, 0, 0, 0, + 0, 0, 0, 0, STEP_OUT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - -enum e_addressing -{ - zB0 = 0, zI2, zI3, zI4, zB7 -}; - -static const u8 s_addressing[] = +const u8 tms1000_base_disassembler::s_addressing[] = { zB0, zB0, zB0, zB0, zI4, zI4, zI4, zI4, zB0, zB0, zB7, zB7, zB0, @@ -73,7 +49,7 @@ static const u8 s_addressing[] = // opcode luts -static const u8 tms1000_mnemonic[256] = +const u8 tms1000_disassembler::tms1000_mnemonic[256] = { /* 0x00 */ zCOMX, zA8AAC, zYNEA, zTAM, zTAMZA, zA10AAC, zA6AAC, zDAN, zTKA, zKNEZ, zTDO, zCLO, zRSTR, zSETR, zIA, zRETN, // 0 @@ -97,7 +73,7 @@ static const u8 tms1000_mnemonic[256] = }; -static const u8 tms1100_mnemonic[256] = +const u8 tms1100_disassembler::tms1100_mnemonic[256] = { /* 0x00 */ zMNEA, zALEM, zYNEA, zXMA, zDYN, zIYC, zAMAAC, zDMAN, zTKA, zCOMX, zTDO, zCOMC, zRSTR, zSETR, zKNEZ, zRETN, // 0 @@ -121,7 +97,7 @@ static const u8 tms1100_mnemonic[256] = }; -static const u8 tms0980_mnemonic[512] = +const u8 tms0980_disassembler::tms0980_mnemonic[512] = { /* 0x000 */ zCOMX, zALEM, zYNEA, zXMA, zDYN, zIYC, zCLA, zDMAN, zTKA, zMNEA, zTKM, 0, 0, zSETR, zKNEZ, 0, // 0 @@ -163,7 +139,7 @@ static const u8 tms0980_mnemonic[512] = }; -static const u8 tp0320_mnemonic[512] = +const u8 tp0320_disassembler::tp0320_mnemonic[512] = { /* 0x000 */ 0, zALEM, zYNEA, zXMA, zDYN, zIYC, zCLA, zDMAN, zTKA, zMNEA, zTKM, 0, 0, zSETR, zKNEZ, 0, // 0 @@ -208,31 +184,27 @@ static const u8 tp0320_mnemonic[512] = // disasm -static const u8 i2_value[4] = +const u8 tms1000_base_disassembler::i2_value[4] = { 0, 2, 1, 3 }; -static const u8 i3_value[8] = +const u8 tms1000_base_disassembler::i3_value[8] = { 0, 4, 2, 6, 1, 5, 3, 7 }; -static const u8 i4_value[16] = +const u8 tms1000_base_disassembler::i4_value[16] = { 0x0, 0x8, 0x4, 0xc, 0x2, 0xa, 0x6, 0xe, 0x1, 0x9, 0x5, 0xd, 0x3, 0xb, 0x7, 0xf }; -static offs_t tms1k_dasm(std::ostream &stream, const u8 *oprom, const u8 *lut_mnemonic, u16 opcode_mask) +offs_t tms1000_base_disassembler::disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer ¶ms) { - // get current opcode - int pos = 0; - u16 op = oprom[pos++]; - if (opcode_mask & 0x100) - op = (op << 8 | oprom[pos++]) & 0x1ff; + u16 op = m_opcode_9bits ? opcodes.r16(pc) & 0x1ff : opcodes.r8(pc); // convert to mnemonic/param - u16 instr = lut_mnemonic[op]; + u16 instr = m_lut_mnemonic[op]; util::stream_format(stream, "%-8s ", s_mnemonic[instr]); switch( s_addressing[instr] ) @@ -247,35 +219,90 @@ static offs_t tms1k_dasm(std::ostream &stream, const u8 *oprom, const u8 *lut_mn util::stream_format(stream, "%d", i4_value[op & 0x0f]); break; case zB7: - if (opcode_mask & 0x100) - util::stream_format(stream, "$%02X", op << 1 & 0xfe); - else - util::stream_format(stream, "$%02X", op & 0x3f); + util::stream_format(stream, "$%02X", op & (m_opcode_9bits ? 0x7f : 0x3f)); break; default: break; } - return pos | s_flags[instr] | DASMFLAG_SUPPORTED; + return 1 | s_flags[instr] | SUPPORTED; } +tms1000_disassembler::tms1000_disassembler() : tms1000_base_disassembler(tms1000_mnemonic, false, 6) +{ +} -CPU_DISASSEMBLE(tms1000) +tms1100_disassembler::tms1100_disassembler() : tms1000_base_disassembler(tms1100_mnemonic, false, 6) { - return tms1k_dasm(stream, oprom, tms1000_mnemonic, 0xff); } -CPU_DISASSEMBLE(tms1100) +tms0980_disassembler::tms0980_disassembler() : tms1000_base_disassembler(tms0980_mnemonic, true, 7) { - return tms1k_dasm(stream, oprom, tms1100_mnemonic, 0xff); } -CPU_DISASSEMBLE(tms0980) +tp0320_disassembler::tp0320_disassembler() : tms1000_base_disassembler(tp0320_mnemonic, true, 7) { - return tms1k_dasm(stream, oprom, tms0980_mnemonic, 0x1ff); } -CPU_DISASSEMBLE(tp0320) +tms1000_base_disassembler::tms1000_base_disassembler(const u8 *lut_mnemonic, bool opcode_9bits, int pc_bits) : m_lut_mnemonic(lut_mnemonic), m_opcode_9bits(opcode_9bits), m_pc_bits(pc_bits) { - return tms1k_dasm(stream, oprom, tp0320_mnemonic, 0x1ff); } + +offs_t tms1000_base_disassembler::pc_linear_to_real(offs_t pc) const +{ + switch(m_pc_bits) { + case 6: { + static const u8 l2r6[64] = { + 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x3e, 0x3d, 0x3b, 0x37, 0x2f, 0x1e, 0x3c, 0x39, 0x33, + 0x27, 0x0e, 0x1d, 0x3a, 0x35, 0x2b, 0x16, 0x2c, 0x18, 0x30, 0x21, 0x02, 0x05, 0x0b, 0x17, 0x2e, + 0x1c, 0x38, 0x31, 0x23, 0x06, 0x0d, 0x1b, 0x36, 0x2d, 0x1a, 0x34, 0x29, 0x12, 0x24, 0x08, 0x11, + 0x22, 0x04, 0x09, 0x13, 0x26, 0x0c, 0x19, 0x32, 0x25, 0x0a, 0x15, 0x2a, 0x14, 0x28, 0x10, 0x20, + }; + return (pc & ~0x3f) | l2r6[pc & 0x3f]; + } + case 7: { + static const u8 l2r7[128] = { + 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0x7e, 0x7d, 0x7b, 0x77, 0x6f, 0x5f, 0x3e, 0x7c, + 0x79, 0x73, 0x67, 0x4f, 0x1e, 0x3d, 0x7a, 0x75, 0x6b, 0x57, 0x2e, 0x5c, 0x38, 0x70, 0x61, 0x43, + 0x06, 0x0d, 0x1b, 0x37, 0x6e, 0x5d, 0x3a, 0x74, 0x69, 0x53, 0x26, 0x4c, 0x18, 0x31, 0x62, 0x45, + 0x0a, 0x15, 0x2b, 0x56, 0x2c, 0x58, 0x30, 0x60, 0x41, 0x02, 0x05, 0x0b, 0x17, 0x2f, 0x5e, 0x3c, + 0x78, 0x71, 0x63, 0x47, 0x0e, 0x1d, 0x3b, 0x76, 0x6d, 0x5b, 0x36, 0x6c, 0x59, 0x32, 0x64, 0x49, + 0x12, 0x25, 0x4a, 0x14, 0x29, 0x52, 0x24, 0x48, 0x10, 0x21, 0x42, 0x04, 0x09, 0x13, 0x27, 0x4e, + 0x1c, 0x39, 0x72, 0x65, 0x4b, 0x16, 0x2d, 0x5a, 0x34, 0x68, 0x51, 0x22, 0x44, 0x08, 0x11, 0x23, + 0x46, 0x0c, 0x19, 0x33, 0x66, 0x4d, 0x1a, 0x35, 0x6a, 0x55, 0x2a, 0x54, 0x28, 0x50, 0x20, 0x40, + }; + return (pc & ~0x7f) | l2r7[pc & 0x7f]; + } + } + return 0; +} + +offs_t tms1000_base_disassembler::pc_real_to_linear(offs_t pc) const +{ + switch(m_pc_bits) { + case 6: { + static const u8 r2l6[64] = { + 0x00, 0x01, 0x1b, 0x02, 0x31, 0x1c, 0x24, 0x03, 0x2e, 0x32, 0x39, 0x1d, 0x35, 0x25, 0x11, 0x04, + 0x3e, 0x2f, 0x2c, 0x33, 0x3c, 0x3a, 0x16, 0x1e, 0x18, 0x36, 0x29, 0x26, 0x20, 0x12, 0x0c, 0x05, + 0x3f, 0x1a, 0x30, 0x23, 0x2d, 0x38, 0x34, 0x10, 0x3d, 0x2b, 0x3b, 0x15, 0x17, 0x28, 0x1f, 0x0b, + 0x19, 0x22, 0x37, 0x0f, 0x2a, 0x14, 0x27, 0x0a, 0x21, 0x0e, 0x13, 0x09, 0x0d, 0x08, 0x07, 0x06, + }; + return (pc & ~0x3f) | r2l6[pc & 0x3f]; + } + case 7: { + static const u8 r2l7[128] = { + 0x00, 0x01, 0x39, 0x02, 0x5b, 0x3a, 0x20, 0x03, 0x6d, 0x5c, 0x30, 0x3b, 0x71, 0x21, 0x44, 0x04, + 0x58, 0x6e, 0x50, 0x5d, 0x53, 0x31, 0x65, 0x3c, 0x2c, 0x72, 0x76, 0x22, 0x60, 0x45, 0x14, 0x05, + 0x7e, 0x59, 0x6b, 0x6f, 0x56, 0x51, 0x2a, 0x5e, 0x7c, 0x54, 0x7a, 0x32, 0x34, 0x66, 0x1a, 0x3d, + 0x36, 0x2d, 0x4d, 0x73, 0x68, 0x77, 0x4a, 0x23, 0x1c, 0x61, 0x26, 0x46, 0x3f, 0x15, 0x0e, 0x06, + 0x7f, 0x38, 0x5a, 0x1f, 0x6c, 0x2f, 0x70, 0x43, 0x57, 0x4f, 0x52, 0x64, 0x2b, 0x75, 0x5f, 0x13, + 0x7d, 0x6a, 0x55, 0x29, 0x7b, 0x79, 0x33, 0x19, 0x35, 0x4c, 0x67, 0x49, 0x1b, 0x25, 0x3e, 0x0d, + 0x37, 0x1e, 0x2e, 0x42, 0x4e, 0x63, 0x74, 0x12, 0x69, 0x28, 0x78, 0x18, 0x4b, 0x48, 0x24, 0x0c, + 0x1d, 0x41, 0x62, 0x11, 0x27, 0x17, 0x47, 0x0b, 0x40, 0x10, 0x16, 0x0a, 0x0f, 0x09, 0x08, 0x07, + }; + return (pc & ~0x7f) | r2l7[pc & 0x7f]; + } + } + return 0; +} + diff --git a/src/devices/cpu/tms1000/tms1k_dasm.h b/src/devices/cpu/tms1000/tms1k_dasm.h new file mode 100644 index 00000000000..64e9e6f5082 --- /dev/null +++ b/src/devices/cpu/tms1000/tms1k_dasm.h @@ -0,0 +1,100 @@ +// license:BSD-3-Clause +// copyright-holders:Wilbert Pol, hap +/* + + TMS0980/TMS1000-family disassembler + +*/ + +#ifndef MAME_CPU_TMS1000_TMS1K_DASM_H +#define MAME_CPU_TMS1000_TMS1K_DASM_H + +#pragma once + +class tms1000_base_disassembler : public util::disasm_interface +{ +public: + tms1000_base_disassembler(const u8 *lut_mnemonic, bool opcode_9bits, int pc_bits); + virtual ~tms1000_base_disassembler() = default; + + virtual u32 opcode_alignment() const override { return 1; } + virtual u32 interface_flags() const override { return NONLINEAR_PC | PAGED; } + virtual u32 page_address_bits() const override { return m_pc_bits; } + virtual offs_t pc_linear_to_real(offs_t pc) const override; + virtual offs_t pc_real_to_linear(offs_t pc) const override; + virtual offs_t disassemble(std::ostream &stream, offs_t pc, const data_buffer &opcodes, const data_buffer ¶ms) override; + +protected: + enum e_mnemonics + { + zILL = 0, + zA10AAC, zA6AAC, zA8AAC, zAC1AC, zACACC, zACNAA, zALEC, zALEM, zAMAAC, zBRANCH, zCALL, zCCLA, + zCLA, zCLO, zCOMC, zCOMX, zCOMX8, zCPAIZ, zCTMDYN, zDAN, zDMAN, zDMEA, zDNAA, + zDYN, zIA, zIMAC, zIYC, zKNEZ, zLDP, zLDX2, zLDX3, zLDX4, zMNEA, zMNEZ, + zNDMEA, zOFF, zRBIT, zREAC, zRETN, zRSTR, zSAL, zSAMAN, zSBIT, + zSBL, zSEAC, zSETR, zTAM, zTAMACS, zTAMDYN, zTAMIY, zTAMIYC, zTAMZA, + zTAY, zTBIT, zTCMIY, zTCY, zTDO, zTKA, zTKM, zTMA, + zTMY, zTYA, zXDA, zXMA, zYMCY, zYNEA, zYNEC + }; + + enum e_addressing + { + zB0 = 0, zI2, zI3, zI4, zB7 + }; + + static const char *const s_mnemonic[]; + static const u32 s_flags[]; + static const u8 s_addressing[]; + static const u8 i2_value[4]; + static const u8 i3_value[8]; + static const u8 i4_value[16]; + + const u8 *m_lut_mnemonic; + bool m_opcode_9bits; + int m_pc_bits; +}; + +class tms1000_disassembler : public tms1000_base_disassembler +{ +public: + tms1000_disassembler(); + virtual ~tms1000_disassembler() = default; + +protected: + static const u8 tms1000_mnemonic[256]; +}; + +class tms1100_disassembler : public tms1000_base_disassembler +{ +public: + tms1100_disassembler(); + virtual ~tms1100_disassembler() = default; + + virtual u32 interface_flags() const override { return NONLINEAR_PC | PAGED2LEVEL; } + virtual u32 page2_address_bits() const override { return 4; } + +protected: + static const u8 tms1100_mnemonic[256]; +}; + +class tms0980_disassembler : public tms1000_base_disassembler +{ +public: + tms0980_disassembler(); + virtual ~tms0980_disassembler() = default; + +protected: + static const u8 tms0980_mnemonic[512]; +}; + +class tp0320_disassembler : public tms1000_base_disassembler +{ +public: + tp0320_disassembler(); + virtual ~tp0320_disassembler() = default; + +protected: + static const u8 tp0320_mnemonic[512]; +}; + +#endif diff --git a/src/devices/cpu/tms1000/tp0320.cpp b/src/devices/cpu/tms1000/tp0320.cpp index 02e961f6473..64ebdb3365a 100644 --- a/src/devices/cpu/tms1000/tp0320.cpp +++ b/src/devices/cpu/tms1000/tp0320.cpp @@ -11,6 +11,7 @@ #include "emu.h" #include "tp0320.h" +#include "tms1k_dasm.h" #include "debugger.h" // TP0320 is TI's first CMOS MCU with integrated LCD controller, the die is still very similar to TMS0980 @@ -27,7 +28,7 @@ DEFINE_DEVICE_TYPE(TP0320, tp0320_cpu_device, "tp0320", "TP0320") // 28-pin SDIP // internal memory maps static ADDRESS_MAP_START(program_11bit_9, AS_PROGRAM, 16, tms1k_base_device) - AM_RANGE(0x000, 0xfff) AM_ROM + AM_RANGE(0x000, 0x7ff) AM_ROM ADDRESS_MAP_END static ADDRESS_MAP_START(data_192x4, AS_DATA, 8, tms1k_base_device) @@ -38,7 +39,7 @@ ADDRESS_MAP_END // device definitions tp0320_cpu_device::tp0320_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) - : tms0980_cpu_device(mconfig, TP0320, tag, owner, clock, 7 /* o pins */, 10 /* r pins */, 7 /* pc bits */, 9 /* byte width */, 4 /* x width */, 12 /* prg width */, ADDRESS_MAP_NAME(program_11bit_9), 8 /* data width */, ADDRESS_MAP_NAME(data_192x4)) + : tms0980_cpu_device(mconfig, TP0320, tag, owner, clock, 7 /* o pins */, 10 /* r pins */, 7 /* pc bits */, 9 /* byte width */, 4 /* x width */, 11 /* prg width */, ADDRESS_MAP_NAME(program_11bit_9), 8 /* data width */, ADDRESS_MAP_NAME(data_192x4)) { } @@ -55,10 +56,9 @@ MACHINE_CONFIG_END // disasm -offs_t tp0320_cpu_device::disasm_disassemble(std::ostream &stream, offs_t pc, const u8 *oprom, const u8 *opram, u32 options) +util::disasm_interface *tp0320_cpu_device::create_disassembler() { - extern CPU_DISASSEMBLE(tp0320); - return CPU_DISASSEMBLE_NAME(tp0320)(this, stream, pc, oprom, opram, options); + return new tp0320_disassembler; } diff --git a/src/devices/cpu/tms1000/tp0320.h b/src/devices/cpu/tms1000/tp0320.h index e740ae83320..9b23155f1c4 100644 --- a/src/devices/cpu/tms1000/tp0320.h +++ b/src/devices/cpu/tms1000/tp0320.h @@ -26,7 +26,7 @@ protected: virtual u32 decode_fixed(u16 op) override { return 0; } // not yet virtual u32 decode_micro(u8 sel) override; virtual void device_reset() override; - virtual offs_t disasm_disassemble(std::ostream &stream, offs_t pc, const u8 *oprom, const u8 *opram, u32 options) override; + virtual util::disasm_interface *create_disassembler() override; virtual void device_add_mconfig(machine_config &config) override; }; |