commit c360019cfde9a3a33a4272105d26ad686dea8ea8
parent 162e67174046db98c9ac77a7697904f645110c72
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Fri, 24 Jun 2022 21:27:44 -0400
Add /mod kernel word
Diffstat:
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/dusk.asm b/dusk.asm
@@ -470,6 +470,16 @@ defword '*', 1, word_mul
mov [ebp], eax
ret
+; ( a b -- r q )
+defword '/mod', 4, word_divmod
+ mov eax, [ebp+4]
+ mov ebx, [ebp]
+ xor edx, edx
+ div ebx
+ mov [ebp+4], edx ; remainder
+ mov [ebp], eax ; quotient
+ ret
+
defword 'and', 3, word_and
pspop eax
and [ebp], eax
diff --git a/fs/tests/kernel.fs b/fs/tests/kernel.fs
@@ -2,6 +2,10 @@
testbegin
\ Testing native words and boot.fs
+\ arithmetic
+3 5 * 15 #eq
+11 3 /mod 3 #eq ( q ) 2 #eq ( r )
+
\ to semantics
42 value foo
43 to foo