mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-28 03:36:03 +00:00
Rework signed multiplication. Fixed an edge case and passes all tests. (#174)
This commit is contained in:
parent
3bdd109f45
commit
53ebbcfbd9
1 changed files with 3 additions and 7 deletions
|
@ -153,13 +153,9 @@ namespace ChocolArm64.Instruction
|
|||
|
||||
public static long SMulHi128(long LHS, long RHS)
|
||||
{
|
||||
bool LSign = (LHS < 0);
|
||||
bool RSign = (RHS < 0);
|
||||
|
||||
long Result = (long)UMulHi128((ulong)(LSign ? -LHS : LHS), (ulong)(RSign ? -RHS : RHS));
|
||||
|
||||
if (LSign != RSign && LHS != 0 && RHS != 0)
|
||||
return ~Result; //for negative results, hi 64-bits start at 0xFFF... and count back
|
||||
long Result = (long)UMulHi128((ulong)(LHS), (ulong)(RHS));
|
||||
if (LHS < 0) Result -= RHS;
|
||||
if (RHS < 0) Result -= LHS;
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue