aboutsummaryrefslogtreecommitdiff
path: root/Math_Ext.jai
diff options
context:
space:
mode:
authordam <dam@gudinoff>2023-06-29 19:40:35 +0100
committerdam <dam@gudinoff>2023-06-29 19:40:35 +0100
commit790b57ca5bbcf74784cb5f2c43e1479756a72840 (patch)
tree1a9a2d44c0197f3cac76f313bfccfa07c94290d5 /Math_Ext.jai
parent1238925ad79b736c262105103a0de8a8c634b7c0 (diff)
downloadtask-time-tracker-790b57ca5bbcf74784cb5f2c43e1479756a72840.tar.zst
task-time-tracker-790b57ca5bbcf74784cb5f2c43e1479756a72840.zip
Fix u-mul and force zero-extension on u8-div.
Diffstat (limited to 'Math_Ext.jai')
-rw-r--r--Math_Ext.jai3
1 files changed, 2 insertions, 1 deletions
diff --git a/Math_Ext.jai b/Math_Ext.jai
index 8f7531b..dd553cd 100644
--- a/Math_Ext.jai
+++ b/Math_Ext.jai
@@ -230,6 +230,7 @@ mul :: (x: $Tx, y: $Ty, $USE_GENERIC: bool = false) -> result: $Tr, overflow: bo
#if Tr == u32 { MAX :: U32_MAX; }
#if Tr == u64 { MAX :: U64_MAX; }
+ if x == 0 || y == 0 then return 0, false;
if x > MAX / y then return MAX, true;
}
@@ -422,7 +423,7 @@ div :: (x: $Tx, y: $Ty, $USE_GENERIC: bool = false) -> result: $Tr, remainder: T
remainder === d;
mov saturated, 0;
- mov result, x;
+ movzxbw result, x; // Move zero-extended byte to word.
div.SIZE result, y;
// Extract remainder from result's high bits.