From fa74509843dbf4b4771c276b476b518a6147a78c Mon Sep 17 00:00:00 2001 From: hap Date: Tue, 9 May 2017 22:59:07 +0200 Subject: [PATCH] sm510d: get rid of half-broken param fetch (nw) --- src/devices/cpu/sm510/sm510.h | 4 ++-- src/devices/cpu/sm510/sm510d.cpp | 13 +++++++------ src/devices/cpu/sm510/sm590op.cpp | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/devices/cpu/sm510/sm510.h b/src/devices/cpu/sm510/sm510.h index bb0cd2de905..cfa1eab9661 100644 --- a/src/devices/cpu/sm510/sm510.h +++ b/src/devices/cpu/sm510/sm510.h @@ -148,7 +148,7 @@ protected: // device_disasm_interface overrides virtual u32 disasm_min_opcode_bytes() const override { return 1; } - virtual u32 disasm_max_opcode_bytes() const override { return 0x40; } // actually 2, but debugger doesn't like non-linear pc + virtual u32 disasm_max_opcode_bytes() const override { return 2; } address_space_config m_program_config; address_space_config m_data_config; @@ -164,7 +164,7 @@ protected: u16 m_op, m_prev_op; u8 m_param; int m_stack_levels; - u16 m_stack[2]; + u16 m_stack[4]; // max 4 int m_icount; u8 m_acc; diff --git a/src/devices/cpu/sm510/sm510d.cpp b/src/devices/cpu/sm510/sm510d.cpp index 4fe950ee29b..46b65ddcb0f 100644 --- a/src/devices/cpu/sm510/sm510d.cpp +++ b/src/devices/cpu/sm510/sm510d.cpp @@ -2,7 +2,7 @@ // copyright-holders:hap, Jonathan Gevaryahu /* - Sharp SM510/SM500 MCU family disassembler + Sharp SM5xx MCU family disassembler */ @@ -175,7 +175,6 @@ static offs_t sm510_common_disasm(const u8 *lut_mnemonic, const u8 *lut_extended // get raw opcode u8 op = oprom[0]; u8 instr = lut_mnemonic[op]; - s8 s_next_pc = ((pclen==6)?s_next_pc_6[pc & 0x3f]:s_next_pc_7[pc & 0x7f]); int len = 1; int bits = s_bits[instr]; @@ -183,9 +182,8 @@ static offs_t sm510_common_disasm(const u8 *lut_mnemonic, const u8 *lut_extended u16 param = mask; if (bits >= 8) { - // note: disasm view shows correct parameter, but raw view does not - // note2: oprom array negative index doesn't work either :( - param = oprom[s_next_pc]; + // note: doesn't work with lfsr pc + param = oprom[1]; len++; } @@ -218,7 +216,10 @@ static offs_t sm510_common_disasm(const u8 *lut_mnemonic, const u8 *lut_extended // show param offset if (bits >= 8) - util::stream_format(stream, " [$%03X]", pc + s_next_pc); + { + s8 next_pc_delta = ((pclen == 6) ? s_next_pc_6[pc & 0x3f] : s_next_pc_7[pc & 0x7f]); + util::stream_format(stream, " [$%03X]", pc + next_pc_delta); + } } return len | s_flags[instr] | DASMFLAG_SUPPORTED; diff --git a/src/devices/cpu/sm510/sm590op.cpp b/src/devices/cpu/sm510/sm590op.cpp index ec6a6657f60..3d116a436fd 100644 --- a/src/devices/cpu/sm510/sm590op.cpp +++ b/src/devices/cpu/sm510/sm590op.cpp @@ -75,7 +75,7 @@ void sm590_device::op_debm() void sm590_device::op_tc() { // TC: skip next if carry - m_skip = m_c; + m_skip = bool(m_c); } void sm590_device::op_rta() @@ -108,7 +108,7 @@ void sm590_device::op_ads() { // ADS: add RAM to ACC, skip next on carry m_acc += ram_r(); - m_skip = (m_c == 1); + m_skip = bool(m_acc & 0x10); m_acc &= 0xf; }