mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-25 04:38:05 +11:00
forth: add words "MOD" and "/MOD"
This commit is contained in:
parent
5d5517ac44
commit
839d7097e7
@ -47,3 +47,5 @@
|
||||
: = CMP NOT ;
|
||||
: < CMP 0 1 - = ;
|
||||
: > CMP 1 = ;
|
||||
: / /MOD SWAP DROP ;
|
||||
: MOD /MOD DROP ;
|
||||
|
@ -734,23 +734,24 @@ MULT:
|
||||
push hl
|
||||
jp next
|
||||
|
||||
; ( a b -- c ) A / B
|
||||
.db "/"
|
||||
.fill 6
|
||||
|
||||
.db "/MOD"
|
||||
.fill 3
|
||||
.dw MULT
|
||||
.db 0
|
||||
DIV:
|
||||
DIVMOD:
|
||||
.dw nativeWord
|
||||
pop de
|
||||
pop hl
|
||||
call divide
|
||||
push hl
|
||||
push bc
|
||||
jp next
|
||||
|
||||
; ( a1 a2 -- b )
|
||||
.db "SCMP"
|
||||
.fill 3
|
||||
.dw DIV
|
||||
.dw DIVMOD
|
||||
.db 0
|
||||
SCMP:
|
||||
.dw nativeWord
|
||||
|
@ -121,6 +121,8 @@ H -- a HERE @
|
||||
-^ a b -- c b - a -> 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 ***
|
||||
= n1 n2 -- f Push true if n1 == n2
|
||||
|
Loading…
Reference in New Issue
Block a user