projects
/
rrq
/
jonasforth.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
c4dd162
)
Implement some arithmetic words
author
Jonas Hvid
<mail@johv.dk>
Mon, 9 Dec 2019 17:09:38 +0000
(18:09 +0100)
committer
Jonas Hvid
<mail@johv.dk>
Mon, 9 Dec 2019 17:09:38 +0000
(18:09 +0100)
main.asm
patch
|
blob
|
history
sys.f
patch
|
blob
|
history
diff --git
a/main.asm
b/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'
diff --git
a/sys.f
b/sys.f
index bc9dae9b53f5cae19ac523786215678299ae9e3c..23fed8781df27e3ee98bfff9a2bd8b12375d1968 100644
(file)
--- a/
sys.f
+++ b/
sys.f
@@
-9,3
+9,7
@@
EXIT [
[ S" [" FIND >CFA , ]
EXIT
[ IMMEDIATE
+
+: / /MOD DROP ;
+: MOD /MOD SWAP DROP ;
+: NEG 0 SWAP - ;