HP 42s Stack Save/Restore Tool



#4

After using 42s on my iPod for a while now, I was getting sick of having to code stack save/restore routines at the beginning and end of every program. So I decided to do something about it!

http://dave.brittens.org/HP42s/StackSave.html

Without repeating myself too much, there are two programs: SAVE and RESTORE. You only have to set a few options before calling either. For example, suppose I were writing a program to calculate a logarithm to any base, which uses two values from the stack and returns one. (An overly simple, contrived example, I know.) At the beginning of the program, I would do this:

"LOG"
CF 91
CF 92
XEQ "SAVE"

Then at the end of the program, these steps:

2
STO "_A"
RDown
1
STO "_O"
RDOWN
"LOG"
CF 91
XEQ "RESTORE"

The result would be the T and Z registers from before the program was run being rolled down to Z and Y, with the T register being copied as is the norm for built in functions.

There are some run-time options to control the number of arguments your program takes from the stack, the number of outputs it returns, how to deal with LAST X, and whether or not to save and restore REGS.

Anyway, try it out, see if you can break it, and hopefully my quick and dirty writeup will make a little bit of sense. :)

-Dave


#5

Quote:
After using 42s on my iPod for a while now, I was getting sick of having to code stack save/restore routines at the beginning and end of every program. So I decided to do something about it!

The next feature to implement in the 42s is Undo and Redo. Will probably be out in time for a stocking stuffer.

However, the functionality is not the same as your program, so may not provide the same utility.


#6

Very cool. I've always liked the Last Stack/Undo feature on the 48. It comes in quite handy when I fat-finger something during a lengthy calculation!


Possibly Related Threads...
Thread Author Replies Views Last Post
  WP-34S (Emulator Program Load/Save) Barry Mead 1 643 12-09-2013, 05:29 PM
Last Post: Marcus von Cube, Germany
  HP 50g - select characters on the stack, copy/paste Sean Freeman 7 1,128 11-20-2013, 07:11 AM
Last Post: Sean Freeman
  Prime: Placing more than 1 item on the RPN stack in a single program? John Colvin 4 855 11-19-2013, 08:59 AM
Last Post: Miguel Toro
  HP Prime - definitely no education tool bluesun08 5 775 11-17-2013, 11:35 AM
Last Post: Alberto Candel
  "HexZombie - a tool for real programmers" Thomas Chrapkiewicz 8 1,176 11-16-2013, 12:46 AM
Last Post: Kiyoshi Akima
  emu48 - copy stack doesn't work (as expected) Thomas Radtke 2 830 11-11-2013, 02:19 PM
Last Post: Thomas Radtke
  HP Prime Stack operations from within a program John Colvin 1 580 11-08-2013, 09:45 PM
Last Post: Helge Gabert
  HP Prime: CAS Variables - -How to save? Helge Gabert 2 601 10-27-2013, 11:26 PM
Last Post: Helge Gabert
  HP Prime Save Power Turn Off Not Working Timothy Roche 12 1,549 10-27-2013, 01:41 PM
Last Post: Michael de Estrada
  How to save the definition of a CAS program or CAS function ? dg1969 3 673 10-19-2013, 01:48 PM
Last Post: dg1969

Forum Jump: