aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorriperiperi <rhy3756547@hotmail.com>2018-06-20 14:45:20 +0100
committergdkchan <gab.dark.100@gmail.com>2018-06-20 10:45:20 -0300
commit53ebbcfbd9faab2659840bd8e22536cc7a2a6720 (patch)
tree15e2bb9741358bbe6e906f902e641d6117588326
parent3bdd109f45cc3edc0217f5e952a6cc672ce53580 (diff)
Rework signed multiplication. Fixed an edge case and passes all tests. (#174)
-rw-r--r--ChocolArm64/Instruction/ASoftFallback.cs10
1 files changed, 3 insertions, 7 deletions
diff --git a/ChocolArm64/Instruction/ASoftFallback.cs b/ChocolArm64/Instruction/ASoftFallback.cs
index 3f8ab5e3..6a407baf 100644
--- a/ChocolArm64/Instruction/ASoftFallback.cs
+++ b/ChocolArm64/Instruction/ASoftFallback.cs
@@ -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;
}