aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Math_Ext.jai18
1 files changed, 8 insertions, 10 deletions
diff --git a/Math_Ext.jai b/Math_Ext.jai
index dd553cd..500962f 100644
--- a/Math_Ext.jai
+++ b/Math_Ext.jai
@@ -74,7 +74,6 @@ add :: (x: $Tx, y: $Ty, $USE_GENERIC: bool = false) -> result: $Tr, saturated: b
result: Tr = ---;
saturated: bool = ---;
-
S_ADD_ASM :: #string DONE
#asm {
// Calculate limit based on x's sign.
@@ -102,22 +101,21 @@ add :: (x: $Tx, y: $Ty, $USE_GENERIC: bool = false) -> result: $Tr, saturated: b
U_ADD_ASM :: #string DONE
#asm {
- mov limit: gpr, MAX;
- mov result, x;
- add.SIZE result, y;
- setc saturated;
- cmovc result, limit;
+ add.SIZE x, y; // Add values.
+ mov result, -1; // Pre-set result with unsigned maximum.
+ setc saturated; // Set saturated flag if CF.
+ cmovnc result, x; // Move add-result to result if NOT CF.
}
DONE
#if Tr == u8
- #insert #run replace(replace(U_ADD_ASM, ".SIZE", ".b"), "MAX", "255");
+ #insert #run replace(U_ADD_ASM, ".SIZE", ".b");
#if Tr == u16
- #insert #run replace(replace(U_ADD_ASM, ".SIZE", ".w"), "MAX", "65535");
+ #insert #run replace(U_ADD_ASM, ".SIZE", ".w");
#if Tr == u32
- #insert #run replace(replace(U_ADD_ASM, ".SIZE", ".d"), "MAX", "4294967295");
+ #insert #run replace(U_ADD_ASM, ".SIZE", ".d");
#if Tr == u64
- #insert #run replace(replace(U_ADD_ASM, ".SIZE", ".q"), "MAX", "18446744073709551615");
+ #insert #run replace(U_ADD_ASM, ".SIZE", ".q");
return result, saturated;