This appendix is here to help you define some of the words referred to in this book that may not exist in your system. Definitions are given in Forth-83 Standard.
A definition of ASCII
that will work in ’83 Standard is:
: ASCII ( -- c) \ Compile: c ( -- )
\ Interpret: c ( -- c)
BL WORD 1+ C@ STATE @
IF [COMPILE] LITERAL THEN ; IMMEDIATEThe word \
can be defined as:
: \ ( skip rest of line)
>IN @ 64 / 1+ 64 * >IN ! ; IMMEDIATEIf you decide not to use EXIT to terminate a
screen, you can define \S as:
: \S 1024 >IN ! ;The word FH can be
defined simply as:
: FH \ ( offset -- offset-block) "from here"
BLK @ + ;This factoring allows you to use FH in many ways, e.g.:
: TEST [ 1 FH ] LITERAL LOAD ;or
: SEE [ 2 FH ] LITERAL LIST ;A slightly more complicated version of FH also lets you edit or load a
screen with a phrase such as “14 FH LIST,” relative to the screen that
you just listed (SCR):
: FH \ ( offset -- offset-block) "from here"
BLK @ ?DUP 0= IF SCR @ THEN + ;BL is a
simple constant:
32 CONSTANT BLTRUE and
FALSE can be defined
as:
0 CONSTANT FALSE
-1 CONSTANT TRUE(Forth’s control words such as IF and UNTIL interpret zero as “false”
and any non-zero value as “true.” Before Forth ’83, the convention was
to indicate “true” with the value 1. Starting with Forth ’83,
however, “true” is indicated with hex FFFF, which is the signed number -1 (all bits set).
WITHIN can be defined
in high level like this:
: WITHIN ( n lo hi+1 -- ?)
>R 1- OVER < SWAP R> < AND ;or
: WITHIN ( n lo hi+1 -- ?)
OVER - >R - R> U< ;The implementation of
LEAP will depend on how
your system implements DO LOOP s. If DO keeps two items
on the return stack (the index and the limit),
LEAP must drop both of them plus one more
return-stack item to exit:
: LEAP R> R> 2DROP R> DROP ;If DO keeps three items on the return stack, it
must be defined:
: LEAP R> R> 2DROP R> R> 2DROP ;