Chapter 3

ANS Forth Words in P21Forth


P21Forth 1.02 is an ANS Forth system for the MuP21 Microprocessor.

Providing the Core word set
Providing the Core Extension word set
Providing the Exception word set
Providing the Double word set
Providing the Double Extension word set
Providing the Search-Order word set
Providing the Search-Order Extension word set
Providing the Facility word set
Providing the Tools word set
Providing the Block word set
Providing the Block Extension word set

The American National Standard X3.215-1994 document clearly describes each of the standard ANS Forth words in each of the word sets implemented in P21Forth. Refer to this document for details of the ANS standard words in P21Forth.

The P21Forth word ENV. will display environmental information about the details of the ANS standard implementation. ENV. exercises the ANS standard word ENVIRONMENT?. ENV. displays the following if the number base is in HEX:

CORE FOUND SET PRESENT
CORE-EXT FOUND SET PRESENT
/HOLD FOUND 50
/PAD FOUND 50
/COUNTED-STRING FOUND FFFFF
ADDRESS-UNIT-BITS FOUND 14
STACK-CELLS FOUND 3A
RETURN-STACK-CELLS FOUND 40
FLOORED FOUND FFFFF
MAX-N FOUND 7FFFF
MAX-U FOUND FFFFF
MAX-CHAR FOUND FFFFF
MAX-D FOUND 7FFFFFFFFF
MAX-UD FOUND FFFFFFFFFF
EXCEPTION FOUND SET PRESENT
DOUBLE FOUND SET PRESENT
DOUBLE-EXT FOUND SET PRESENT
SEARCH-ORDER FOUND SET PRESENT
SEARCH-ORDER-EXT FOUND SET PRESENT
WORDLISTS FOUND 8
STRING FOUND SET NOT PRESENT
STRING-EXT FOUND SET NOT PRESENT
FACILITY FOUND SET PRESENT
FACILITY-EXT FOUND SET NOT PRESENT
TOOLS FOUND SET PRESENT
TOOLS-EXT FOUND SET NOT PRESENT
BLOCK FOUND SET PRESENT
BLOCK-EXT FOUND SET PRESENT
In this example the word `FOUND' means the keyword was found in the environmental query. If it is a word SET it will be shown as PRESENT and complete or NOT PRESENT. If it is a quantity such as the largest unsigned number in this implementation the number will be displayed.

ENV. is not compiled at boot time in P21Forth 1.02. Instead in the HEX number base type 40 43 THRU HEX ENV. to see the ENV. demo.

ANS Forth WORDS in P21Forth 1.02

UNUSED ENVIRONMENT? ENDCASE ENDOF OF CASE WORD NEXT FOR BOUNDS J I LEAVE UNLOOP +LOOP LOOP ?DO DO +loop loop ?do do FIND EXPECT SPAN CONVERT -ROLL ROLL ALIAS WWORDS LSHIFT RSHIFT M*/ M*/MOD TU/MOD TU* DU. DU.R D2/ DU2/ D2* MU/MOD */ */MOD M/ M* M- M+ DMAX DMIN DU< D< D= D0= D- D0> D0< 2ROT 2OVER 2SWAP 2R@ 2R> 2>R 2VARIABLE 2CONSTANT 2LITERAL 2LIT UMAX UMIN -ROT TUCK NIP U> > SM/REM 0<> 0> ERASE BLANK DV! VVALUE DDEFER 'ADR TO VALUE IS DEFER [CHAR] ['] COMPILE [COMPILE] C" @EXECUTE FORTH VOCABULARY SEAL ALSO PREVIOUS ONLY ORDER VOCS THRU LOAD LIST SCR BLOCK BUFFER FLUSH SAVE-BUFFERS \ EMPTY-BUFFERS REFILL UPDATE RESTORE-INPUT SAVE-INPUT BYE PAGE SEE >BODY >NAME WORDS .ID DUMP .S REPEAT AGAIN UNTIL WHILE ELSE AHEAD IF MARK RESOLVE THEN BEGIN MARKER SET-ORDER GET-ORDER WORDLIST VLINK FORTH-WORDLIST USER CONSTANT VARIABLE DOES> CREATE ; : :NONAME POSTPONE RECURSE COMPILE-ONLY IMMEDIATE LAST ?UNIQUE ] DEFINITIONS SET-CURRENT GET-CURRENT CURRENT S" ." ABORT" ,C" \ ( .( PARSE CHAR LITERAL COMPILE, , C, ALLOT ' QUIT EVALUATE SOURCE-ID BLK DELIMIT SOURCE [ CONTEXT WID? SAME? NAME> ?STACK abort" ABORT THROW CATCH ACCEPT ? . U. D. .R U.R D.R S.R CR TYPE SPACES SPACE .CHARS SIGN #> #S # HOLD DIGIT <# NUMBER? >NUMBER PACK -TRAILING FILL PICK AT-XY KEY UM* / MOD /MOD FM/MOD UM/MOD DABS WITHIN MIN MAX < U< BL 2 1 ! UP CMOVE 2! 2@ DECIMAL HEX * PAD HERE DP #IN >IN BASE DPL CSP HLD STATE ?KEY EMIT DEPTH >CHAR COUNT+! ABS DNEGATE D+ ROT D2* 2* U2/ 2/ ALIGNED ALIGN CELLS CHARS = - NEGATE INVERT NOT 2DUP 2DROP ?DUP 2- 1- 2+ CELL+ 1+ CHAR+ 0 FALSE -2 -1 TRUE + UM+ XOR OR AND 0= 0< S>D SWAP OVER DUP DROP SP! SP@ R> R@ >R RP! RP@ @ C@ ! C! EXECUTE EXIT


End of Chapter 3

Return to Table of Contents

Previous Chapter

Next Chapter