aboutsummaryrefslogtreecommitdiff
path: root/ChocolArm64/Instruction/ASoftFallback.cs
diff options
context:
space:
mode:
authorMS-DOS1999 <mgnjulien@gmail.com>2018-04-19 05:22:12 +0200
committergdkchan <gab.dark.100@gmail.com>2018-04-19 00:22:12 -0300
commit76a5972378b0c0980fa13fe23778a465b5e1900d (patch)
tree8a12aa21ebe495ab3264fde886217a5afadd7db4 /ChocolArm64/Instruction/ASoftFallback.cs
parent6e69cd9284c0ba4bb25560f83dcea298169bdf7b (diff)
Fix Fmin/max and add vector version, add and modifying fmin/max tests (#89)
Diffstat (limited to 'ChocolArm64/Instruction/ASoftFallback.cs')
-rw-r--r--ChocolArm64/Instruction/ASoftFallback.cs76
1 files changed, 76 insertions, 0 deletions
diff --git a/ChocolArm64/Instruction/ASoftFallback.cs b/ChocolArm64/Instruction/ASoftFallback.cs
index 64f539fc..c08f253e 100644
--- a/ChocolArm64/Instruction/ASoftFallback.cs
+++ b/ChocolArm64/Instruction/ASoftFallback.cs
@@ -256,6 +256,82 @@ namespace ChocolArm64.Instruction
((Value >> 6) & 1) + (Value >> 7);
}
+ public static float MaxF(float val1, float val2)
+ {
+ if (val1 == 0.0 && val2 == 0.0)
+ {
+ if (BitConverter.SingleToInt32Bits(val1) < 0 && BitConverter.SingleToInt32Bits(val2) < 0)
+ return -0.0f;
+
+ return 0.0f;
+ }
+
+ if (val1 > val2)
+ return val1;
+
+ if (float.IsNaN(val1))
+ return val1;
+
+ return val2;
+ }
+
+ public static double Max(double val1, double val2)
+ {
+ if (val1 == 0.0 && val2 == 0.0)
+ {
+ if (BitConverter.DoubleToInt64Bits(val1) < 0 && BitConverter.DoubleToInt64Bits(val2) < 0)
+ return -0.0;
+
+ return 0.0;
+ }
+
+ if (val1 > val2)
+ return val1;
+
+ if (double.IsNaN(val1))
+ return val1;
+
+ return val2;
+ }
+
+ public static float MinF(float val1, float val2)
+ {
+ if (val1 == 0.0 && val2 == 0.0)
+ {
+ if (BitConverter.SingleToInt32Bits(val1) < 0 || BitConverter.SingleToInt32Bits(val2) < 0)
+ return -0.0f;
+
+ return 0.0f;
+ }
+
+ if (val1 < val2)
+ return val1;
+
+ if (float.IsNaN(val1))
+ return val1;
+
+ return val2;
+ }
+
+ public static double Min(double val1, double val2)
+ {
+ if (val1 == 0.0 && val2 == 0.0)
+ {
+ if (BitConverter.DoubleToInt64Bits(val1) < 0 || BitConverter.DoubleToInt64Bits(val2) < 0)
+ return -0.0;
+
+ return 0.0;
+ }
+
+ if (val1 < val2)
+ return val1;
+
+ if (double.IsNaN(val1))
+ return val1;
+
+ return val2;
+ }
+
public static float RoundF(float Value, int Fpcr)
{
switch ((ARoundMode)((Fpcr >> 22) & 3))