1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
|
UNFINISHED
Manual for pForth - a Portable Forth
The best reference for pForth is an ANSI Forth manual. pForth
is built on an ANSI model. There are, however, some non-standard
words which are documented here:
{ ( i*x -- , declare local variables )
Local variables are only usable within a colon definition.
They are taken from the stack as they are defined.
They are self fetching. Use -> to set them.
They help you avoid excessive stack dancing.
Here is an example:
: SUMSQ { aa bb -- }
aa aa *
bb bb * +
;
3 4 SUMSQ . ( prints 25 )
Here is an example of using a temporary variable:
: SUMN { num | sum -- , sum up integers the dumb way }
0 -> sum \ uses -> to set local variable
num 0
DO i sum +
-> sum \ write current TOS to sum
LOOP
sum
;
:STRUCT ( <name> -- , defines a 'C' like structure )
See end of "c_struct.fth" for an example.
ANEW ( <name> -- )
Forgets NAME if it is already defined.
Then defines NAME. Put at beginning of file
so that file can be INCLUDEd multiple times
without redefining the contents.
CASE OF ENDOF ENDCASE in the typical fashion. See "case.fth"
CHOOSE ( range -- random , pick random number, 0...range-1 )
IF ELSE THEN DO LOOP etc. can be used outside colon definitions!
IF.FORGOTTEN ( <name> -- , executes NAME if forgotten )
Put this at the end of a file to automatically
call your cleanup word if the code is forgotten.
INCLUDE ( <filename> -- , interpret from file )
Write your Forth programs in a file then load them
using INCLUDE.
INCLUDE myprog.fth
INCLUDE? ( <name> <filename> -- , interpret from file if needed )
INCLUDE the given file only if the named word is undefined.
The name should be of a Forth word defined in the file.
See "load_pforth.fth" for an example.
INCLUDE? DO.MY.PROG myprog.fth
MAP ( -- , dumps info about dictionary )
Other words
FP.INIT
FP.TERM
F>S
S>F
EXISTS?
STRINGS=
S@
S!
;STRUCT
:STRUCT
STRUCT
ULONG
RPTR
APTR
FLPT
USHORT
UBYTE
LONG
SHORT
BYTE
BYTES
SIZEOF()
OB.STATS?
OB.STATS
OB.FINDIT
OB.MEMBER
}UNION
}UNION{
UNION{
OB.MAKE.MEMBER
MAP
.HEX
.DEC
.BIN
ARRAY
WARRAY
BARRAY
-2SORT
2SORT
WCHOOSE
CHOOSE
RANDOM
RAND-SEED
MSEC
MSEC-DELAY
VALUE
->
TO
-- strings --
TEXTROM
$ROM
$APPEND.CHAR
INDEX
$MATCH?
TEXT=?
TEXT=
$=
COMPARE
$ARRAY
-- case --
ENDCASE ENDOF RANGEOF (RANGEOF?) OF
?OF CASE OF-DEPTH CASE-DEPTH
TOLOWER
@EXECUTE
>NAME
CLOSEST-XT
CLOSEST-NFA
TAB
TAB-WIDTH
.HX
$
CR?
#COLS
?PAUSE
ABORT"
WARNING"
CELL*
<<
>>
TASK-MISC1.FTH .R . (.)
(NUMBER?)
((NUMBER?)) NUM_TYPE_DOUBLE NUM_TYPE_SINGLE
NUM_TYPE_BAD >NUMBER DIGIT
ANEW FORGET [FORGET] IF.FORGOTTEN
SAVE-FORTH
INCLUDE?
RI
INCLUDE
$INCLUDE
$APPEND
LWORD
PARSE
PARSE-WORD
PLACE
WHAT'S
IS
DEFER
>NEWLINE
0SP
SPACES
SPACE
RECURSE
UNLOOP
-- user stack --
0USP
US@ US> >US USTACK 0STACKP STACK@
STACK> >STACK :STACK
-- address storage and translation --
A, A@ A!
IF.REL->USE IF.USE->REL
X! X@
>ABS >REL REL->USE USE->REL
BODY> >BODY N>LINK CODE> >CODE NAME>
NAMEBASE+ CODEBASE NAMEBASE
N>NEXTLINK >NAME
PREVNAME NAME>
ID.
OFF ON
TRACE-STACK
TRACE-LEVEL
TRACE-FLAGS
HEADERS-BASE
HEADERS-PTR
ECHO
CODE-BASE
POP-SOURCE-ID
PUSH-SOURCE-ID
SOURCE-ID
SET-SOURCE
SOURCE
LOADSYS
FLUSHEMIT
FINDNFA
BYE
BODY_OFFSET
BAIL
ARSHIFT
|