2020-03-12 21:49:10 -04:00
|
|
|
: H HERE @ ;
|
|
|
|
: -^ SWAP - ;
|
2020-03-12 00:14:44 -04:00
|
|
|
: +! SWAP OVER @ + SWAP ! ;
|
|
|
|
: ALLOT HERE +! ;
|
2020-03-12 21:49:10 -04:00
|
|
|
: , H ! 2 ALLOT ;
|
|
|
|
: C, H C! 1 ALLOT ;
|
2020-03-15 22:46:17 -04:00
|
|
|
: BEGIN H ; IMMEDIATE
|
2020-03-16 21:31:43 -04:00
|
|
|
: COMPILE ' ['] LITN EXECUTE ['] , , ; IMMEDIATE
|
|
|
|
: AGAIN COMPILE (bbr) H -^ C, ; IMMEDIATE
|
2020-03-14 09:23:58 -04:00
|
|
|
: NOT 1 SWAP SKIP? EXIT 0 * ;
|
2020-03-15 22:46:17 -04:00
|
|
|
: ( BEGIN LITS ) WORD SCMP NOT SKIP? AGAIN ; IMMEDIATE
|
2020-03-14 19:10:39 -04:00
|
|
|
( Hello, hello, krkrkrkr... do you hear me?
|
|
|
|
Ah, voice at last! Some lines above need comments
|
|
|
|
BTW: Forth lines limited to 64 cols because of default
|
|
|
|
input buffer size in Collapse OS
|
2020-03-16 21:31:43 -04:00
|
|
|
|
|
|
|
COMPILE; Tough one. Get addr of caller word (example above
|
|
|
|
(bbr)) and then call LITN on it. However, LITN is an
|
|
|
|
immediate and has to be indirectly executed. Then, write
|
|
|
|
a reference to "," so that this word is written to HERE.
|
|
|
|
|
|
|
|
NOT: a bit convulted because we don't have IF yet )
|
|
|
|
: IF COMPILE SKIP? COMPILE (fbr) H 1 ALLOT ; IMMEDIATE
|
2020-03-14 19:10:39 -04:00
|
|
|
( Subtract TOS from H to get offset to write to IF or ELSE's
|
|
|
|
br cell )
|
2020-03-14 09:23:58 -04:00
|
|
|
: THEN DUP H -^ SWAP C! ; IMMEDIATE
|
|
|
|
( write (fbr) addr, allot, then same as THEN )
|
2020-03-16 21:31:43 -04:00
|
|
|
: ELSE
|
|
|
|
COMPILE (fbr) 1 ALLOT DUP H -^ SWAP C! H 1 - ; IMMEDIATE
|
2020-03-13 19:33:16 -04:00
|
|
|
: ? @ . ;
|
|
|
|
: VARIABLE CREATE 2 ALLOT ;
|
|
|
|
: CONSTANT CREATE H ! DOES> @ ;
|
2020-03-12 00:14:44 -04:00
|
|
|
: = CMP NOT ;
|
|
|
|
: < CMP 0 1 - = ;
|
|
|
|
: > CMP 1 = ;
|