Starting Words Numbers refer to pages in Leo Brodie, Starting Forth, 2nd Edition. ! ( n a -- ) Store number at address. 174 " string" ( -- a n) Text string constant. 253Ð54 # ( du -- du2) Generate next digit of output string. 154 #> ( du -- a n) Complete output string. 154 #LINE ( -- a) Address having line number. (Was L# .) #OUT ( -- a) Address having # of chars since last CR. (Was C# .) #PAGE ( -- a) Address having page number. (Was P# .) #S ( du -- 0.) Generate remaining digits for output. 154 #TIB ( -- a) Address having # of chars received by last QUERY. ' xxx ( -- cfa) Address of xxx. (In older systems: -- pfa) 199 ( comment) ( -- ) (Immediate.) Comment. 26 (.) ( n -- a len) Format n without typing. S>D <# #S #> (LITERAL) ( Compiling: n -- ; Later: -- n) 274 * ( n n2 -- product) 29 *. ( n n -- n2) +1 */ 110Ð12 */ ( n n2 n3 -- n*n2/n3) 103 */MOD ( n n2 n3 -- remainder n*n2/n3) 107 + ( n n2 -- sum) 26 +! ( n a -- ) DUP @ UNDER+ ! 174 +1 ( -- n) 16384 210Ð12 +LOOP DO ... incr +LOOP 131 +STICK ( n[m] n[m-1] ... n0 x m -- n[m]+x n[m-1] ... n0) +UNDER ( n n2 n3 -- n+n3 n2) ROLL + SWAP (AKA UNDER+ .) , ( n -- ) Store number in user's dictionary. 190 ," ( -- ) Compile string. (S-F has ASCII " STRING .) 256 - ( n n2 -- difference) 29 --> ( -- ) (Immediate.) Continued on next block. -MATCH ( a n s n -- a flag) 251 -ROT ( n n2 n3 -- n3 n n2) SWAP >R SWAP R> (Was ( n -- n>0) 92 1+ ( n -- n+1) 96 1- ( n -- n-1) 96 1K ( -- n) The size of a source block (i.e., 1024). 2! ( d a -- ) Store doublenumber at address. 177 2* ( n -- n*2) DUP + 96 2+ ( n -- n+2) 96 2- ( n -- n-2) 96 2/ ( n -- n/2) 96 2>R ( n n2 -- ; R: -- n n2) SWAP >R >R 2@ ( a -- d) Doublenumber value at address. 177 2CONSTANT xx ( d -- ; Does: d) Define doublenumber constant. 177 2DROP ( n n2 -- ) DROP DROP 48 2DUP ( n n2 -- n n2 n n2) OVER OVER 48 2OVER ( n n2 n3 n4 -- n n2 n3 n4 n n2) OVER3 OVER3 48 2R> ( -- n n2; R: n n2 -- ) R> R> SWAP 2ROT ( n n2 n3 n4 n5 n6 -- n3 n4 n5 n6 n n2) 5 ROLL 5 ROLL 2SWAP ( n n2 n3 n4 -- n3 n4 n n2) ROT >R ROT R> 48 2VARIABLE xxx ( -- ; Does: -- pfa) Define doublenumber storage. 177 3DROP ( n n2 n3 -- ) 2DROP DROP 3DUP ( n n2 n3 -- n n2 n3 n n2 n3) OVER2 OVER2 OVER2 50(Probs) 4DROP ( n n2 n3 n4 -- ) 2DROP 2DROP 4DUP ( n n2 n3 n4 -- n n2 n3 n4 n n2 n3 n4) 2OVER 2OVER : xxx ... ( -- ) Start colonÐdefinition 26 ; ( -- ) Finish colon-definition. 26 < ( n n2 -- n ( n n2 -- n<>n2) (Old timers generally use - .) 92 = ( n n2 -- n=n2) - 0= 92 > ( n n2 -- n>n2) 92 >< ( c1c2 -- c2c1) Exchange high- and low-bytes. (F83 FLIP .) >BODY ( cfa -- pfa) Find pfa of given compilation address. 210 >IN ( -- a) Address having char offset within input stream 246 >R ( n -- ; R: -- n) (Compile-only.) 99 >TYPE ( a n -- ) Move string to PAD and TYPE it. 232 ? ( a -- ) Display contents at address. @ . 174 ?DO ( n2 n -- ) (Compile-only, immediate.) 120 ?DUP ( n -- n n -or- n) DUP IF DUP THEN 92 ?LEAVE ( f -- ) (Compile-only, immediate) IF LEAVE THEN @ ( a -- n) Value at address. 174 @EXECUTE ( a -- any) ?DUP IF @ EXECUTE THEN 199 ABORT ( -- ) Clear stack and quit. 210 ABORT" oops" ( f -- ) (Compile-only, immediate.) 92 ABS ( n -- magnitude) 97 AGAIN BEGIN ... 0 UNTIL 127 ALLOT ( n -- ) Reserve n bytes in user's dictionary. 181 ALSO ( -- ) Duplicate the first vocabulary in the search order. AND ( n n2 -- and) 92 ARGUMENTS ( n -- ) DEPTH U< NOT ABORT" Values?" 208 ASSEMBLER ( -- ) 221 ASCII c ( -- c) (Immediate.) Char literal. 144 BASE ( -- a) Address having active conversion radix. 169Ð70 BASED. xxx ( n -- ; Does: n -- ) Create printing word. 287(Probs) BEEP ( -- ) Sound audible alarm. BEGIN (Compile-only, immediate.) 131 BETWEEN ( n n2 n3 -- n2<=n<=n2) 1+ WITHIN BINARY ( -- ) 2 BASE ! 149 BL ( -- n) Value of the space char (i.e, 32). 237 BLANK ( a n -- ) Fill string with space chars. BL FILL 237 BLK ( -- a) Address having # of block being interpreted. 246 BLOCK ( u -- adr) Address to use for block u. 230 BOUNDS ( n n2 -- n+n2 n) OVER + SWAP BUFFER ( u -- adr) Address to use for block u. 230 C! ( n a -- ) Store byte at address. 188 C+! ( n a -- ) Add 8-bit value to value at address. C, ( n -- ) Store byte in user's dictionary. 190 C/L ( -- n) The length of a source block line (usually 64). C@ ( a -- c) Byte value at address. 188 CARRAY ( n -- ; Does: i -- a) (S-F has ARRAY .) 266 CASE? ( a b -- true -or- a 0) OVER = IF DROP TRUE ELSE 0 THEN CELL ( -- n) # of address units in a cell. CELL+ ( n -- n') CELL + CELLS ( n -- n2) CELL * CHOOSE ( u -- u2) Random number < u. 235 CHR ( -- a) Address having active editing cursor position. (Was R# .) CMATRIX ( n n2 -- ; Does: i i2 -- a) (S-F has MATRIX .) 267 CMOVE ( a a2 n -- ) Move data from a to a2. 236 CMOVE> ( a a2 n -- ) Move from a+n-1. (Was BINARY .) 246 COPY ( source target -- ) Copy one block to another. 78 COUNT ( a -- a+1 c) Counted string to text string. 243 CR ( -- ) Display newline or equivalent. 26 CREATE xxx ( -- ; Does: -- pfa) Define next address. 181 CTRL c ( -- c) (F83 CONTROL .) CURRENT ( -- a) Points to vocabulary for definitions. 221 D+ ( d d2 -- sum) 157 D- ( d d2 -- difference) DNEGATE D+ 157 D. ( d -- ) Display doublenumber. 150 D.R ( d n -- ) Display doublenumber right justified. 157 D0= ( d -- d=0.) OR 0= 157 D2* ( d -- s1*2) 2DUP D+ D2/ ( d -- d/2) D< ( d d2 -- d ( -- a) (Compile-only, immediate.) 264 dot" ( -- ) (Compiled by ." .) (AKA (.") .) 273 DP ( -- a) Address having last dict. position. (AKA H .) 216 DPL ( -- a) Address having decimal point length. (Was PTR .) 192 DROP ( n -- ) 43 DROPS ( n n2 n3 ... n[m-1] m -- ) ?DUP IF 0 DO DROP LOOP THEN DU. ( du -- ) (S-F has UD. ) 151 DU< ( du du2 -- du DROP 210 EXPECT ( a n -- ) Receive up to n "cooked" chars at a. 240 FALSE ( -- n) Standard false value (i.e., 0). 176 FH ( n -- u) Relative block #. FILL ( a n c -- ) Fill string with char "c". 182 FIND ( adr1 -- cfa 1 or cfa -1 or adr1 0) Search dictionary. FLUSH ( -- ) SAVE-BUFFERS EMPTY-BUFFERS. 230 FORGET xxx ( -- ) Forget back through "xxx" in dictionary. 57 FORTH ( -- ) (Not immediate.) 221 FORTH-83 ( -- ) Load Forth-83 words not already defined. H. ( u -- ) Display number using base 16. HERE ( -- a) Address having next dictionary location. 216 HEX ( -- ) 16 BASE ! 148 HOLD ( c -- ) Generate char "c" in output string. 154 I ( -- loopindex) (Not the same as R@ .) 119Ð20 I' ( -- looplimit) (Might not be available. Don't use.) IF ( f -- ) (Compile-only, immediate.) 92 IMMEDIATE ( -- ) Mark most recently compiled word as immediate. 273 INDEX ( f l -- ) Display first lines in range of blocks. 62 INTERPRET ( any -- any) Begin text interpretation of input stream. 283 IS xxx ( n -- ) Redefine the parameter field of a CREATEd word. J ( -- 2nd innermost loopindex) 123 K ( -- 3rd innermost loopindex) (Might not be available.) KEY ( -- c) Receive a "raw" char. 240 KEY? ( -- f) Check for keyboard attention. (AKA ?TERMINAL .) 238 L/BLOCK ( -- n) The number of lines in a block (usually 16). LEAP ( -- ) Exit inside a single DO-loop. UNLOOP EXIT (Obsolete.) LEAVE ( -- ) (Compile-only, immediate.) Terminate loop. 131 LIT" string" ( -- a) Address of counted string. 256 LIST ( u -- ) Display block u. 57 LITERAL ( n -- ; Later: -- n) (Compile-only, immediate.) 278 LOAD ( u -- ) Start interpretation at top of block u. 57 LOADS xxx ( n -- ; Does: -- any) 287(Probs) LOOP DO ... LOOP 131 LOOPS ( n -- any) 288(Probs) M* ( n n2 -- d3) (Might not be available.) 158 M*/ ( d n2 n3 -- d4) (Might not be available.) 158 M+ ( d n2 -- d3) (Might not be available.) 158 M/ ( d n2 -- n3) (Might not be available.) 158 MAX ( n n2 -- maximum) 97 MIN ( n n2 -- minimum) 97 MOD ( u u2 -- remainder) 39 MOVE ( a a2 n -- ) Smart CMOVE or CMOVE> . (Not S-F.) 236 NEGATE ( n -- 2's complement) 97 NIP ( n n2 -- n2) SWAP DROP 49(Probs) NON ( n -- flag) 0= NOT ( n -- 1's complement) TRUE XOR 92 NUF? ( -- flag) KEY? DUP IF KEY 2DROP KEY BL = NOT THEN NUMBER ( a -- dn) Convert text to number. 247 NUMBER? ( a -- dn flag) 248 OCTAL ( -- ) 8 BASE ! 148 OFF ( a -- ) 0 SWAP ! OFFSET ( -- a) Address having value added to # for BLOCK or BUFFER. ON ( a -- ) TRUE SWAP ! ONLY ( -- ) Make search order to be only the "ONLY" vocabulary. OR ( n n2 -- or) 92 ORDER ( -- ) Display search order. OUTSIDE ( Compiling: n sys -- sys n) 274fn OVER ( n n2 -- n n2 n) 43 OVER2 ( n n2 n3 -- n n2 n3 n) 2 PICK OVER3 ( n n2 n3 n4 -- n n2 n3 n4 n) 3 PICK PAD ( -- a) Address of scratch area for intermediate data. 216 PAGE ( -- ) Clear window or slew printer. 131 PARSE ( c -- a n) 242Ð43 PATCH ( code cfa -- ) Change action of cfa to code. PLACE ( a n2 a3 -- ) Text string to counted string. PLURAL xxx ( addr -- ; Does: any -- any) 287(Probs) PICK ( n[m] n[m-1] É n[0] m -- n[m] n[m-1] É n[0] n[m]) PRINT ( -- ) Redirect output to printer for remaining input. 61 PRINTER ( -- ) Output to the printer. 61 QUERY ( -- ) Receive chars into TIB for parsing by WORD. 207 QUIT ( -- ) Clear return stack and return to terminal. 131 R> ( -- n ; R: n -- ) (Compile-only.) 99 R@ ( -- n ; R: n -- n) (Not the same as I .) 99 RE ( -- u) SCR @ RECURSE ( any -- any) (New name for MYSELF .) 211 RECURSIVE ( -- ) Allow self-reference. REPEAT BEGIN ... WHILE ... REPEAT 131 RESET ( R: any -- none) 207 ROLL ( n[m] n[m-1] É n[0] m -- n[m-1] É n[0] n[m]) ROT ( n n2 n3 -- n2 n3 n) >R SWAP R> SWAP 43 S>D ( n -- d) Convert single to double. DUP 0< 324 S0 ( -- a) Address having bottom of stack. (F83 has SP0 .) 216 SAVE-BUFFERS ( -- ) Write updated buffers back to mass storage. 230 SCAN ( a n c -- a+i n-i) Find first c in string. SCR ( -- a) Address having the active editing screen number. SEAL ( -- ) Eliminate the "ONLY" vocabulary from the search order. SHOW ( f l -- ) List range of blocks. 62 SIGN ( n -- ) (Use ROT SIGN instead of obsolete SIGN .) 154 SKIP ( a n c -- a+i n-i) Skip leading c's in string. SP@ ( -- a) Address of stack top. (AKA 'S .) (Don't use.) 216 SPACE ( -- ) Display one space. 26 SPACES ( n -- ) Display n spaces. 26 SPAN ( -- a) Address having # of chars received by EXPECT . 240 STATE ( -- a) Address having compilation state. 286 STICK ( n[m] n[m-1] ... n0 x m -- x n[m-1] ... n0) SWAP ( n n2 -- n2 n) 43 TEXT ( c -- ) Parse and move to PAD with blank extension. 243 THEN IF ... THEN 92 THREAD ( word vocaddr -- addr -1/0/1) THRU ( u u2 -- ) Load blocks u thru u2. 62 TIB ( -- a) Text input buffer. (Was S0 @ .) 216 TIMES ( n -- any) Interpret source n times. TRIAD ( u -- ) 62 (Obsolete.) TRUE ( -- n) Standard true value (i.e., all bits on). 176 TUCK ( n n2 -- n2 n n2) SWAP OVER 50(Probs) TYPE ( a n -- ) Display string. 231 U. ( u -- ) Display number unsigned. 147 U.R ( u n -- ) Display # unsigned right justified 148 U2/ ( n -- n') Unsigned shift right. U< ( u u2 -- u ( -- n) @ ; (Like CONSTANT .) VARIABLE xxx ( -- ; Does: -- pfa) Define number storage. 174 VOCABULARY xxx ( -- ) Define vocabulary xxx. WHILE BEGIN ... WHILE ... REPEAT 131 WITHIN ( n n2 n3 -- n2<=nR - R> U< 95(Probs) WORD ( c -- a) Parse input for counted string delimited by c. 243 WORDS ( -- ) Display names in vocabulary. (FIG VLIST .) 13 XOR ( n n2 -- exclusive or) 92 [ ( -- ) (Immediate.) Set interpret state. 278 ['] xxx ( -- cfa) (Compile-only, immediate.) Address of xxx. 199 [ASCII] c ( -- c) (CompileÐonly, immediate.) 281 [COMPILE] xxx ( -- ) (Compile-only, immediate.) 278 \ ( -- ) Ignore rest of line. 58 \IF ( flag -- ) Ignore rest of line unless flag is true. \S ( -- ) Ignore rest of block. (AKA ;SÊor \\ .) 58 ] ( -- ) Set compilation state. 278 Chapter 1. FUNDAMENTAL FORTH 7 Chapter 2. HOW TO GET RESULTS 29 Chapter 3. WORKING WITH FORTH 51 Chapter 4. DECISIONS, DECISIONS, É 80 Chapter 5. THE PHILOSOPHY OF INTEGER ARITHMETIC 96 Chapter 6. THROW IT FOR A LOOP 117 Chapter 7. A NUMBER OF KINDS OF NUMBERS 135 Chapter 8. VARIABLES, CONSTANTS, AND ARRAYS 168 Chapter 9. UNDER THE HOOD 195 Chapter 10. I/O AND YOU 226 Chapter 11. EXTENDING THE COMPILER É 260 Chapter 12. 3 1/2 EXAMPLES 289