ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» º Lesson 1 Part 13.0 F-PC 3.5 Tutorial by Jack Brown º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Our Own Outer Interpreter ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ The lesson 1 part 12.0 we presented the outer interpreter called MYQUIT which presented a picture of the parameter stack as the command line prompt instead of the usual " ok ". You should make sure that you have the outer interpreter MYQUIT in a file MYQUIT.SEQ so that you can load it whenever you need to experiment with the parameter stack. The stack picture presented by MYQUIT is generated by F-PC's non destructive stack display command called .S In Forth the period " . " means print. Using a period or dot by itself will print the top stack number ( the top stack number is the last number to be added to the stack) In the parameter stack picture provide by .S ( print stack ) the number to the extreme right is the top stack number. The number in the square brackets [3] specifies how many numbers are on the parameter stack. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Sample Run with MYQUIT ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ FLOAD MYQUIT MYQUIT Stack Empty. > 11 22 <--- put two numbers on stack [2] 11 22 > 33 <--- put 33 on the stack too [3] 11 22 33 > . 33 <--- print top number. [2] 11 22 > DEPTH <--- fetch stack depth to top [3] 11 22 2 > . 2 <--- print stack depth [2] 11 22 > + <--- add top two stack numbers [1] 33 > . 33 <--- print the sum Stack Empty. > 55 22 <--- put two numbers on stack [2] 55 22 > - <--- find the difference [1] 33 > . 33 <--- print the difference Stack Empty. > 7 8 <--- put two numbers on stack [2] 7 8 > * <--- find the product [1] 56 > . 56 <--- print the product Stack Empty. > 23 43 <--- put two numbers on stack [2] 23 43 > MIN <--- leave smaller on stack [1] 23 > . 23 <--- print the smaller number Stack Empty. > 23 45 <--- put two numbers on stack [2] 23 45 > MAX <--- leave the larger number [1] 45 > . 45 <--- print the larger number Stack Empty. > 66 3 <--- put two numbers on the stack [2] 66 3 > / <--- find the quotient [1] 22 > . 22 <--- display the quotient Stack Empty. > <--- finished. Do you know how to stop MYQUIT? There are two ways. 1) Type QUIT to start the old outer interpreter. 2) Make an error, as the error recovery routine will start the old version of QUIT. You can make an error by trying to execute a word that doesn't exist. That should be no problem! As an exercise try some of the above operators without MYQUIT running. Even without MYQUIT in operation you can display the parameter stack whenever you like by using the nondestructive stack print operator .S In the above discussion we have been using the word print for . where it might have been better to use the word display since the number goes on the display screen and not the printer. The reason we refer to " . " as the print operator is because it is a Forth tradition left over from the days when the human was connected to the computer via a teletype machine. In those days print really meant print! ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Comments in Forth Programs. ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ There are two ways to place comments in a Forth Program. The first is to place the comment in round brackets that some people call parentheses. ( This is a comment ) You must include both a starting and closing round bracket. The other common Forth commenting character is the back slash " \ ". Placing a backslash in you program means that anything on the line following the back slash will be ignored \ This is a comment to the end of the line. No end mark required. ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ· º Problem 1.7 º ÓÄÄÄÄÄÄÄÄÄÄÄÄÄÄĽ Experiment with the stack operators above. Write me a Forth program or Forth word that uses one or more of the operators + , - , * , / , MAX , MIN , and . It is pretty hard to get this problem wrong! Just about anything that does something useful will do. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Please move to Lesson 1 Part 14.0 ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ