mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-23 17:00:08 +00:00
armemu: Implement USAD8 and USADA8
This commit is contained in:
parent
af1cd769e7
commit
07471d111a
@ -5888,8 +5888,37 @@ L_stm_s_takeabort:
|
|||||||
case 0x75:
|
case 0x75:
|
||||||
printf ("Unhandled v6 insn: smmla/smmls/smmul\n");
|
printf ("Unhandled v6 insn: smmla/smmls/smmul\n");
|
||||||
break;
|
break;
|
||||||
case 0x78:
|
case 0x78: // USAD8 and USADA8
|
||||||
printf ("Unhandled v6 insn: usad/usada8\n");
|
{
|
||||||
|
const u8 rm_idx = BITS(8, 11);
|
||||||
|
const u8 rn_idx = BITS(0, 3);
|
||||||
|
const u8 rd_idx = BITS(16, 19);
|
||||||
|
|
||||||
|
const u32 rm_val = state->Reg[rm_idx];
|
||||||
|
const u32 rn_val = state->Reg[rn_idx];
|
||||||
|
|
||||||
|
// Equivalent of https://graphics.stanford.edu/~seander/bithacks.html#IntegerAbs for 8-bit.
|
||||||
|
auto branchlessAbs = [&](u8 shift) {
|
||||||
|
const int diff = ((rn_val >> shift) & 0xFF) - ((rm_val >> shift) & 0xFF);
|
||||||
|
const int mask = diff >> (CHAR_BIT - 1);
|
||||||
|
|
||||||
|
return (diff + mask) ^ mask;
|
||||||
|
};
|
||||||
|
|
||||||
|
u32 finalDif = 0;
|
||||||
|
finalDif += branchlessAbs(0);
|
||||||
|
finalDif += branchlessAbs(8);
|
||||||
|
finalDif += branchlessAbs(16);
|
||||||
|
finalDif += branchlessAbs(24);
|
||||||
|
|
||||||
|
// Op is USADA8 if true.
|
||||||
|
const u8 ra_idx = BITS(12, 15);
|
||||||
|
if (ra_idx != 15)
|
||||||
|
finalDif += state->Reg[ra_idx];
|
||||||
|
|
||||||
|
state->Reg[rd_idx] = finalDif;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
#if 0
|
#if 0
|
||||||
case 0x7a:
|
case 0x7a:
|
||||||
|
Loading…
Reference in New Issue
Block a user