From aeab957b528f94829572c132f728c6d84e6d1eb7 Mon Sep 17 00:00:00 2001 From: AJR Date: Fri, 13 Jul 2018 20:03:27 -0400 Subject: [PATCH] cosmac: Fix disassembly; very minor cleanup (nw) --- src/devices/cpu/cosmac/cosdasm.cpp | 2 +- src/devices/cpu/cosmac/cosmac.cpp | 18 ++++++++---------- src/devices/cpu/cosmac/cosmac.h | 6 +++--- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/devices/cpu/cosmac/cosdasm.cpp b/src/devices/cpu/cosmac/cosdasm.cpp index c818fd2c9a9..b540c96c9ec 100644 --- a/src/devices/cpu/cosmac/cosdasm.cpp +++ b/src/devices/cpu/cosmac/cosdasm.cpp @@ -35,7 +35,7 @@ offs_t cosmac_disassembler::short_branch(offs_t base_pc, offs_t &pc, const data_ offs_t cosmac_disassembler::long_branch(offs_t &pc, const data_buffer ¶ms) { - u16 res = params.r16(pc); + u16 res = params.r8(pc) << 8 | params.r8(pc + 1); pc += 2; return res; } diff --git a/src/devices/cpu/cosmac/cosmac.cpp b/src/devices/cpu/cosmac/cosmac.cpp index ca709bdb943..299968e6cd9 100644 --- a/src/devices/cpu/cosmac/cosmac.cpp +++ b/src/devices/cpu/cosmac/cosmac.cpp @@ -161,7 +161,7 @@ const cosmac_device::ophandler cdp1801_device::s_opcodetable[256] = &cdp1801_device::adi, &cdp1801_device::sdi, &cdp1801_device::und, &cdp1801_device::smi }; -cosmac_device::ophandler cdp1801_device::get_ophandler(uint8_t opcode) +cosmac_device::ophandler cdp1801_device::get_ophandler(uint8_t opcode) const { return s_opcodetable[opcode]; } @@ -249,7 +249,7 @@ const cosmac_device::ophandler cdp1802_device::s_opcodetable[256] = &cdp1802_device::adi, &cdp1802_device::sdi, &cdp1802_device::shl, &cdp1802_device::smi }; -cosmac_device::ophandler cdp1802_device::get_ophandler(uint8_t opcode) +cosmac_device::ophandler cdp1802_device::get_ophandler(uint8_t opcode) const { return s_opcodetable[opcode]; } @@ -828,8 +828,8 @@ inline void cosmac_device::set_q_flag(int state) inline void cosmac_device::fetch_instruction() { // instruction fetch - m_op = read_opcode(R[P]); - R[P]++; + offs_t addr = R[P]++; + m_op = read_opcode(addr); I = m_op >> 4; N = m_op & 0x0f; @@ -919,9 +919,8 @@ inline void cosmac_device::execute_instruction() inline void cosmac_device::dma_input() { - RAM_W(R[0], m_read_dma(R[0])); - - R[0]++; + offs_t addr = R[0]++; + RAM_W(addr, m_read_dma(addr)); m_icount -= CLOCKS_DMA; @@ -956,9 +955,8 @@ inline void cosmac_device::dma_input() inline void cosmac_device::dma_output() { - m_write_dma((offs_t)R[0], RAM_R(R[0])); - - R[0]++; + offs_t addr = R[0]++; + m_write_dma(addr, RAM_R(addr)); m_icount -= CLOCKS_DMA; diff --git a/src/devices/cpu/cosmac/cosmac.h b/src/devices/cpu/cosmac/cosmac.h index d5c98c8c992..33b9c9008bb 100644 --- a/src/devices/cpu/cosmac/cosmac.h +++ b/src/devices/cpu/cosmac/cosmac.h @@ -441,7 +441,7 @@ protected: // opcode/condition tables typedef void (cosmac_device::*ophandler)(); - virtual cosmac_device::ophandler get_ophandler(uint8_t opcode) = 0; + virtual cosmac_device::ophandler get_ophandler(uint8_t opcode) const = 0; }; @@ -457,7 +457,7 @@ protected: // device_disasm_interface overrides virtual std::unique_ptr create_disassembler() override; - virtual cosmac_device::ophandler get_ophandler(uint8_t opcode) override; + virtual cosmac_device::ophandler get_ophandler(uint8_t opcode) const override; static const ophandler s_opcodetable[256]; }; @@ -475,7 +475,7 @@ protected: // device_disasm_interface overrides virtual std::unique_ptr create_disassembler() override; - virtual cosmac_device::ophandler get_ophandler(uint8_t opcode) override; + virtual cosmac_device::ophandler get_ophandler(uint8_t opcode) const override; static const ophandler s_opcodetable[256]; };