Fixed compare instructions

This commit is contained in:
dingusdev 2020-02-19 19:03:39 -07:00
parent 5b2369458e
commit c71be1bc37
2 changed files with 16 additions and 9 deletions

View File

@ -473,7 +473,7 @@ void opc_cmp_i_li(PPCDisasmContext* ctx)
auto ls = (ctx->instr_code >> 21) & 0x1;
auto ra = (ctx->instr_code >> 16) & 0x1F;
auto crfd = (ctx->instr_code >> 23) & 0x07;
auto imm = ctx->instr_code & 0xFFFF;
int imm = ctx->instr_code & 0xFFFF;
if (ctx->simplified) {
@ -481,7 +481,7 @@ void opc_cmp_i_li(PPCDisasmContext* ctx)
if ((ctx->instr_code >> 26) & 0x1)
ctx->instr_str = my_sprintf("%-8scr%d, r%d, 0x%X", "cmpwi", crfd, ra, imm);
else
ctx->instr_str = my_sprintf("%-8scr%d, r%d, 0x%04X", "cmplwi", crfd, ra, imm);
ctx->instr_str = my_sprintf("%-8scr%d, r%d, %s0x%X", "cmplwi", crfd, ra, (imm < 0) ? "-" : "", abs(imm));
return;
}
@ -490,7 +490,7 @@ void opc_cmp_i_li(PPCDisasmContext* ctx)
if ((ctx->instr_code >> 26) & 0x1)
ctx->instr_str = my_sprintf("%-8scr%d, %d, r%d, 0x%X", "cmpi", crfd, ls, ra, imm);
else
ctx->instr_str = my_sprintf("%-8scr%d, %d, r%d, 0x%04X", "cmpli", crfd, ls, ra, imm);
ctx->instr_str = my_sprintf("%-8scr%d, %d, r%d, %s0x%X", "cmpli", crfd, ls, ra, (imm < 0) ? "-" : "", abs(imm));
}
void opc_bool_im(PPCDisasmContext* ctx)
@ -1067,8 +1067,14 @@ void opc_group31(PPCDisasmContext* ctx)
if (ctx->simplified) {
if (!(rs & 1)) {
ctx->instr_str = my_sprintf("%-8scr%d, r%d, r%d", "cmpw", (rs >> 2), ra, rb);
return;
if ((rs >> 2) == 0) {
ctx->instr_str = my_sprintf("%-8sr%d, r%d", "cmpw", ra, rb);
return;
}
else {
ctx->instr_str = my_sprintf("%-8scr%d, r%d, r%d", "cmpw", (rs >> 2), ra, rb);
return;
}
}
}
@ -1127,8 +1133,9 @@ void opc_group31(PPCDisasmContext* ctx)
}
}
else
else {
ctx->instr_str = my_sprintf("%-8scr%d, %d, r%d, r%d", "cmpl", (rs >> 2), (rs & 1), ra, rb);
}
break;
case 83: /* mfmsr */
ctx->instr_str = my_sprintf("%-8sr%d", "mfmsr",

View File

@ -357,9 +357,9 @@
# compare instructions
0xFFF00100,0x7C15A000,cmpw,r21,r20
0xFFF00100,0x7FBFB800,cmp,cr7,1,r31,r23
0xFFF00100,0x7FA05840,cmpl,cr7,1,r0,r11
0xFFF00100,0x2FA90000,cmpi,cr7,1,r9,0x0
0xFFF00100,0x2AA3FFFF,cmpli,cr5,1,r3,0xFFFF
0xFFF00100,0x7F804840,cmplw,cr7,r0,r9
0xFFF00100,0x2F800000,cmpwi,cr7,r0,0x0
0xFFF00100,0x298E0022,cmplwi,cr3,r14,0x22
0xFFF00100,0xFE17C840,fcmpo,cr4,f23,f25
0xFFF00100,0xFF0C6800,fcmpu,cr6,f12,f13

1 # Test data for PowerPC disassembler supplied as comma-separated values
357 0xFFF00100,0x7CA305AA,stswi,r5,r3,0x20
358 0xFFF00100,0x7D453D2A,stswx,r10,r5,r7
359 0xFFF00100,0x7C0002E4,tlbia
360 0xFFF00100,0x7C004A64,tlbie,r9
361 # various simplified (extended) mnemonics
362 0xFFF00100,0x60000000,nop
363 0xFFF00100,0x7C7C1B78,mr,r28,r3
364 0xFFF00100,0x7C7C1B78,mr,r28,r3
365 0xFFF00100,0x7DAA6B79,mr.,r10,r13