User Tools

Site Tools


tutorials:forth

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tutorials:forth [2022/03/07 16:39]
lars Update to reflect this is mostly for FORTH-10.
tutorials:forth [2022/06/07 02:10]
rcs correct lack of space after dot commands in examples
Line 7: Line 7:
 **FORTH** is another interpreter originally written on the MIT AI lab DEC-20 called OZ, by John Wilson. **FORTH** is another interpreter originally written on the MIT AI lab DEC-20 called OZ, by John Wilson.
  
-====== Survival Guide ======+====== FORTH-10 Survival Guide ======
  
 Start the interpreter on TWENEX with the command ''FORTH-10''. If you have not created an [[#start-up_file|auto-load file]], FORTH-10 will respond with the default greeting and prompt. Start the interpreter on TWENEX with the command ''FORTH-10''. If you have not created an [[#start-up_file|auto-load file]], FORTH-10 will respond with the default greeting and prompt.
Line 21: Line 21:
   7 3 Ok  ( Push 7 then 3 on stack. )   7 3 Ok  ( Push 7 then 3 on stack. )
   + Ok    ( Remove two items from stack (3 and 7), push the sum on stack, so 10 is only item. )    + Ok    ( Remove two items from stack (3 and 7), push the sum on stack, so 10 is only item. ) 
-  .10 Ok  ( Word . pops top stack item and prints it. Stack is now empty. )+  . 10 Ok  ( Word . pops top stack item and prints it. Stack is now empty. )
      
 Words ''.'', ''+'', ''-'', ''*'', and ''/'' interpret stack items as integer values. For floating-point values, use ''f.'', ''f+'', ''f-'', ''f*'', and ''f/''.   Words ''.'', ''+'', ''-'', ''*'', and ''/'' interpret stack items as integer values. For floating-point values, use ''f.'', ''f+'', ''f-'', ''f*'', and ''f/''.  
  
   3.14159 Ok   3.14159 Ok
-  f.3.14159 Ok      ( f. pops stack and displays as floating-point. )+  f. 3.14159 Ok      ( f. pops stack and displays as floating-point. )
      
 Add new words to the dictionary with the defining words '':'' and '';''. Add new words to the dictionary with the defining words '':'' and '';''.
Line 37: Line 37:
                      ( previous top value, multiply and push product on stack.  )                      ( previous top value, multiply and push product on stack.  )
   7 TIMES5 Ok        ( Execute the word. )   7 TIMES5 Ok        ( Execute the word. )
-  .35  Ok            ( Pop and display result. )+  . 35  Ok            ( Pop and display result. )
      
 List words currently defined in the dictionary with ''VLIST''. List words currently defined in the dictionary with ''VLIST''.
Line 79: Line 79:
  
 At start-up, FORTH-10 searches the user's log-in directory for a file named ''AUTO-LOAD.4TH''. If such a file exists, it is loaded automatically. If the file does not exist, FORTH-10 displays a standard greeting message. At start-up, FORTH-10 searches the user's log-in directory for a file named ''AUTO-LOAD.4TH''. If such a file exists, it is loaded automatically. If the file does not exist, FORTH-10 displays a standard greeting message.
 +
 +====== FORTH ======
 +
 +Start the John Wilson's interpreter on TWENEX with the command ''FORTH''. It will respond with this greeting and prompt.
 +
 +  @FORTH
 +  FORTH/Oz v1 (JohnW)
 +  ok
 +  
 +Exit FORTH with the command ''BYE''.
 +
  
 ====== Reference ====== ====== Reference ======
tutorials/forth.txt ยท Last modified: 2022/06/07 02:10 by rcs