The Museum of HP Calculators

HP Forum Archive 08

 FORTH on HP-71BMessage #1 Posted by Hiroshi Ito on 1 July 2002, 10:48 a.m. I began the study of "the FORTH/ASSEMBLER ROM HP82441A for HP-71B". But I met difficultly from the beginning. HP-71B is indicated with "OK (3)". But, I don't know how a result of a calculation can be confirmed. Can I confirm it if I do what with "579" which for example is the answer of "123+456"? # 123 456 [ENDLINE] # OK ( 2 ) # + [ENDLINE]" # OK ( 1 ) # And, do you keep it as a program code which a name was attached to, or can you carry it out if you do what?

 Re: FORTH on HP-71BMessage #2 Posted by Daniel Diggelmann on 1 July 2002, 3:13 p.m.,in response to message #1 by Hiroshi Ito Hello Hiroshi, The answer of the calculation can be displayed with "." But I don't know how to store it as a program. Daniel

 Re: FORTH on HP-71BMessage #3 Posted by Raymond Hellstern (Germany) on 1 July 2002, 4:20 p.m.,in response to message #2 by Daniel Diggelmann Hi, have you tried "!" ? Raymond

 Re: FORTH on HP-71BMessage #4 Posted by Tony Duell (UK) on 1 July 2002, 6:46 p.m.,in response to message #1 by Hiroshi Ito A couple of general points. (1) Forth is a somewhat unconventional language, so if you have never used Forth before, you need to get a (good) book on it. 'Starting Forth' is not too bad. And (2), HP71 Forth is an unconventional version of Forth. You really do need to find at least the Forth/Assembler ROM user manual and preferably also the IMS (source listings -- yes, they do exist!). To answere your questions. The number in parentheses after the OK (as in OK (3) -- the '3' here) is the number of numbers on the Forth (integer) stack. Suppose we start with an empty stack (the machine shows OK (0)). Then type 12 34 That will place 2 numbers (twelve and thirty-four) on the stack so the machine will reply with OK (2). Then type + and you'll get OK (1). The + 'word' in Forth takes 2 numbers off the stack, adds them, and puts the result back on the stack. So now the stack contains one item. To display the top of stack you use the word . (that's a single period/full stop). It takes the top number off the stack and displays it. So in this case you'd get 46 OK (0). The 46 is the sum of 12 and 34, the (0) means that's nothing left on the stack. Of course you can do it all in one line 12 34 + . (note that the spaces are important --the names of Forth words can contain any characters apart from space (and newline), and the forth command line parser looks for spaces to work out where the name of each word ends). Technically you can't write programs in Forth -- all you can do is define new words. Of course the definitions can be very complicated (and you can define words using words that you've just defined) so what you can end up with is a single word that when exectuted runs your application. Here's a simple example of defining a word : SQ DUP * ; (type everything from the colon to the semicolon inclusive). This is called a 'colon definition' (for obvious reasons). In this case it defies a new word called SQ which when exectued will perform the operations DUP, then * in that order. DUP duplicates the top item of the stack, * multiplies the top 2 items on the stack, replacing them with the product. So SQ (defined like that) will square the top number on the stack. Try it. After defining SQ as above, type 5 SQ You'll get OK (1). Where's the answer? Still on the stack, of course. Type . to display it. Or type something like 7 SQ . to do it in one line.

 Re: FORTH on HP-71BMessage #5 Posted by HIroshi Ito on 2 July 2002, 11:57 a.m.,in response to message #4 by Tony Duell (UK) I understood "." and ": SQ DUP * ;". But, how to use "!" couldn't be understood. I sometimes write the following program, and help myself. Then, it is kept with the name which it liked in 9114B HP-IL Disc Drive. Can you describe the program of the dialog type which complex control structure exists in with "FORTH", too? \$ 10 NAME TEST \$ 20 INTEGER N,I \$ 30 REAL A,S \$ 40 INPUT "NUMBER=";N \$ 50 IF N <= 0 THEN 40 \$ 60 A=0 \$ 70 FOR I=1 TO N \$ 80 INPUT "SAMPLE(";I;")=";S \$ 90 A=A+S \$ 100 NEXT I \$ 110 PRINT "ANSWER=";A \$ 120 END \$ COPY TEST TO T20020702:FD "amazon.com" is available even from Japan. I want to learn it if there is a reference book for the initiation person. Thank you.

 Re: FORTH on HP-71BMessage #6 Posted by Katie on 1 July 2002, 6:59 p.m.,in response to message #1 by Hiroshi Ito Here's a primer that I found on-line describing the basic FORTH language. The FORTH on the 71b is a pretty decent implementation with all of the standard elements and a good interface to the floating point routines built into the 71b. You can also interface with BASIC programs that you write on the calculator.

 online FORTH primerMessage #7 Posted by Ellis Easley on 8 July 2002, 8:13 a.m.,in response to message #6 by Katie There is a second part (4th_OF_B) in the same directory.

Go back to the main exhibit hall