From 243c8c7a3448fafe458f30364fac67ca02360bd8 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 11 Mar 2013 23:45:29 -0700 Subject: [PATCH] Clean up disasm immediates. They were still a bit wrong. --- Core/MIPS/MIPSDis.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/Core/MIPS/MIPSDis.cpp b/Core/MIPS/MIPSDis.cpp index ddc20763f..3aaac33b4 100644 --- a/Core/MIPS/MIPSDis.cpp +++ b/Core/MIPS/MIPSDis.cpp @@ -163,7 +163,10 @@ namespace MIPSDis void Dis_IType(u32 op, char *out) { - int imm = (signed short)(op&0xFFFF); + s32 simm = (s32)(s16)(op & 0xFFFF); + u32 uimm = (u32)(u16)(op & 0xFFFF); + u32 suimm = (u32)simm; + int rt = _RT; int rs = _RS; const char *name = MIPSGetName(op); @@ -172,34 +175,35 @@ namespace MIPSDis case 8: //addi case 9: //addiu case 10: //slti - sprintf(out, "%s\t%s, %s, %s",name,RN(rt),RN(rs),SignedHex(imm)); + sprintf(out, "%s\t%s, %s, %s",name,RN(rt),RN(rs),SignedHex(simm)); break; case 11: //sltiu - sprintf(out, "%s\t%s, %s, 0x%X",name,RN(rt),RN(rs),(u32)imm); + sprintf(out, "%s\t%s, %s, 0x%X",name,RN(rt),RN(rs),suimm); break; default: - sprintf(out, "%s\t%s, %s, 0x%X",name,RN(rt),RN(rs),(u32)imm); + sprintf(out, "%s\t%s, %s, 0x%X",name,RN(rt),RN(rs),uimm); break; } } void Dis_ori(u32 op, char *out) { - int imm = (signed short)(op&0xFFFF); + s32 simm = (s32)(s16)(op & 0xFFFF); + u32 uimm = (u32)(u16)(op & 0xFFFF); int rt = _RT; int rs = _RS; const char *name = MIPSGetName(op); if (rs == 0) - sprintf(out, "li\t%s, %s",RN(rt),SignedHex(imm)); + sprintf(out, "li\t%s, 0x%X",RN(rt),uimm); else - sprintf(out, "%s\t%s, %s, %s",name,RN(rt),RN(rs),SignedHex(imm)); + sprintf(out, "%s\t%s, %s, 0x%X",name,RN(rt),RN(rs),uimm); } void Dis_IType1(u32 op, char *out) { - int imm = (signed short)(op&0xFFFF); + u32 uimm = (u32)(u16)(op & 0xFFFF); int rt = _RT; const char *name = MIPSGetName(op); - sprintf(out, "%s\t%s, %s",name,RN(rt),SignedHex(imm)); + sprintf(out, "%s\t%s, 0x%X",name,RN(rt),uimm); } void Dis_addi(u32 op, char *out) @@ -266,7 +270,7 @@ namespace MIPSDis name = "rotr"; if (((op & 0x3f) == 6) && sa == 1) name = "rotrv"; - sprintf(out, "%s\t%s, %s, %s",name,RN(rd),RN(rt),SignedHex(sa)); + sprintf(out, "%s\t%s, %s, 0x%X",name,RN(rd),RN(rt),sa); } void Dis_VarShiftType(u32 op, char *out) @@ -300,13 +304,13 @@ namespace MIPSDis case 0x0: //ext { int size = _SIZE + 1; - sprintf(out,"%s\t%s, %s, %s, %s",name,RN(Rt),RN(rs),SignedHex(pos),SignedHex(size)); + sprintf(out,"%s\t%s, %s, 0x%X, 0x%X",name,RN(Rt),RN(rs),pos,size); } break; case 0x4: // ins { int size = (_SIZE + 1) - pos; - sprintf(out,"%s\t%s, %s, %s, %s",name,RN(Rt),RN(rs),SignedHex(pos),SignedHex(size)); + sprintf(out,"%s\t%s, %s, 0x%X, 0x%X",name,RN(Rt),RN(rs),pos,size); } break; }