diff options
author | 2016-07-03 13:43:19 -0400 | |
---|---|---|
committer | 2016-07-03 13:46:21 -0400 | |
commit | 90b08e2995d6857fa73aeea5fc61e23e1d3e74b4 (patch) | |
tree | 5315a48fdafb8d7afe2fe7aad71dbcc4f4688398 /src | |
parent | 5eebcb3fb9e1ec089248fb62eef0132187da5798 (diff) |
Consolidate disassemble functions (nw)
Diffstat (limited to 'src')
-rw-r--r-- | src/emu/debug/debugcmd.cpp | 11 | ||||
-rw-r--r-- | src/emu/debug/debugcpu.cpp | 44 | ||||
-rw-r--r-- | src/emu/debug/debugcpu.h | 3 | ||||
-rw-r--r-- | src/emu/debug/dvdisasm.cpp | 4 | ||||
-rw-r--r-- | src/emu/didisasm.cpp | 14 |
5 files changed, 33 insertions, 43 deletions
diff --git a/src/emu/debug/debugcmd.cpp b/src/emu/debug/debugcmd.cpp index 361f8f14fdf..b1a1f08a47a 100644 --- a/src/emu/debug/debugcmd.cpp +++ b/src/emu/debug/debugcmd.cpp @@ -2391,7 +2391,7 @@ void debugger_commands::execute_dasm(int ref, int params, const char *param[]) } /* disassemble the result */ - i += numbytes = space->device().debug()->disassemble(disasm, offset + i, opbuf, argbuf) & DASMFLAG_LENGTHMASK; + i += numbytes = dasmintf->disassemble(disasm, offset + i, opbuf, argbuf) & DASMFLAG_LENGTHMASK; } /* print the bytes */ @@ -2544,7 +2544,12 @@ void debugger_commands::execute_history(int ref, int params, const char *param[] /* loop over lines */ device_disasm_interface *dasmintf; - int maxbytes = space->device().interface(dasmintf) ? dasmintf->max_opcode_bytes() : 1; + if (!space->device().interface(dasmintf)) + { + m_console.printf("No disassembler available for %s\n", space->device().name()); + return; + } + int maxbytes = dasmintf->max_opcode_bytes(); for (int index = 0; index < (int) count; index++) { offs_t pc = debug->history_pc(-index); @@ -2559,7 +2564,7 @@ void debugger_commands::execute_history(int ref, int params, const char *param[] } char buffer[200]; - debug->disassemble(buffer, pc, opbuf, argbuf); + dasmintf->disassemble(buffer, pc, opbuf, argbuf); m_console.printf("%0*X: %s\n", space->logaddrchars(), pc, buffer); } diff --git a/src/emu/debug/debugcpu.cpp b/src/emu/debug/debugcpu.cpp index 94c586d8270..e76abd6fec6 100644 --- a/src/emu/debug/debugcpu.cpp +++ b/src/emu/debug/debugcpu.cpp @@ -1977,36 +1977,6 @@ void device_debug::set_instruction_hook(debug_instruction_hook_func hook) //------------------------------------------------- -// disassemble - disassemble a line at a given -// PC on a given device -//------------------------------------------------- - -offs_t device_debug::disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) const -{ - if (m_disasm == nullptr) - return 0; - - // if we have a disassembler, run it - offs_t result = m_disasm->disassemble(buffer, pc, oprom, opram, 0); - - // make sure we get good results - assert((result & DASMFLAG_LENGTHMASK) != 0); -#ifdef MAME_DEBUG - if (m_memory != nullptr) - { - address_space &space = m_memory->space(AS_PROGRAM); - int bytes = space.address_to_byte(result & DASMFLAG_LENGTHMASK); - assert(bytes >= m_disasm->min_opcode_bytes()); - assert(bytes <= m_disasm->max_opcode_bytes()); - (void) bytes; // appease compiler - } -#endif - - return result; -} - - -//------------------------------------------------- // ignore - ignore/observe a given device //------------------------------------------------- @@ -2653,10 +2623,14 @@ UINT32 device_debug::compute_opcode_crc32(offs_t pc) const argbuf[numbytes] = m_device.machine().debugger().cpu().read_opcode(space, pcbyte + numbytes, 1); } - // disassemble to our buffer - char diasmbuf[200]; - memset(diasmbuf, 0x00, 200); - UINT32 numbytes = disassemble(diasmbuf, pc, opbuf, argbuf) & DASMFLAG_LENGTHMASK; + UINT32 numbytes = maxbytes; + if (m_disasm != nullptr) + { + // disassemble to our buffer + char diasmbuf[200]; + memset(diasmbuf, 0x00, 200); + numbytes = m_disasm->disassemble(diasmbuf, pc, opbuf, argbuf) & DASMFLAG_LENGTHMASK; + } // return a CRC of the exact count of opcode bytes return core_crc32(0, opbuf, numbytes); @@ -3054,7 +3028,7 @@ UINT32 device_debug::dasm_wrapped(std::string &buffer, offs_t pc) // disassemble to our buffer char diasmbuf[200]; memset(diasmbuf, 0x00, 200); - UINT32 result = disassemble(diasmbuf, pc, opbuf, argbuf); + UINT32 result = m_disasm->disassemble(diasmbuf, pc, opbuf, argbuf); buffer.assign(diasmbuf); return result; } diff --git a/src/emu/debug/debugcpu.h b/src/emu/debug/debugcpu.h index 9915760b146..ffb390ea226 100644 --- a/src/emu/debug/debugcpu.h +++ b/src/emu/debug/debugcpu.h @@ -185,9 +185,6 @@ public: // hooks into our operations void set_instruction_hook(debug_instruction_hook_func hook); - // disassembly - offs_t disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) const; - // debugger focus void ignore(bool ignore = true); bool observing() const { return ((m_flags & DEBUG_FLAG_OBSERVING) != 0); } diff --git a/src/emu/debug/dvdisasm.cpp b/src/emu/debug/dvdisasm.cpp index a2aad9162cf..bd8207e1138 100644 --- a/src/emu/debug/dvdisasm.cpp +++ b/src/emu/debug/dvdisasm.cpp @@ -272,7 +272,7 @@ offs_t debug_view_disasm::find_pc_backwards(offs_t targetpc, int numinstrs) if (machine().debugger().cpu().translate(source.m_space, TRANSLATE_FETCH, &physpcbyte)) { char dasmbuffer[100]; - instlen = source.device()->debug()->disassemble(dasmbuffer, scanpc, &opbuf[1000 + scanpcbyte - targetpcbyte], &argbuf[1000 + scanpcbyte - targetpcbyte]) & DASMFLAG_LENGTHMASK; + instlen = source.m_disasmintf->disassemble(dasmbuffer, scanpc, &opbuf[1000 + scanpcbyte - targetpcbyte], &argbuf[1000 + scanpcbyte - targetpcbyte]) & DASMFLAG_LENGTHMASK; } // count this one @@ -407,7 +407,7 @@ bool debug_view_disasm::recompute(offs_t pc, int startline, int lines) } // disassemble the result - pc += numbytes = source.device()->debug()->disassemble(buffer, pc & source.m_space.logaddrmask(), opbuf, argbuf) & DASMFLAG_LENGTHMASK; + pc += numbytes = source.m_disasmintf->disassemble(buffer, pc & source.m_space.logaddrmask(), opbuf, argbuf) & DASMFLAG_LENGTHMASK; } else strcpy(buffer, "<unmapped>"); diff --git a/src/emu/didisasm.cpp b/src/emu/didisasm.cpp index 875b2bfef5e..9c10087d6c2 100644 --- a/src/emu/didisasm.cpp +++ b/src/emu/didisasm.cpp @@ -74,5 +74,19 @@ offs_t device_disasm_interface::disassemble(char *buffer, offs_t pc, const UINT8 if (result == 0) result = disasm_disassemble(buffer, pc, oprom, opram, options); + // make sure we get good results + assert((result & DASMFLAG_LENGTHMASK) != 0); +#ifdef MAME_DEBUG + device_memory_interface *memory; + if (device().interface(memory)) + { + address_space &space = memory->space(AS_PROGRAM); + int bytes = space.address_to_byte(result & DASMFLAG_LENGTHMASK); + assert(bytes >= min_opcode_bytes()); + assert(bytes <= max_opcode_bytes()); + (void) bytes; // appease compiler + } +#endif + return result; } |