Merge pull request #4462 from Kingcom/FollowOp

Extend follow functionality of disassembly
This commit is contained in:
Henrik Rydgård 2013-11-06 12:15:57 -08:00
commit dbaac03afb
3 changed files with 35 additions and 3 deletions

View File

@ -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;

View File

@ -113,6 +113,9 @@ namespace MIPSAnalyst
bool isDataAccess;
int dataSize;
u32 dataAddress;
bool hasRelevantAddress;
u32 releventAddress;
} MipsOpcodeInfo;
MipsOpcodeInfo GetOpcodeInfo(DebugInterface* cpu, u32 address);

View File

@ -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));