Merge pull request #513 from cxd4/in_ur_codez_disassembling_ur_ops

Document the RSP op-code matrices + static disassembler debugger code.
This commit is contained in:
zilmar 2015-06-23 14:34:54 +10:00
commit 4b1ff1983f
1 changed files with 152 additions and 142 deletions

View File

@ -793,6 +793,69 @@ void RSP_Commands_Setup ( HWND hDlg )
SetWindowPos(hDlg,NULL,X,Y,WindowWidth,WindowHeight, SWP_NOZORDER | SWP_SHOWWINDOW); SetWindowPos(hDlg,NULL,X,Y,WindowWidth,WindowHeight, SWP_NOZORDER | SWP_SHOWWINDOW);
} }
static const char unused_op[] = "invalid";
static const char* mnemonics_primary[8 << 3] = {
"SPECIAL","REGIMM" ,"J" ,"JAL" ,"BEQ" ,"BNE" ,"BLEZ" ,"BGTZ" ,
"ADDI" ,"ADDIU" ,"SLTI" ,"SLTIU" ,"ANDI" ,"ORI" ,"XORI" ,"LUI" ,
"COP0" ,unused_op,"COP2" ,unused_op,unused_op,unused_op,unused_op,unused_op,
unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,
"LB" ,"LH" ,unused_op,"LW" ,"LBU" ,"LHU" ,unused_op,unused_op,
"SB" ,"SH" ,unused_op,"SW" ,unused_op,unused_op,unused_op,unused_op,
unused_op,unused_op,"LWC2" ,unused_op,unused_op,unused_op,unused_op,unused_op,
unused_op,unused_op,"SWC2" ,unused_op,unused_op,unused_op,unused_op,unused_op,
};/* 000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 */
static const char* mnemonics_special[8 << 3] = {
"SLL" ,unused_op,"SRL" ,"SRA" ,"SLLV" ,unused_op,"SRLV" ,"SRAV" ,
"JR" ,"JALR" ,unused_op,unused_op,unused_op,"BREAK" ,unused_op,unused_op,
unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,
unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,
"ADD" ,"ADDU" ,"SUB" ,"SUBU" ,"AND" ,"OR" ,"XOR" ,"NOR" ,
unused_op,unused_op,"SLT" ,"SLTU" ,unused_op,unused_op,unused_op,unused_op,
unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,
unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,
};/* 000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 */
static const char* mnemonics_regimm[8 << 2] = {
"BLTZ" ,"BGEZ" ,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,
unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,
"BLTZAL" ,"BGEZAL" ,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,
unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,
};/* 000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 */
static const char* mnemonics_cop0[8 << 2] = {
"MFC0" ,unused_op,unused_op,unused_op,"MTC0" ,unused_op,unused_op,unused_op,
unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,
unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,
unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,
};/* 000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 */
static const char* mnemonics_cop2[8 << 2] = {
"MFC2" ,unused_op,"CFC2" ,unused_op,"MTC2" ,unused_op,"CTC2" ,unused_op,
unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,
"C2" ,"C2" ,"C2" ,"C2" ,"C2" ,"C2" ,"C2" ,"C2" ,
"C2" ,"C2" ,"C2" ,"C2" ,"C2" ,"C2" ,"C2" ,"C2" ,
};/* 000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 */
static const char* mnemonics_vector[8 << 3] = {
"VMULF" ,"VMULU" ,unused_op,unused_op,"VMUDL" ,"VMUDM" ,"VMUDN" ,"VMUDH" ,
"VMACF" ,"VMACU" ,unused_op,"VMACQ" ,"VMADL" ,"VMADM" ,"VMADN" ,"VMADH" ,
"VADD" ,"VSUB" ,unused_op,"VABS" ,"VADDC" ,"VSUBC" ,unused_op,unused_op,
unused_op,unused_op,unused_op,unused_op,unused_op,"VSAW" ,unused_op,unused_op,
"VLT" ,"VEQ" ,"VNE" ,"VGE" ,"VCL" ,"VCH" ,"VCR" ,"VMRG" ,
"VAND" ,"VNAND" ,"VOR" ,"VNOR" ,"VXOR" ,"VNXOR" ,unused_op,unused_op,
"VRCP" ,"VRCPL" ,"VRCPH" ,"VMOV" ,"VRSQ" ,"VRSQL" ,"VRSQH" ,"VNOP" ,
unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,
};/* 000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 */
static const char* mnemonics_lwc2[8 << 2] = {
"LBV" ,"LSV" ,"LLV" ,"LDV" ,"LQV" ,"LRV" ,"LPV" ,"LUV" ,
"LHV" ,"LFV" ,unused_op,"LTV" ,unused_op,unused_op,unused_op,unused_op,
unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,
unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,
};/* 000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 */
static const char* mnemonics_swc2[8 << 2] = {
"SBV" ,"SSV" ,"SLV" ,"SDV" ,"SQV" ,"SRV" ,"SPV" ,"SUV" ,
"SHV" ,"SFV" ,"SWV" ,"STV" ,unused_op,unused_op,unused_op,unused_op,
unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,
unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,unused_op,
};/* 000 | 001 | 010 | 011 | 100 | 101 | 110 | 111 */
char * RSPSpecialName ( DWORD OpCode, DWORD PC ) char * RSPSpecialName ( DWORD OpCode, DWORD PC )
{ {
OPCODE command; OPCODE command;
@ -893,35 +956,35 @@ char * RSPRegimmName ( DWORD OpCode, DWORD PC )
{ {
OPCODE command; OPCODE command;
command.Hex = OpCode; command.Hex = OpCode;
switch (command.rt) if (strcmp(mnemonics_regimm[command.rt], unused_op) == 0)
{ {
case RSP_REGIMM_BLTZ: sprintf(
sprintf(CommandName,"BLTZ\t%s, 0x%03X",GPR_Name(command.rs), CommandName,
(PC + ((short)command.offset << 2) + 4) & 0xFFC); "RSP: Unknown\t%02X %02X %02X %02X",
break; command.Ascii[3],
case RSP_REGIMM_BGEZ: command.Ascii[2],
sprintf(CommandName,"BGEZ\t%s, 0x%03X",GPR_Name(command.rs), command.Ascii[1],
(PC + ((short)command.offset << 2) + 4) & 0xFFC); command.Ascii[0]
break; );
case RSP_REGIMM_BLTZAL: }
sprintf(CommandName,"BLTZAL\t%s, 0x%03X",GPR_Name(command.rs), else if (command.rt == RSP_REGIMM_BGEZAL && command.rs == 0)
(PC + ((short)command.offset << 2) + 4) & 0xFFC); { /* MIPS pseudo-instruction: BAL (Branch and Link) */
break; sprintf(
case RSP_REGIMM_BGEZAL: CommandName,
if (command.rs == 0) "BAL\t0x%03X",
{ (PC + ((short)command.offset << 2) + 4) & 0xFFC
sprintf(CommandName,"BAL\t0x%03X",(PC + ((short)command.offset << 2) + 4) & 0xFFC); );
} }
else else
{ {
sprintf(CommandName,"BGEZAL\t%s, 0x%03X",GPR_Name(command.rs), sprintf(
(PC + ((short)command.offset << 2) + 4) & 0xFFC); CommandName,
} "%s\t%s, 0x%03X",
break; mnemonics_regimm[command.rt],
default: GPR_Name(command.rs),
sprintf(CommandName,"RSP: Unknown\t%02X %02X %02X %02X", (PC + ((short)command.offset << 2) + 4) & 0xFFC
command.Ascii[3],command.Ascii[2],command.Ascii[1],command.Ascii[0]); );
} }
return CommandName; return CommandName;
} }
@ -933,17 +996,26 @@ char * RSPCop0Name ( DWORD OpCode, DWORD PC )
PC = PC; // unused PC = PC; // unused
switch (command.rs) if (strcmp(mnemonics_cop0[command.rs], unused_op) == 0)
{ {
case RSP_COP0_MF: sprintf(
sprintf(CommandName,"MFC0\t%s, %s",GPR_Name(command.rt),COP0_Name(command.rd)); CommandName,
break; "RSP: Unknown\t%02X %02X %02X %02X",
case RSP_COP0_MT: command.Ascii[3],
sprintf(CommandName,"MTC0\t%s, %s",GPR_Name(command.rt),COP0_Name(command.rd)); command.Ascii[2],
break; command.Ascii[1],
default: command.Ascii[0]
sprintf(CommandName,"RSP: Unknown\t%02X %02X %02X %02X", );
command.Ascii[3],command.Ascii[2],command.Ascii[1],command.Ascii[0]); }
else
{
sprintf(
CommandName,
"%s\t%s, %s",
mnemonics_cop0[command.rs],
GPR_Name(command.rt),
COP0_Name(command.rd)
);
} }
return CommandName; return CommandName;
} }
@ -1174,59 +1246,28 @@ char * RSPLc2Name ( DWORD OpCode, DWORD PC )
PC = PC; // unused PC = PC; // unused
switch (command.rd) if (strcmp(mnemonics_lwc2[command.rd], unused_op) == 0)
{ {
case RSP_LSC2_BV: sprintf(
sprintf(CommandName,"LBV\t$v%d [%d], 0x%04X (%s)",command.rt, command.del, CommandName,
command.voffset, GPR_Name(command.base)); "RSP: Unknown\t%02X %02X %02X %02X",
break; command.Ascii[3],
case RSP_LSC2_SV: command.Ascii[2],
sprintf(CommandName,"LSV\t$v%d [%d], 0x%04X (%s)",command.rt, command.del, command.Ascii[1],
(command.voffset << 1), GPR_Name(command.base)); command.Ascii[0]
break; );
case RSP_LSC2_LV: }
sprintf(CommandName,"LLV\t$v%d [%d], 0x%04X (%s)",command.rt, command.del, else
(command.voffset << 2), GPR_Name(command.base)); {
break; sprintf(
case RSP_LSC2_DV: CommandName,
sprintf(CommandName,"LDV\t$v%d [%d], 0x%04X (%s)",command.rt, command.del, "%s\t$v%d[%d], 0x%04X(%s)",
(command.voffset << 3), GPR_Name(command.base)); mnemonics_lwc2[command.rd],
break; command.rt,
case RSP_LSC2_QV: command.del,
sprintf(CommandName,"LQV\t$v%d [%d], 0x%04X (%s)",command.rt, command.del, command.voffset,
(command.voffset << 4), GPR_Name(command.base)); GPR_Name(command.base)
break; );
case RSP_LSC2_RV:
sprintf(CommandName,"LRV\t$v%d [%d], 0x%04X (%s)",command.rt, command.del,
(command.voffset << 4), GPR_Name(command.base));
break;
case RSP_LSC2_PV:
sprintf(CommandName,"LPV\t$v%d [%d], 0x%04X (%s)",command.rt, command.del,
(command.voffset << 3), GPR_Name(command.base));
break;
case RSP_LSC2_UV:
sprintf(CommandName,"LUV\t$v%d [%d], 0x%04X (%s)",command.rt, command.del,
(command.voffset << 3), GPR_Name(command.base));
break;
case RSP_LSC2_HV:
sprintf(CommandName,"LHV\t$v%d [%d], 0x%04X (%s)",command.rt, command.del,
(command.voffset << 4), GPR_Name(command.base));
break;
case RSP_LSC2_FV:
sprintf(CommandName,"LFV\t$v%d [%d], 0x%04X (%s)",command.rt, command.del,
(command.voffset << 4), GPR_Name(command.base));
break;
case RSP_LSC2_WV:
sprintf(CommandName,"LWV\t$v%d [%d], 0x%04X (%s)",command.rt, command.del,
(command.voffset << 4), GPR_Name(command.base));
break;
case RSP_LSC2_TV:
sprintf(CommandName,"LTV\t$v%d [%d], 0x%04X (%s)",command.rt, command.del,
(command.voffset << 4), GPR_Name(command.base));
break;
default:
sprintf(CommandName,"RSP: Unknown\t%02X %02X %02X %02X",
command.Ascii[3],command.Ascii[2],command.Ascii[1],command.Ascii[0]);
} }
return CommandName; return CommandName;
} }
@ -1238,59 +1279,28 @@ char * RSPSc2Name ( DWORD OpCode, DWORD PC )
PC = PC; // unused PC = PC; // unused
switch (command.rd) if (strcmp(mnemonics_swc2[command.rd], unused_op) == 0)
{ {
case RSP_LSC2_BV: sprintf(
sprintf(CommandName,"SBV\t$v%d [%d], 0x%04X (%s)",command.rt, command.del, CommandName,
command.voffset, GPR_Name(command.base)); "RSP: Unknown\t%02X %02X %02X %02X",
break; command.Ascii[3],
case RSP_LSC2_SV: command.Ascii[2],
sprintf(CommandName,"SSV\t$v%d [%d], 0x%04X (%s)",command.rt, command.del, command.Ascii[1],
(command.voffset << 1), GPR_Name(command.base)); command.Ascii[0]
break; );
case RSP_LSC2_LV: }
sprintf(CommandName,"SLV\t$v%d [%d], 0x%04X (%s)",command.rt, command.del, else
(command.voffset << 2), GPR_Name(command.base)); {
break; sprintf(
case RSP_LSC2_DV: CommandName,
sprintf(CommandName,"SDV\t$v%d [%d], 0x%04X (%s)",command.rt, command.del, "%s\t$v%d[%d], 0x%04X(%s)",
(command.voffset << 3), GPR_Name(command.base)); mnemonics_swc2[command.rd],
break; command.rt,
case RSP_LSC2_QV: command.del,
sprintf(CommandName,"SQV\t$v%d [%d], 0x%04X (%s)",command.rt, command.del, command.voffset,
(command.voffset << 4), GPR_Name(command.base)); GPR_Name(command.base)
break; );
case RSP_LSC2_RV:
sprintf(CommandName,"SRV\t$v%d [%d], 0x%04X (%s)",command.rt, command.del,
(command.voffset << 4), GPR_Name(command.base));
break;
case RSP_LSC2_PV:
sprintf(CommandName,"SPV\t$v%d [%d], 0x%04X (%s)",command.rt, command.del,
(command.voffset << 3), GPR_Name(command.base));
break;
case RSP_LSC2_UV:
sprintf(CommandName,"SUV\t$v%d [%d], 0x%04X (%s)",command.rt, command.del,
(command.voffset << 3), GPR_Name(command.base));
break;
case RSP_LSC2_HV:
sprintf(CommandName,"SHV\t$v%d [%d], 0x%04X (%s)",command.rt, command.del,
(command.voffset << 4), GPR_Name(command.base));
break;
case RSP_LSC2_FV:
sprintf(CommandName,"SFV\t$v%d [%d], 0x%04X (%s)",command.rt, command.del,
(command.voffset << 4), GPR_Name(command.base));
break;
case RSP_LSC2_WV:
sprintf(CommandName,"SWV\t$v%d [%d], 0x%04X (%s)",command.rt, command.del,
(command.voffset << 4), GPR_Name(command.base));
break;
case RSP_LSC2_TV:
sprintf(CommandName,"STV\t$v%d [%d], 0x%04X (%s)",command.rt, command.del,
(command.voffset << 4), GPR_Name(command.base));
break;
default:
sprintf(CommandName,"RSP: Unknown\t%02X %02X %02X %02X",
command.Ascii[3],command.Ascii[2],command.Ascii[1],command.Ascii[0]);
} }
return CommandName; return CommandName;
} }