mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-23 22:38:06 +11:00
cmp: fix & and | logic
It simply didn't work before, except for =.
This commit is contained in:
parent
74a32db5cc
commit
fca0e79da3
40
forth/cmp.fs
40
forth/cmp.fs
@ -6,25 +6,33 @@
|
|||||||
( n1 f -- f )
|
( n1 f -- f )
|
||||||
: <>} SWAP DROP ;
|
: <>} SWAP DROP ;
|
||||||
|
|
||||||
( n1 f n2 -- n1 cmp )
|
|
||||||
: |CMP
|
: _|&
|
||||||
SWAP IF DROP 1 EXIT THEN ( n1 true )
|
( n1 n2 cell )
|
||||||
OVER SWAP ( n1 n1 n2 )
|
>R >R DUP R> R> ( n1 n1 n2 cell )
|
||||||
CMP
|
@ EXECUTE ( n1 f )
|
||||||
;
|
;
|
||||||
|
|
||||||
: &CMP
|
( n1 f n2 -- n1 f )
|
||||||
SWAP NOT IF DROP 0 EXIT THEN ( n1 false )
|
: _|
|
||||||
OVER SWAP ( n1 n1 n2 )
|
CREATE , DOES>
|
||||||
CMP
|
( n1 f n2 cell )
|
||||||
|
ROT IF 2DROP 1 EXIT THEN ( n1 true )
|
||||||
|
_|&
|
||||||
|
;
|
||||||
|
|
||||||
|
: _&
|
||||||
|
CREATE , DOES>
|
||||||
|
( n1 f n2 cell )
|
||||||
|
ROT NOT IF 2DROP 0 EXIT THEN ( n1 true )
|
||||||
|
_|&
|
||||||
;
|
;
|
||||||
|
|
||||||
( All words below have this signature:
|
( All words below have this signature:
|
||||||
n1 f n2 -- n1 f )
|
n1 f n2 -- n1 f )
|
||||||
: |= |CMP NOT ;
|
' = _| |=
|
||||||
: &= &CMP NOT ;
|
' = _& &=
|
||||||
: |< |CMP -1 = ;
|
' > _| |>
|
||||||
: &< &CMP -1 = ;
|
' > _& &>
|
||||||
: |> |CMP 1 = ;
|
' < _| |<
|
||||||
: &> &CMP 1 = ;
|
' < _& &<
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user