Skip to content

Commit

Permalink
Merge pull request hrydgard#961 from unknownbrackets/debugger
Browse files Browse the repository at this point in the history
Clean up disasm immediates
  • Loading branch information
hrydgard committed Mar 12, 2013
2 parents 34865fe + 243c8c7 commit e098d6f
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions Core/MIPS/MIPSDis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit e098d6f

Please sign in to comment.