Debugger: Cleanup some sign extends in disassembly.

This commit is contained in:
Unknown W. Brackets 2023-04-09 10:36:20 -07:00
parent f31a7a0582
commit 5233a3bc84
3 changed files with 17 additions and 18 deletions

View File

@ -97,7 +97,7 @@ namespace MIPSDis
void Dis_FPULS(MIPSOpcode op, char *out)
{
int offset = (signed short)(op&0xFFFF);
int offset = SignExtend16ToS32(op & 0xFFFF);
int ft = _FT;
int rs = _RS;
const char *name = MIPSGetName(op);
@ -114,7 +114,7 @@ namespace MIPSDis
void Dis_FPUBranch(MIPSOpcode op, char *out)
{
u32 off = disPC;
int imm = (signed short)(op&0xFFFF)<<2;
int imm = SignExtend16ToS32(op & 0xFFFF) << 2;
off += imm + 4;
const char *name = MIPSGetName(op);
sprintf(out, "%s\t->$%08x",name,off);
@ -123,7 +123,7 @@ namespace MIPSDis
void Dis_RelBranch(MIPSOpcode op, char *out)
{
u32 off = disPC;
int imm = (signed short)(op&0xFFFF)<<2;
int imm = SignExtend16ToS32(op & 0xFFFF) << 2;
int rs = _RS;
off += imm + 4;
@ -155,7 +155,7 @@ namespace MIPSDis
void Dis_RelBranch2(MIPSOpcode op, char *out)
{
u32 off = disPC;
int imm = (signed short)(op&0xFFFF)<<2;
int imm = SignExtend16ToS32(op & 0xFFFF) << 2;
int rt = _RT;
int rs = _RS;
off += imm + 4;
@ -196,7 +196,7 @@ namespace MIPSDis
}
void Dis_ori(MIPSOpcode op, char *out)
{
u32 uimm = (u32)(u16)(op & 0xFFFF);
u32 uimm = op & 0xFFFF;
int rt = _RT;
int rs = _RS;
const char *name = MIPSGetName(op);
@ -208,7 +208,7 @@ namespace MIPSDis
void Dis_IType1(MIPSOpcode op, char *out)
{
u32 uimm = (u32)(u16)(op & 0xFFFF);
u32 uimm = op & 0xFFFF;
int rt = _RT;
const char *name = MIPSGetName(op);
sprintf(out, "%s\t%s, 0x%X",name,RN(rt),uimm);
@ -216,7 +216,7 @@ namespace MIPSDis
void Dis_addi(MIPSOpcode op, char *out)
{
int imm = (signed short)(op&0xFFFF);
int imm = SignExtend16ToS32(op & 0xFFFF);
int rt = _RT;
int rs = _RS;
if (rs == 0)
@ -227,7 +227,7 @@ namespace MIPSDis
void Dis_ITypeMem(MIPSOpcode op, char *out)
{
int imm = (signed short)(op&0xFFFF);
int imm = SignExtend16ToS32(op & 0xFFFF);
int rt = _RT;
int rs = _RS;
const char *name = MIPSGetName(op);

View File

@ -16,13 +16,11 @@
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include <cstring>
#include "Core/HLE/HLE.h"
#include "Common/Data/Convert/SmallDataConvert.h"
#include "Core/MIPS/MIPS.h"
#include "Core/MIPS/MIPSDis.h"
#include "Core/MIPS/MIPSTables.h"
#include "Core/MIPS/MIPSDebugInterface.h"
#include "Core/MIPS/MIPSVFPUUtils.h"
#define _RS ((op>>21) & 0x1F)
@ -102,7 +100,7 @@ namespace MIPSDis
{
void Dis_SV(MIPSOpcode op, char *out)
{
int offset = (signed short)(op&0xFFFC);
int offset = SignExtend16ToS32(op & 0xFFFC);
int vt = ((op>>16)&0x1f)|((op&3)<<5);
int rs = (op>>21) & 0x1f;
const char *name = MIPSGetName(op);
@ -111,7 +109,7 @@ namespace MIPSDis
void Dis_SVQ(MIPSOpcode op, char *out)
{
int offset = (signed short)(op&0xFFFC);
int offset = SignExtend16ToS32(op & 0xFFFC);
int vt = (((op>>16)&0x1f))|((op&1)<<5);
int rs = (op>>21) & 0x1f;
const char *name = MIPSGetName(op);
@ -122,7 +120,7 @@ namespace MIPSDis
void Dis_SVLRQ(MIPSOpcode op, char *out)
{
int offset = (signed short)(op&0xFFFC);
int offset = SignExtend16ToS32(op & 0xFFFC);
int vt = (((op>>16)&0x1f))|((op&1)<<5);
int rs = (op>>21) & 0x1f;
int lr = (op>>1)&1;
@ -603,7 +601,7 @@ namespace MIPSDis
void Dis_VBranch(MIPSOpcode op, char *out)
{
u32 off = disPC;
int imm = (signed short)(op&0xFFFF)<<2;
int imm = SignExtend16ToS32(op&0xFFFF) << 2;
int imm3 = (op>>18)&7;
off += imm + 4;
const char *name = MIPSGetName(op);

View File

@ -21,6 +21,7 @@
#include <limits>
#include <algorithm>
#include "Common/Data/Convert/SmallDataConvert.h"
#include "Common/Math/math_util.h"
#include "Core/Compatibility.h"
@ -201,7 +202,7 @@ namespace MIPSInt
void Int_SVQ(MIPSOpcode op)
{
int imm = (signed short)(op&0xFFFC);
int imm = SignExtend16ToS32(op & 0xFFFC);
int rs = _RS;
int vt = (((op >> 16) & 0x1f)) | ((op&1) << 5);
@ -419,7 +420,7 @@ namespace MIPSInt
void Int_Viim(MIPSOpcode op) {
int vt = _VT;
s32 imm = (s16)(op&0xFFFF);
s32 imm = SignExtend16ToS32(op & 0xFFFF);
u16 uimm16 = (op&0xFFFF);
float f[1];
int type = (op >> 23) & 7;
@ -1736,7 +1737,7 @@ namespace MIPSInt
void Int_SV(MIPSOpcode op)
{
s32 imm = (signed short)(op&0xFFFC);
s32 imm = SignExtend16ToS32(op & 0xFFFC);
int vt = ((op >> 16) & 0x1f) | ((op & 3) << 5);
int rs = _RS;
u32 addr = R(rs) + imm;