Implement some arithmetic words
[rrq/jonasforth.git] / main.asm
index 67e9a7b6a96a1225d9fc37ca322b3bd6030528b3..d2cd54deb29e91c65f5d366d344aba29911eba39 100644 (file)
--- a/main.asm
+++ b/main.asm
@@ -431,6 +431,17 @@ forth_asm MINUS, '-'
   push rbx
   next
 
+;; Given two integers a and b on the stack, pushes the quotient and remainder of
+;; division of a by b.
+forth_asm TIMESMOD, '/MOD'
+  pop rbx                       ; b
+  pop rax                       ; a
+  mov rdx, 0
+  div rbx
+  push rax                      ; a / b
+  push rdx                      ; a % b
+  next
+
 ;; Get the location of the STATE variable. It can be set with '!' and read with
 ;; '@'.
 forth STATE, 'STATE'