From 44e20fb213741ed0091ac509c7aea09531ce123f Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 26 May 2013 16:24:44 -0700 Subject: [PATCH] Correctly detect bltzal as func calls in debug. --- Core/MIPS/MIPSAnalyst.cpp | 2 +- Core/MIPS/MIPSCodeUtils.cpp | 19 ++++++++++++++++++- Core/MIPS/MIPSCodeUtils.h | 2 ++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Core/MIPS/MIPSAnalyst.cpp b/Core/MIPS/MIPSAnalyst.cpp index 1a91df2911..dd18ac02e1 100644 --- a/Core/MIPS/MIPSAnalyst.cpp +++ b/Core/MIPS/MIPSAnalyst.cpp @@ -353,7 +353,7 @@ namespace MIPSAnalyst } u32 op = Memory::Read_Instruction(addr); - u32 target = GetBranchTarget(addr); + u32 target = GetBranchTargetNoRA(addr); if (target != INVALIDTARGET) { isStraightLeaf = false; diff --git a/Core/MIPS/MIPSCodeUtils.cpp b/Core/MIPS/MIPSCodeUtils.cpp index 3aade2c9f8..7701c682f9 100644 --- a/Core/MIPS/MIPSCodeUtils.cpp +++ b/Core/MIPS/MIPSCodeUtils.cpp @@ -56,7 +56,24 @@ namespace MIPSCodeUtils return addr + ((signed short)(op&0xFFFF)<<2); } else - return INVALIDTARGET; + return INVALIDTARGET; + } + else + return INVALIDTARGET; + } + + u32 GetBranchTargetNoRA(u32 addr) + { + u32 op = Memory::Read_Instruction(addr); + if (op) + { + u32 info = MIPSGetInfo(op); + if ((info & IS_CONDBRANCH) && !(info & OUT_RA)) + { + return addr + ((signed short)(op&0xFFFF)<<2); + } + else + return INVALIDTARGET; } else return INVALIDTARGET; diff --git a/Core/MIPS/MIPSCodeUtils.h b/Core/MIPS/MIPSCodeUtils.h index 87d61e8192..604c141943 100644 --- a/Core/MIPS/MIPSCodeUtils.h +++ b/Core/MIPS/MIPSCodeUtils.h @@ -49,6 +49,8 @@ namespace MIPSCodeUtils { u32 GetCallTarget(u32 addr); u32 GetBranchTarget(u32 addr); + // Ignores bltzal/etc. the change RA. + u32 GetBranchTargetNoRA(u32 addr); u32 GetJumpTarget(u32 addr); u32 GetSureBranchTarget(u32 addr); void RewriteSysCalls(u32 startAddr, u32 endAddr);