1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-23 23:18:05 +11:00

forth: add words "MOD" and "/MOD"

This commit is contained in:
Virgil Dupras 2020-03-16 22:36:29 -04:00
parent 5d5517ac44
commit 839d7097e7
3 changed files with 10 additions and 5 deletions

View File

@ -47,3 +47,5 @@
: = CMP NOT ; : = CMP NOT ;
: < CMP 0 1 - = ; : < CMP 0 1 - = ;
: > CMP 1 = ; : > CMP 1 = ;
: / /MOD SWAP DROP ;
: MOD /MOD DROP ;

View File

@ -734,23 +734,24 @@ MULT:
push hl push hl
jp next jp next
; ( a b -- c ) A / B
.db "/" .db "/MOD"
.fill 6 .fill 3
.dw MULT .dw MULT
.db 0 .db 0
DIV: DIVMOD:
.dw nativeWord .dw nativeWord
pop de pop de
pop hl pop hl
call divide call divide
push hl
push bc push bc
jp next jp next
; ( a1 a2 -- b ) ; ( a1 a2 -- b )
.db "SCMP" .db "SCMP"
.fill 3 .fill 3
.dw DIV .dw DIVMOD
.db 0 .db 0
SCMP: SCMP:
.dw nativeWord .dw nativeWord

View File

@ -121,6 +121,8 @@ H -- a HERE @
-^ a b -- c b - a -> c -^ a b -- c b - a -> c
* a b -- c a * b -> c * a b -- c a * b -> c
/ a b -- c a / b -> c / a b -- c a / b -> c
MOD a b -- c a % b -> c
/MOD a b -- r q r:remainder q:quotient
*** Logic *** *** Logic ***
= n1 n2 -- f Push true if n1 == n2 = n1 n2 -- f Push true if n1 == n2