From 274632f3040e77535b86c26c0df31ff0fa7fb75a Mon Sep 17 00:00:00 2001 From: Kingcom Date: Tue, 26 Nov 2013 11:38:01 +0100 Subject: [PATCH] Minor disassembly tweaks --- Core/Debugger/DisassemblyManager.cpp | 2 +- Windows/Debugger/CtrlDisAsmView.cpp | 11 +++++------ Windows/Debugger/CtrlDisAsmView.h | 11 ++++------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Core/Debugger/DisassemblyManager.cpp b/Core/Debugger/DisassemblyManager.cpp index f8a9818157..66586d6117 100644 --- a/Core/Debugger/DisassemblyManager.cpp +++ b/Core/Debugger/DisassemblyManager.cpp @@ -30,7 +30,7 @@ DebugInterface* DisassemblyManager::cpu; bool isInInterval(u32 start, u32 size, u32 value) { - return start <= value && value < start+size; + return start <= value && value <= (start+size-1); } void parseDisasm(const char* disasm, char* opcode, char* arguments, bool insertSymbols) diff --git a/Windows/Debugger/CtrlDisAsmView.cpp b/Windows/Debugger/CtrlDisAsmView.cpp index 8d9aee7fff..0f8d10d80d 100644 --- a/Windows/Debugger/CtrlDisAsmView.cpp +++ b/Windows/Debugger/CtrlDisAsmView.cpp @@ -167,7 +167,6 @@ CtrlDisAsmView::CtrlDisAsmView(HWND _wnd) boldfont = CreateFont(rowHeight-2,charWidth,0,0,FW_DEMIBOLD,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH, L"Lucida Console"); curAddress=0; - instructionSize=4; showHex=false; hasFocus = false; dontRedraw = false; @@ -655,11 +654,11 @@ void CtrlDisAsmView::onKeyDown(WPARAM wParam, LPARAM lParam) toggleBreakpoint(true); break; case VK_UP: - windowStart -= instructionSize; + scrollWindow(-1); scanFunctions(); break; case VK_DOWN: - windowStart += instructionSize; + scrollWindow(1); scanFunctions(); break; case VK_NEXT: @@ -819,10 +818,10 @@ void CtrlDisAsmView::onMouseDown(WPARAM wParam, LPARAM lParam, int button) void CtrlDisAsmView::copyInstructions(u32 startAddr, u32 endAddr, bool withDisasm) { - int count = (endAddr - startAddr) / instructionSize; - if (withDisasm == false) { + int instructionSize = debugger->getInstructionSize(0); + int count = (endAddr - startAddr) / instructionSize; int space = count * 32; char *temp = new char[space]; @@ -1153,7 +1152,7 @@ std::string CtrlDisAsmView::disassembleRange(u32 start, u32 size) // gather all branch targets without labels std::set branchAddresses; - for (u32 i = 0; i < size; i += instructionSize) + for (u32 i = 0; i < size; i += debugger->getInstructionSize(0)) { MIPSAnalyst::MipsOpcodeInfo info = MIPSAnalyst::GetOpcodeInfo(debugger,start+i); diff --git a/Windows/Debugger/CtrlDisAsmView.h b/Windows/Debugger/CtrlDisAsmView.h index 95e6b82c6c..ff4ebd2fa3 100644 --- a/Windows/Debugger/CtrlDisAsmView.h +++ b/Windows/Debugger/CtrlDisAsmView.h @@ -50,7 +50,6 @@ class CtrlDisAsmView u32 windowStart; int visibleRows; - int instructionSize; bool whiteBackground; bool displaySymbols; @@ -110,7 +109,6 @@ public: { debugger=deb; curAddress=debugger->getPC(); - instructionSize=debugger->getInstructionSize(0); manager.setCpu(deb); } DebugInterface *getDebugger() @@ -123,13 +121,12 @@ public: void gotoAddr(unsigned int addr) { - addr = manager.getStartAddress(addr); - u32 windowEnd = windowStart+visibleRows*instructionSize; - u32 newAddress = addr&(~(instructionSize-1)); + u32 windowEnd = manager.getNthNextAddress(windowStart,visibleRows); + u32 newAddress = manager.getStartAddress(addr); if (newAddress < windowStart || newAddress >= windowEnd) { - windowStart = newAddress-visibleRows/2*instructionSize; + windowStart = manager.getNthPreviousAddress(newAddress,visibleRows/2); } setCurAddress(newAddress); @@ -138,7 +135,7 @@ public: } void gotoPC() { - gotoAddr(debugger->getPC()&(~(instructionSize-1))); + gotoAddr(debugger->getPC()); } u32 getSelection() {