Added major MTSPR/MFSPR mnemonics and MFTB mnemonics

This commit is contained in:
dingusdev 2020-02-15 13:10:01 -07:00
parent 6f6e5671d4
commit 158b0d2b50

View File

@ -131,6 +131,27 @@ const char* trap_cond[32] = { /*Trap conditions*/
"twne", "", "", "", "", "", "", "" "twne", "", "", "", "", "", "", ""
}; };
const char* spr_index0[32] = {
"mq", "xer", "", "", "", "", "", "",
"lr", "ctr", "", "", "", "", "", "",
"", "", "dsisr", "dar", "rtcu", "rtcl", "dec", "",
"", "sdr1", "srr0", "srr1", "", "", "", ""
};
const char* spr_index8[32] = {
"", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "",
"sprg0", "sprg1", "sprg2", "sprg3", "", "", "", "",
"", "", "ear", "", "tbl", "tbu", "", ""
};
const char* spr_index16[32] = {
"", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "",
"ibat0u", "ibat0l", "ibat1u", "ibat1l","ibat2u", "ibat2l", "ibat3u", "ibat3l",
"dbat0u", "dbat0l", "dbat1u", "dbat1l","dbat2u", "dbat2l", "dbat3u", "dbat3l",
};
/** various formatting helpers. */ /** various formatting helpers. */
void fmt_oneop(string& buf, const char* opc, int src) void fmt_oneop(string& buf, const char* opc, int src)
{ {
@ -953,6 +974,8 @@ void opc_group31(PPCDisasmContext* ctx)
} }
auto ref_spr = (((ctx->instr_code >> 11) & 31) << 5) | ((ctx->instr_code >> 16) & 31); auto ref_spr = (((ctx->instr_code >> 11) & 31) << 5) | ((ctx->instr_code >> 16) & 31);
auto spr_high = (ctx->instr_code >> 11) & 31;
auto spr_low = (ctx->instr_code >> 16) & 31;
switch (ext_opc) { switch (ext_opc) {
case 0: /* cmp */ case 0: /* cmp */
@ -1032,58 +1055,55 @@ void opc_group31(PPCDisasmContext* ctx)
break; break;
case 339: /* mfspr */ case 339: /* mfspr */
if (ctx->simplified) { if (ctx->simplified) {
switch (ref_spr) { switch (spr_high) {
case 0: //case 0 is 601 only case 0:
ctx->instr_str = my_sprintf("%-8sr%d", "mfmq", rs); strcpy(opcode, "mf");
return; strcat(opcode, spr_index0[spr_low]);
case 1: ctx->instr_str = my_sprintf("%-8sr%d", opcode, rs);
ctx->instr_str = my_sprintf("%-8sr%d", "mfxer", rs);
return; return;
case 8: case 8:
ctx->instr_str = my_sprintf("%-8sr%d", "mflr", rs); strcpy(opcode, "mf");
strcat(opcode, spr_index8[spr_low]);
ctx->instr_str = my_sprintf("%-8sr%d", opcode, rs);
return; return;
case 9: case 16:
ctx->instr_str = my_sprintf("%-8sr%d", "mfctr", rs); strcpy(opcode, "mf");
return; strcat(opcode, spr_index16[spr_low]);
case 18: ctx->instr_str = my_sprintf("%-8sr%d", opcode, rs);
ctx->instr_str = my_sprintf("%-8sr%d", "mfdsisr", rs);
return;
case 19:
ctx->instr_str = my_sprintf("%-8sr%d", "mfdar", rs);
return;
case 22:
ctx->instr_str = my_sprintf("%-8sr%d", "mfdec", rs);
return; return;
} }
} }
fmt_twoop_fromspr(ctx->instr_str, "mfspr", rs, ref_spr); fmt_twoop_fromspr(ctx->instr_str, "mfspr", rs, ref_spr);
break; break;
case 371: /* mftb */ case 371: /* mftb */
fmt_twoop_tospr(ctx->instr_str, "mftb", ref_spr, rs); if (ctx->simplified) {
if (ref_spr == 268) {
fmt_oneop(ctx->instr_str, "mftbl", rs);
}
else if (ref_spr == 269) {
fmt_oneop(ctx->instr_str, "mftbu", rs);
}
return;
}
ctx->instr_str = my_sprintf("%-8sr%d, %d", "mftb", rs, ref_spr);
break; break;
case 467: /* mtspr */ case 467: /* mtspr */
if (ctx->simplified) { if (ctx->simplified) {
switch (ref_spr) { switch (spr_high) {
case 0: //case 0 is 601 only case 0:
ctx->instr_str = my_sprintf("%-8sr%d", "mtmq", rs); strcpy(opcode, "mt");
return; strcat(opcode, spr_index0[spr_low]);
case 1: ctx->instr_str = my_sprintf("%-8sr%d", opcode, rs);
ctx->instr_str = my_sprintf("%-8sr%d", "mtxer", rs);
return; return;
case 8: case 8:
ctx->instr_str = my_sprintf("%-8sr%d", "mtlr", rs); strcpy(opcode, "mt");
strcat(opcode, spr_index8[spr_low]);
ctx->instr_str = my_sprintf("%-8sr%d", opcode, rs);
return; return;
case 9: case 16:
ctx->instr_str = my_sprintf("%-8sr%d", "mtctr", rs); strcpy(opcode, "mt");
return; strcat(opcode, spr_index16[spr_low]);
case 18: ctx->instr_str = my_sprintf("%-8sr%d", opcode, rs);
ctx->instr_str = my_sprintf("%-8sr%d", "mtdsisr", rs);
return;
case 19:
ctx->instr_str = my_sprintf("%-8sr%d", "mtdar", rs);
return;
case 27:
ctx->instr_str = my_sprintf("%-8sr%d", "mtdec", rs);
return; return;
} }
} }