Post Reply 
WP 34s stack preservation
04-01-2015, 05:27 PM (This post was last modified: 04-01-2015 05:28 PM by signals.)
Post: #1
WP 34s stack preservation
First, I'd like to say "Thanks!" to everyone who has been involved with the WP 34s project. I don't know how I missed it until now, but I just discovered it recently. Better late than never... I elected to buy one pre-made from hpcalc.org because I need a calculator, not another project to add to the pile, but it is supposed to be here tomorrow and I'm very excited.

I've never owned a traditional RPN calculator before. I bought an HP 48sx sometime around 1991 and used it exclusively ever since. Well, at least until its screen died and I replaced it with a 48g from eBay. Now, it is dying, and I'm in need of a new one. I no longer need all of the fancy graphing and such, I'll use a computer for that. All I need is a quick number cruncher and the WP 34s seems like a perfect fit. Unfortunately, the finite stack is difficult for me to get my mind around and I'm having trouble figuring out best practice for preserving the stack when a program is called. It's easy in the RPL world; just remove anything you put on the stack, and it will be the same as when you started.

Anyway, I've discovered the STOS and RCLS commands and have been storing the stack into local registers at the start of my program and recalling them at the end. It works, but I have to allocate 4 extra LRs that I probably don't need to hold a possible 8 level stack. So, I've been wondering, what is the correct way to do this?

I know there's a SSIZE? command which will tell me the stack size, and theoretically, I could use that to decide how many LRs I need for the STOS command, but I as soon as I call SSIZE? the stack lifts, and I've lost T (or D.) Then I have to add my local LR usage to the number so I can call LocR, and I lift the stack again for the addition and lose the original Z.

I could use global registers, but that violates the "leave the calculator as you found it" behavior that I expect when running a program. Am I just stuck with blowing 8 LRs on stack preservation? Or am I missing something obvious? How is this usually handled?

Go easy on me. I've never touched a keystroke programmable RPN calculator until a few days ago, so I'll be the first to admit that I probably just don't know something basic. As good as the manual is (and it is good) the sheer amount of information in it is overwhelming and it will probably take me a few weeks, and a few dumb questions, to grok it all.

Thanks.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
WP 34s stack preservation - signals - 04-01-2015 05:27 PM
RE: WP 34s stack preservation - signals - 04-01-2015, 06:31 PM
RE: WP 34s stack preservation - signals - 04-01-2015, 07:40 PM



User(s) browsing this thread: 1 Guest(s)