From aae08173f1d08765b369083f31407149a11a02d3 Mon Sep 17 00:00:00 2001 From: Kingcom Date: Tue, 5 Nov 2013 21:20:21 +0100 Subject: [PATCH] Extend follow functionality of disassembly --- Core/MIPS/MIPSAnalyst.cpp | 29 +++++++++++++++++++++++++++++ Core/MIPS/MIPSAnalyst.h | 3 +++ Windows/Debugger/CtrlDisAsmView.cpp | 6 +++--- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/Core/MIPS/MIPSAnalyst.cpp b/Core/MIPS/MIPSAnalyst.cpp index d9c2324b3..c6cfd909f 100644 --- a/Core/MIPS/MIPSAnalyst.cpp +++ b/Core/MIPS/MIPSAnalyst.cpp @@ -401,6 +401,32 @@ namespace MIPSAnalyst { MIPSInfo opInfo = MIPSGetInfo(op); info.isLikelyBranch = (opInfo & LIKELY) != 0; + // gather relevant address for alu operations + // that's usually the value of the dest register + switch (MIPS_GET_OP(op)) + { + case 0: // special + switch (MIPS_GET_FUNC(op)) + { + case 0x20: // add + case 0x21: // addu + info.hasRelevantAddress = true; + info.releventAddress = cpu->GetRegValue(0,MIPS_GET_RS(op))+cpu->GetRegValue(0,MIPS_GET_RT(op)); + break; + case 0x22: // sub + case 0x23: // subu + info.hasRelevantAddress = true; + info.releventAddress = cpu->GetRegValue(0,MIPS_GET_RS(op))-cpu->GetRegValue(0,MIPS_GET_RT(op)); + break; + } + break; + case 0x08: // addi + case 0x09: // adiu + info.hasRelevantAddress = true; + info.releventAddress = cpu->GetRegValue(0,MIPS_GET_RS(op))+((s16)(op & 0xFFFF)); + break; + } + //j , jal, ... if (opInfo & IS_JUMP) { info.isBranch = true; @@ -502,6 +528,9 @@ namespace MIPSAnalyst { u32 rs = cpu->GetRegValue(0, (int)MIPS_GET_RS(op)); s16 imm16 = op & 0xFFFF; info.dataAddress = rs + imm16; + + info.hasRelevantAddress = true; + info.releventAddress = info.dataAddress; } return info; diff --git a/Core/MIPS/MIPSAnalyst.h b/Core/MIPS/MIPSAnalyst.h index d68a30bc2..ed5555e48 100644 --- a/Core/MIPS/MIPSAnalyst.h +++ b/Core/MIPS/MIPSAnalyst.h @@ -113,6 +113,9 @@ namespace MIPSAnalyst bool isDataAccess; int dataSize; u32 dataAddress; + + bool hasRelevantAddress; + u32 releventAddress; } MipsOpcodeInfo; MipsOpcodeInfo GetOpcodeInfo(DebugInterface* cpu, u32 address); diff --git a/Windows/Debugger/CtrlDisAsmView.cpp b/Windows/Debugger/CtrlDisAsmView.cpp index 894333549..54f0933eb 100644 --- a/Windows/Debugger/CtrlDisAsmView.cpp +++ b/Windows/Debugger/CtrlDisAsmView.cpp @@ -751,10 +751,10 @@ void CtrlDisAsmView::followBranch() { jumpStack.push_back(curAddress); gotoAddr(info.branchTarget); - } else if (info.isDataAccess) + } else if (info.hasRelevantAddress) { // well, not exactly a branch, but we can do something anyway - SendMessage(GetParent(wnd),WM_DEB_GOTOHEXEDIT,info.dataAddress,0); + SendMessage(GetParent(wnd),WM_DEB_GOTOHEXEDIT,info.releventAddress,0); SetFocus(wnd); } } @@ -849,7 +849,7 @@ void CtrlDisAsmView::onKeyDown(WPARAM wParam, LPARAM lParam) break; case VK_NEXT: if (curAddress != windowEnd - instructionSize && curAddressIsVisible()) { - setCurAddress(windowEnd - instructionSize, GetAsyncKeyState(VK_SHIFT)); + setCurAddress(windowEnd - instructionSize, KeyDownAsync(VK_SHIFT)); scrollAddressIntoView(); } else { setCurAddress(curAddress + visibleRows * instructionSize, KeyDownAsync(VK_SHIFT));