The Museum of HP Calculators

HP Forum Archive 18

[ Return to Index | Top of Index ]

A couple of RPL questions
Message #1 Posted by Hal Bitton in Boise on 28 June 2008, 7:56 p.m.

Hi folks,
2 quick questions

1. If I want to do a comparison (such as a DO UNTIL function) using one of the stack registers to campare, how do I adress the stack register in the program?

2. Can I force a display update during program execution without pausing?

thanks much, Hal

      
Re: A couple of RPL questions
Message #2 Posted by Allen on 28 June 2008, 8:33 p.m.,
in response to message #1 by Hal Bitton in Boise

Quote:
1. If I want to do a comparison (such as a DO UNTIL function) using one of the stack registers to campare, how do I adress the stack register in the program?
Generally speaking you can either leave the number on the stack or depending on what the stack traffic and DEPTH is like during the loop, it may be easier to save to a local or global variable.

If the number is on the stack, the addressing mode varies according to depth. If you know it is always at stack position P you can grab a copy by using P ROLL and put it back by P ROLLD. There are easier, faster ways if you know the stack depth of the counter, and especially when the depth is 3 or less. The WHILE/REPEAT loops may also help. If you have a partial program, perhaps there is more to say. Are you optimizing for speed or size?

Edited: 28 June 2008, 8:34 p.m.

            
Re: A couple of RPL questions
Message #3 Posted by Hal Bitton in Boise on 29 June 2008, 10:25 a.m.,
in response to message #2 by Allen

Hi Allen, thanks for your response.

I will only be using what's in stack level 1 in my do until loop, adding 1 to it and comparing it to 50, so the construct would look like this: DO 1 +
UNTIL stack level 1 > 50
END
the problem is, I don't know what nomenclature to use for stack level 1 so the calculator will recognize it...do I refer to it in the program as level 1, L1, LVL1, or what? I tried just leaving it blank, like this:
DO 1 +
UNTIL > 50
END
thinking it would default to stack level 1 and compare it to 50 in the absence any other specific variable, but that didn't seem to work.
I realize I could put level 1 into a variable and use that in the do until loop, but I was just hoping there was a way to directly use the contents of level 1 (or any other stack level, for that matter) in my do until loop.
Hope this clarifies my plight for you. Thanks, and best regards, hal

P.S. Anybody out there know how to force a screen update during program execution without halting or pausing the program?
thanks again, hal

                  
Re: A couple of RPL questions
Message #4 Posted by Raymond Del Tondo on 29 June 2008, 11:50 a.m.,
in response to message #3 by Hal Bitton in Boise

Hi,

it seems there is some misunderstanding on how an RPL data stack works.
The RPL data stack (and nearly all other stacks in an RPL machine)
work in a different way than the fixed data stack of an RPN calculator.

Please take a look at an appriorate RPL tutorial,
which can be found on (and through) www.hpcalc.org

For the 2nd question:
I know how to refresh the display during prg run in SysRPL,
but I don't know if there's such a statement in UserRPL.

I assume you actually want to show the contents of the data stack,
so you could write a very small program to do that.

Alternatively you could call some suitable SysRPL entries to do that work;-)

HTH

Raymond

                  
Re: A couple of RPL questions
Message #5 Posted by Egan Ford on 29 June 2008, 12:23 p.m.,
in response to message #3 by Hal Bitton in Boise

Quote:
DO 1 +
UNTIL > 50
END

A couple of issues. Comparison operators pop two values off the stack and comparison operators should be postfix. Type in your 48/49/50:
1 2 >
Your calc will return '0' to the stack, and the 1 and 2 will be removed from the stack. Reverse the 1 and 2 and '1' will be returned. The return value of '0' or '1' is used by UNTIL (also popped).

Your counting program should look like:

DO
  1 +
  DUP
UNTIL 50 > END
or
DO
  1 +
DUP 50 > UNTIL END
I prefer the later, i.e. keeping it all postfix just like FORTH:
BEGIN
  1 +
DUP 50 > UNTIL

Edited: 29 June 2008, 1:34 p.m.

                  
Re: A couple of RPL questions
Message #6 Posted by Allen on 29 June 2008, 3:37 p.m.,
in response to message #3 by Hal Bitton in Boise

Quote:
P.S. Anybody out there know how to force a screen update during program execution without halting or pausing the program? thanks again, hal

I recommend reading Chapter20 RPLMAN (from hpcalc.org). I do not often dabble in programs that take longer than the screen where I need to update.

FWIW, I agree with egan regarding the syntax for your loop:

DO
  1 +
DUP 50 > UNTIL END

but if this is all you are doing, it is better just to use

1 WAIT

If there are actual inputs and outputs to your loop (other than the counter), There is almost certainly a better way.

      
Re: A couple of RPL questions
Message #7 Posted by reth on 30 June 2008, 5:46 a.m.,
in response to message #1 by Hal Bitton in Boise

I'd suggest you to read the manuals before asking here for help. If someone can not figure out how DO UNTIL works and calls it function any help is pouring water in sand

            
Re: A couple of RPL questions
Message #8 Posted by Hal Bitton in Boise on 30 June 2008, 6:39 p.m.,
in response to message #7 by reth

Hello Reth

Quote:
I'd suggest you to read the manuals before asking here for help.
Agreed. I have read the manuals (48g and 50g guides). I was seeking help on two specific tecniques which were not forthcoming from the documentation. Egan Ford, and Allen were both kind enough to offer very good insight, all delivered within a few lines. How would this possibly supplant reading the manual?

Quote:
If someone can not figure out how DO UNTIL works and calls it function any help is pouring water in sand
I'm assuming that you are basing this assessment on the fact that I called DO UNTIL a function, whereas "loop construct" would have been more appropriate. I'm going to give you the benifit of the doubt on this point, that you're not trying to insult my intelligence. The aforementioned help which I recieved was put to good use, and has resolved the issue I was having. This was most certainly NOT analagous to pouring water onto sand.
I think that in the future I will continue to ask for a bit of help from time to time, in spite of the possibility of being rebuked by you.
Best regards, Hal
                  
Re: A couple of RPL questions
Message #9 Posted by Jeff Kearns on 30 June 2008, 7:04 p.m.,
in response to message #8 by Hal Bitton in Boise

I am a regular visitor to the forum but an infrequent contributor. I nonetheless find your questions and comments to be appropriate and I have always found them to be worthy of asking those on this forum who may know a bit more about RPL programming than the average user. I am a RPL beginner myself and learn a great deal from the Q&A strings.

Good response.

Jeff Kearns

                  
Re: A couple of RPL questions
Message #10 Posted by reth on 1 July 2008, 3:54 a.m.,
in response to message #8 by Hal Bitton in Boise

I'm sorry, Hal, I didn't want to be abusive, I only remembered how I myself worked it out some 20 years ago (it was the HP28s) having only german language manual and not understanding a word, only figured it out by the examples given and coming from the HP41 experience; Back then I was so much in love with those calculators so I started understanding foreign languages ;)
Best regards,
Reth

                        
Re: A couple of RPL questions
Message #11 Posted by Hal Bitton in Boise on 1 July 2008, 3:18 p.m.,
in response to message #10 by reth

Thank you Reth...
No offence taken. Until I started collecting 4 years ago, I had no RPL experience at all...only keystroke programming (starting with my HP 29C in the late 70's). I'll be the first to admit that there are times I become impatient and fire off a question on this forum that I probably could have answered myself with a bit more perseverance.
Speaking of the 41C, I have a couple of 41cx's...wonderful machines. One of them is presently on display at the advanced math and science school that my 12 yr old son attends. (HP is one of the sponsors of that school). Who knows, maybe (hopfully!) that display will spark one of the kids to at least look at an HP machine at some point in the future (because I assure you, they all have TI's right now...except my son, who loves his 33s!).
Best regards, Hal


[ Return to Index | Top of Index ]

Go back to the main exhibit hall