3 Manual for pForth - a Portable Forth
\r
5 The best reference for pForth is an ANSI Forth manual. pForth
\r
6 is built on an ANSI model. There are, however, some non-standard
\r
7 words which are documented here:
\r
9 { ( i*x -- , declare local variables )
\r
10 Local variables are only usable within a colon definition.
\r
11 They are taken from the stack as they are defined.
\r
12 They are self fetching. Use -> to set them.
\r
13 They help you avoid excessive stack dancing.
\r
16 : SUMSQ { aa bb -- }
\r
20 3 4 SUMSQ . ( prints 25 )
\r
22 Here is an example of using a temporary variable:
\r
24 : SUMN { num | sum -- , sum up integers the dumb way }
\r
25 0 -> sum \ uses -> to set local variable
\r
28 -> sum \ write current TOS to sum
\r
33 :STRUCT ( <name> -- , defines a 'C' like structure )
\r
34 See end of "c_struct.fth" for an example.
\r
37 Forgets NAME if it is already defined.
\r
38 Then defines NAME. Put at beginning of file
\r
39 so that file can be INCLUDEd multiple times
\r
40 without redefining the contents.
\r
42 CASE OF ENDOF ENDCASE in the typical fashion. See "case.fth"
\r
44 CHOOSE ( range -- random , pick random number, 0...range-1 )
\r
46 IF ELSE THEN DO LOOP etc. can be used outside colon definitions!
\r
48 IF.FORGOTTEN ( <name> -- , executes NAME if forgotten )
\r
49 Put this at the end of a file to automatically
\r
50 call your cleanup word if the code is forgotten.
\r
52 INCLUDE ( <filename> -- , interpret from file )
\r
53 Write your Forth programs in a file then load them
\r
58 INCLUDE? ( <name> <filename> -- , interpret from file if needed )
\r
59 INCLUDE the given file only if the named word is undefined.
\r
60 The name should be of a Forth word defined in the file.
\r
61 See "load_pforth.fth" for an example.
\r
63 INCLUDE? DO.MY.PROG myprog.fth
\r
65 MAP ( -- , dumps info about dictionary )
\r
132 ENDCASE ENDOF RANGEOF (RANGEOF?) OF
\r
133 ?OF CASE OF-DEPTH CASE-DEPTH
\r
153 TASK-MISC1.FTH .R . (.)
\r
155 ((NUMBER?)) NUM_TYPE_DOUBLE NUM_TYPE_SINGLE
\r
156 NUM_TYPE_BAD >NUMBER DIGIT
\r
158 ANEW FORGET [FORGET] IF.FORGOTTEN
\r
184 US@ US> >US USTACK 0STACKP STACK@
\r
185 STACK> >STACK :STACK
\r
187 -- address storage and translation --
\r
189 IF.REL->USE IF.USE->REL
\r
191 >ABS >REL REL->USE USE->REL
\r
192 BODY> >BODY N>LINK CODE> >CODE NAME>
\r
193 NAMEBASE+ CODEBASE NAMEBASE
\r