2020-03-13 12:49:10 +11:00
|
|
|
: H HERE @ ;
|
|
|
|
: -^ SWAP - ;
|
2020-03-12 15:14:44 +11:00
|
|
|
: +! SWAP OVER @ + SWAP ! ;
|
|
|
|
: ALLOT HERE +! ;
|
2020-03-13 12:49:10 +11:00
|
|
|
: , H ! 2 ALLOT ;
|
|
|
|
: C, H C! 1 ALLOT ;
|
2020-03-15 00:23:58 +11:00
|
|
|
: NOT 1 SWAP SKIP? EXIT 0 * ;
|
2020-03-14 10:33:16 +11:00
|
|
|
: RECURSE R> R> 2 - >R >R EXIT ;
|
2020-03-15 00:23:58 +11:00
|
|
|
: ( LIT@ ) WORD SCMP NOT SKIP? RECURSE ; IMMEDIATE
|
2020-03-14 10:33:16 +11:00
|
|
|
( Hello, hello, krkrkrkr... do you hear me? )
|
|
|
|
( Ah, voice at last! Some lines above need comments )
|
2020-03-15 00:23:58 +11:00
|
|
|
( BTW: Forth lines limited to 64 cols because of default )
|
|
|
|
( input buffer size in Collapse OS )
|
|
|
|
( NOT: a bit convulted because we don't have IF yet )
|
2020-03-14 10:33:16 +11:00
|
|
|
( RECURSE: RS TOS is for RECURSE itself, then we have to dig )
|
|
|
|
( one more level to get to RECURSE's parent's caller. )
|
2020-03-15 00:23:58 +11:00
|
|
|
( IF true, skip following (fbr). Also, push br cell ref H, )
|
|
|
|
( to PS )
|
|
|
|
: IF ['] SKIP? , ['] (fbr) , H 1 ALLOT ; IMMEDIATE
|
|
|
|
( Subtract TOS from H to get offset to write to IF or ELSE's )
|
|
|
|
( br cell )
|
|
|
|
: THEN DUP H -^ SWAP C! ; IMMEDIATE
|
|
|
|
( write (fbr) addr, allot, then same as THEN )
|
|
|
|
: ELSE ['] (fbr) , 1 ALLOT DUP H -^ SWAP C! H 1 - ; IMMEDIATE
|
2020-03-14 10:33:16 +11:00
|
|
|
: ? @ . ;
|
|
|
|
: VARIABLE CREATE 2 ALLOT ;
|
|
|
|
: CONSTANT CREATE H ! DOES> @ ;
|
2020-03-12 15:14:44 +11:00
|
|
|
: = CMP NOT ;
|
|
|
|
: < CMP 0 1 - = ;
|
|
|
|
: > CMP 1 = ;
|