projects
/
rrq
/
jonasforth.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Implement some arithmetic words
[rrq/jonasforth.git]
/
main.asm
diff --git
a/main.asm
b/main.asm
index 2e880d9b36871b250057378f14c6b62b1c6c7d87..d2cd54deb29e91c65f5d366d344aba29911eba39 100644
(file)
--- a/
main.asm
+++ b/
main.asm
@@
-431,6
+431,17
@@
forth_asm MINUS, '-'
push rbx
next
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'
;; Get the location of the STATE variable. It can be set with '!' and read with
;; '@'.
forth STATE, 'STATE'
@@
-527,7
+538,7
@@
forth IMMEDIATE, 'IMMEDIATE', 1
dq LIT, 1
dq LATEST, GET
dq LIT, 8, PLUS
dq LIT, 1
dq LATEST, GET
dq LIT, 8, PLUS
- dq PUT
+ dq PUT
_BYTE
dq EXIT
;; Given the address of a word, return 0 if the given word is not immediate.
dq EXIT
;; Given the address of a word, return 0 if the given word is not immediate.