The Museum of HP Calculators

HP Forum Archive 20

[ Return to Index | Top of Index ]

35s prompt for multi-character variables in program like "low footprint" root finder
Message #1 Posted by Chris C on 14 Feb 2012, 10:49 a.m.

I'm new to the 35s , and loving it, and wanting to learn to use more features. I was looking at programs and found the low footprint root finder (here: http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/archv019.cgi?read=146636 ). It looked great but I couldn't get it to work, so I ended up going with another root finder. The low foot footprint one stuck in my head because of how the writer prompted for variables using multiple characters, which would help make sure the correct value was entered in the correct place in an equation. (He prompted for X1 and X2 and Y1 and Y2.)

I tried to figure out the low footprint code, but I never could, so that's why I'm starting this thread. I'd like to be able have this functionality for a class where there are dozens of equations, and I need to make sure I enter the correct variable values in the correct places.

So, question (a): The author says he uses unnamed indirect variable addresses. Is doing this necessary to be able to use multiple characters to prompt for variables? (I don't store variable values in the A-Z spaces, so I don't need to preserve anything in those spaces.)

Question (b): How do I do this as simply as possible for programming and usage?

Thank you all, Chris C

Edited: 14 Feb 2012, 11:24 a.m. after one or more responses were posted

      
Re: 35s prompt for multi-character variables in program like "low footprint" root finder
Message #2 Posted by Bart (UK) on 14 Feb 2012, 11:16 a.m.,
in response to message #1 by Chris C

Quote:
do I need to use unnamed indirect addressing?
No.
Quote:
It is my understanding that that is only necessary if I want to preserve the contents of the named A-Z variables
that is correct. If you are not concerned with preserving the contents of the named A-Z variables (or actually want to use them), you can use e.g. "STO A" instead of "STO (I)".

The other post is using the "message" function of the 35s to prompt for variables, load them on the stack and then stores them. The INPUT does it all in one step, but with the limits of single letter variables.

See page 13-16 in the manual, section "Using Equations to Display Messages".
Also see this thread: HP-35s messages
Regards, Bart

Edited: 14 Feb 2012, 11:19 a.m.

            
Re: 35s prompt for multi-character variables in program like "low footprint" root finder
Message #3 Posted by Chris C on 14 Feb 2012, 12:08 p.m.,
in response to message #2 by Bart (UK)

Thanks Bart.

I've read and read in the manual and tried things but haven't been able to put it together into what I need. I do understand how to use flag 10 and show the multi-character prompts on screen. I just don't understand how the calculator treats the entries entered after the prompts. If you, or someone, wouldn't mind, could you post code for a small sample program so I could learn from it and apply it to my other needs?

NC=(H1-H2A)/(H1-H2S)

Thank you!

Edited: 14 Feb 2012, 12:13 p.m.

                  
Re: 35s prompt for multi-character variables in program like "low footprint" root finder
Message #4 Posted by Bart (UK) on 14 Feb 2012, 1:05 p.m.,
in response to message #3 by Chris C

As I mentioned, the "low footprint" program first loads variable values onto the stack, then stores them.

So firstly to use the stack you must be in RPN mode.
Secondly, as the stack is only 4 levels, you can only do 4 variable values in one go.

LABEL STEP             COMMENT
A001  LBL A
A002  SF 10
A003  H1, H2A, H2S     the three inputs, enter them in sequence pressing ENTER after the first two and R/S after the last one
A004  CF 10
A005  STO C            stores H2S into C, the last entered value is at the bottom of the stack (X-register)
A006  Rv               This is the Roll Down arrow, roll the stack down so H2A is in X-register
A007  STO B            stores H2A into B
A008  Rv               This is the Roll Down arrow, roll the stack down so H1 is in X-register
A009  STO A            stores H1 into A
A010  (A-B)/(A-C)      the actual formula, note the answer is put on the stack (X-register)
A011  SF 10
A012  NC=              displayes "NC="
A013  PSE              but only briefly
A014  CF 10
A015  RTN

You will see the answer in the X-register (bottom line), and the values of the entered variables above. If you want a "clean" display showing zero's and the answer, then do a "clear stack" before executing the formula:
LABEL STEP             COMMENT
A001  LBL A
A002  SF 10
A003  H1, H2A, H2S     the three inputs, enter them in sequence pressing ENTER after the first two and R/S after the last one
A004  CF 10
A005  STO C            stores H2S into C, the last entered value is at the bottom of the stack (X-register)
A006  Rv               This is the Roll Down arrow, roll the stack down so H2A is in X-register
A007  STO B            stores H2A into B
A008  Rv               This is the Roll Down arrow, roll the stack down so H1 is in X-register
A009  STO A            stores H1 into A
A010  CLSTK
A011  (A-B)/(A-C)      the actual formula, note the answer is put on the stack (X-register)
A012  SF 10
A013  NC=              displayes "NC="
A014  PSE              but only briefly
A015  CF 10
A016  RTN

Regards
                        
Re: 35s prompt for multi-character variables in program like "low footprint" root finder
Message #5 Posted by Chris C on 14 Feb 2012, 6:51 p.m.,
in response to message #4 by Bart (UK)

Thanks very much. This looks like just what I was hoping for.

One question on something you said though. When you said:

"...the stack is only 4 levels, you can only do 4 variable values in one go."

are you meaning this is applies if using unnamed indirect variable addressing or does it apply to your example too? Can't your example below use up to 26 variables (A-Z)? Or am I misunderstanding? What if the variable values were entered one at a time? Like:

A003 ENTER H1
A004 STO C
A005 ENTER H2A
A006 STO B
A007 ENTER H2S
A008 STO A
A009 CF 10
A010 (A-B)/(A-C)

Edited: 14 Feb 2012, 6:59 p.m.

                              
Re: 35s prompt for multi-character variables in program like "low footprint" root finder
Message #6 Posted by Bart (UK) on 14 Feb 2012, 7:44 p.m.,
in response to message #5 by Chris C

I was referring to the number of variable values that could be handled in one line, as in my A003. You can still do 261, but just 4 at a time.

Doing it one variable at a time as in your example, you do not have to be concerned with stack depth limits.

1) more if you use indirect addressing.

Edited: 14 Feb 2012, 7:52 p.m.

                                    
Re: 35s prompt for multi-character variables in program like "low footprint" root finder
Message #7 Posted by Chris C on 14 Feb 2012, 8:45 p.m.,
in response to message #6 by Bart (UK)

I understand. Thanks very much!

                  
Re: 35s prompt for multi-character variables in program like "low footprint" root finder
Message #8 Posted by Alexander Oestert on 14 Feb 2012, 1:18 p.m.,
in response to message #3 by Chris C

LBL A

SF 10 (Set message mode)

KEY IN VALUE (the message)

CF 10 (End of message mode)

STO A (store in A whatever was keyed in during message was shown and after R/S was pressed in Run mode)

VIEW A

RTN

                        
Re: 35s prompt for multi-character variables in program like "low footprint" root finder
Message #9 Posted by Chris C on 14 Feb 2012, 6:52 p.m.,
in response to message #8 by Alexander Oestert

Thank you.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall