armemu: Simplify SSAT/SSAT16/SXTB/SXTAB

This commit is contained in:
Lioncash 2014-12-28 12:19:31 -05:00
parent 9f5b53f9ff
commit 6ce2a38ec4

View file

@ -6274,29 +6274,13 @@ L_stm_s_takeabort:
} }
printf("Unhandled v6 insn: pkh/sxtab/selsxtb\n"); printf("Unhandled v6 insn: pkh/sxtab/selsxtb\n");
break; break;
case 0x6a: {
ARMword Rm;
int ror = -1;
switch (BITS(4, 11)) { case 0x6a: // SSAT, SSAT16, SXTB, and SXTAB
case 0x07:
ror = 0;
break;
case 0x47:
ror = 8;
break;
case 0x87:
ror = 16;
break;
case 0xc7:
ror = 24;
break;
case 0x01:
case 0xf3:
//ichfly
//SSAT16
{ {
const u8 op2 = BITS(5, 7);
// SSAT16
if (op2 == 0x01) {
const u8 rd_idx = BITS(12, 15); const u8 rd_idx = BITS(12, 15);
const u8 rn_idx = BITS(0, 3); const u8 rn_idx = BITS(0, 3);
const u8 num_bits = BITS(16, 19) + 1; const u8 num_bits = BITS(16, 19) + 1;
@ -6324,32 +6308,25 @@ L_stm_s_takeabort:
state->Reg[rd_idx] = (rn_lo & 0xFFFF) | ((rn_hi & 0xFFFF) << 16); state->Reg[rd_idx] = (rn_lo & 0xFFFF) | ((rn_hi & 0xFFFF) << 16);
return 1; return 1;
} }
else if (op2 == 0x03) {
const u8 rotation = BITS(10, 11) * 8;
u32 rm = ((state->Reg[BITS(0, 3)] >> rotation) & 0xFF) | (((state->Reg[BITS(0, 3)] << (32 - rotation)) & 0xFF) & 0xFF);
if (rm & 0x80)
rm |= 0xffffff00;
default: // SXTB, otherwise SXTAB
break;
}
if (ror == -1) {
if (BITS(4, 6) == 0x7) {
printf("Unhandled v6 insn: ssat\n");
return 0;
}
break;
}
Rm = ((state->Reg[BITS(0, 3)] >> ror) & 0xFF) | (((state->Reg[BITS(0, 3)] << (32 - ror)) & 0xFF) & 0xFF);
if (Rm & 0x80)
Rm |= 0xffffff00;
if (BITS(16, 19) == 0xf) if (BITS(16, 19) == 0xf)
/* SXTB */ state->Reg[BITS(12, 15)] = rm;
state->Reg[BITS(12, 15)] = Rm;
else else
/* SXTAB */ state->Reg[BITS(12, 15)] = state->Reg[BITS(16, 19)] + rm;
state->Reg[BITS(12, 15)] = state->Reg[BITS(16, 19)] + Rm;
return 1; return 1;
} }
else {
printf("Unimplemented op: SSAT");
}
}
break;
case 0x6b: // REV, REV16, SXTH, and SXTAH case 0x6b: // REV, REV16, SXTH, and SXTAH
{ {