1 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ;; and now
for something completely different
...
3 ;; UrForth
/C Forth Engine
!
4 ;; Copyright
(C
) 2023 Ketmar Dark
// Invisible Vector
6 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 ;; define some standard words
10 ;; note that UFO starts without colon
, conditionals and loops
!
13 $INCLUDE
-ONCE
<01-colon
-semicolon
.f
>
14 $INCLUDE
-ONCE
<10-mem
-utils
.f
>
15 $INCLUDE
-ONCE
<20-base
-creatori
.f
>
16 $INCLUDE
-ONCE
<25-scolon
.f
>
17 $INCLUDE
-ONCE
<30-ifthen
.f
>
18 $INCLUDE
-ONCE
<35-num
-print
.f
>
19 $INCLUDE
-ONCE
<40-voc
-creatori
.f
>
20 $INCLUDE
-ONCE
<50-defer_value
.f
>
21 $INCLUDE
-ONCE
<70-replace
.f
>
22 \ $INCLUDE
-ONCE
<80-locals
.f
>
23 $INCLUDE
-ONCE
<90-cond
-comp
.f
>
24 $INCLUDE
-ONCE
<92-cond
-if.f
>
27 $
IF $UFO
-DEBUG
-STARTUP
-TIMES
28 GET
-MSECS SWAP
- .( UrForth bootstrap time
: ) . .( msecs
\n)
34 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
35 $
IF $UFO
-BOOTSTRAP
-TESTS
36 .( >>> CASE TEST
<<<\n)
39 8 OF
." This is 8" CR ENDOF
40 12 OF
." This is 12" CR ENDOF
41 99 OF
." This is 99" CR ENDOF
42 ( note that you
*HAVE*
to DUP it
)
43 ( ENDCASE will
call DROP
)
44 ( so
if you want
to leave something on the stack
, )
45 ( make sure that TOS is garbage
to be dropped
)
48 ." The number is: " . CR
59 .( >>> CASE TEST COMPLETE
<<<\n)
61 .( >>> FOR TEST
<<<\n)
64 I
2 = IF CONTINUE ENDIF
69 DEBUG
:DECOMPILE testfor
71 .( >>> FOR TEST COMPLETE
<<<\n)
73 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
75 : aa
3 cells
" 3 cells: " TYPE
. cr
;
81 0 10 DO I
. CR
-1 +LOOP CR
83 \ DEBUG
:DECOMPILE test02
88 11 1 DO I
. CR LOOP CR
89 -11 -1 DO I
. CR
-1 +LOOP CR
91 0 -10 DO I
. CR LOOP CR
94 \ DEBUG
:DECOMPILE test01
98 : e1
." E1!\n" ['] e2 execute ." after EXEC! num: " . cr ;
99 : e0 ." E0!\n" ['] e2 execute
-tail
." ERROR: after EXEC! num: " . cr
;
105 .( === EXEC NATIVE
===\n)
106 60 9 ' + EXECUTE . cr
107 : e3 60 9 ['] + EXECUTE
-TAIL
." ERROR: after EXEC! num: " . cr
;