1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ;; UrForth level
1: self
-hosting
32-bit Forth compiler
3 ;; Copyright
(C
) 2020 Ketmar Dark
// Invisible Vector
5 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7 code: = ( n0 n1 -- n0=n1? )
15 code: <> ( n0 n1 -- n0<>n1? )
23 code: < ( n0 n1 -- n<n1? )
31 code: > ( n0 n1 -- n0>n1? )
39 code: <= ( n0 n1 -- n<=n1? )
47 code: >= ( n0 n1 -- n0>=n1? )
55 code: U< ( u0 u1 -- u0<u1? )
63 code: U> ( u0 u1 -- u0>u1? )
71 code: U<= ( u0 u1 -- u0<=u1? )
79 code: U>= ( u0 u1 -- u0>=u1? )
88 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
90 code: 0= ; ( n0 -- n=0? )
98 code: 0<> ( n0 -- n<>0? )
105 code: 0< ( n0 -- n<0? )
112 code: 0> ( n0 -- n>0? )
119 code: 0<= ( n0 -- n<=0? )
126 code: 0>= ( n0 -- n>=0? )
134 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
136 : BOUNDS
( addr count
-- addr
+count addr
) over
+ swap
;
139 ;; : WITHIN
( n a b
-- flag
) over
- >r
- r
> u
< ;
142 code: WITHIN ( n a b -- flag )
150 neg TOS
;; because our
"true" is
1, not
-1
154 ;; u
>= ua and u
<= ub
(unsigned compare
)
155 code: BOUNDS? ( u ua ub -- flag )
169 code: CLAMP ( u ua ub -- u-clamped )
183 code: UCLAMP ( u ua ub -- u-clamped )
198 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
199 ;; the following words are used in various CASE
-OF
202 code: (OF=) ( n0 n1 -- n0 n0=n1 )
211 code: (OF<>) ( n0 n1 -- n0 n0<>n1? )
220 code: (OF<) ( n0 n1 -- n0 n0<n1 )
229 code: (OF>) ( n0 n1 -- n0>n1? )
238 code: (OF<=) ( n0 n1 -- n<=n1? )
247 code: (OF>=) ( n0 n1 -- n0>=n1? )
256 code: (OF-U<) ( u0 u1 -- u0<u1? )
265 code: (OF-U>) ( u0 u1 -- u0>u1? )
274 code: (OF-U<=) ( u0 u1 -- u0<=u1? )
283 code: (OF-U>=) ( u0 u1 -- u0>=u1? )
293 code: (OF-AND) ( n0 n1 -- n0 n0&n1 )
301 code: (OF-~AND) ( n0 n1 -- n0&~n1 )
311 code: (OF-WITHIN) ( n a b -- a flag )
319 neg TOS
;; because our
"true" is
1, not
-1
324 ;; u
>= ua and u
<= ub
(unsigned compare
)
325 code: (OF-BOUNDS) ( u ua ub -- n flag )