HP Forums
(12C) Does a STO pop the stack or not? - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (12C) Does a STO pop the stack or not? (/thread-13149.html)



(12C) Does a STO pop the stack or not? - Joe_H - 06-19-2019 12:00 PM

I was wondering if someone could answer the following question for me. I understood that 12C and its platinum version were completely compatible except for the line address (extra 0 in platinum) and the LSTx command is in a different location on Platinum plus it has one or tow additional commands such as x^2 etc.

A program I have written on 12C won't run on the Platinum and I have found it is for the following reason:

Take stack to be: 1, 2, 3, 4 (for X, Y, Z, T)

01 STO FV
02 0
03 STO PV
04 Rv

Now, according to my understanding of how the stack works it should be after these: 1, 2, 3, 0

But I ran into problems debugging the software on the 12C. I thought I had misunderstood how the stack operates as the 12C stack after the operations above is: 2, 3, 4, 0. I have confirmed this by running it a number of times.

I now find that on the Platinum that it does in fact follow how I understood it works and the stack is 1, 2, 3, 0.

I have narrowed this down to the first two lines above. A STO FV followed by the 0 entry pops the stack and pushes 0 onto it so it is: 0, 2, 3, 4.

Which model is correctly performing these operations and why have they introduced a very subtle but awkward incompatibility between the models?


RE: (12C) Does a STO pop the stack or not? - rprosperi - 06-19-2019 12:28 PM

This behavior (12CP not treating stack lift enable/disable the same way as the 12C) has been discussed in the past, it seems to be related to using the Financial registers rather than strictly because of the STO command. See this thread from the old Forum:

https://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/archv015.cgi?read=87191


RE: (12C) Does a STO pop the stack or not? - Joe_H - 06-19-2019 12:30 PM

HP-12C (3rd generation model, I gather, no. HSTNJ-KN05 made in China with 2xCR2032 and a serial port) purchased around 2010:

- On the 12C I have confirmed that a STO {0-9} doesn't pop the stack and the 0 is pushed onto it.
- However, for STO {n, i, PV, PMT & FV} it does pop the stack when a digit is entered after the STO line.
- If the stack is rotated immediately after the STO the digit entered into the TVM register remains on the stack.
- If the STO is followed by a RCL # or LSTx the value stored is popped off the stack and replaced with the register value or LSTx.


HP-12C Platinum (HSTNJ-KN11 2xCR2032 model made in Philippines no serial port installed but chassis shaped for the plug) purchased 2019:

- On the Platinum it is the same for STO {0-9} as STO {n, i, PV, PMT & FV} in that the valued stored in the TVM register is not popped if followed by another value either by direct entry of RCL or LSTx.

The behaviour of the Platinum is more consistent and easier to understand but the incompatibility is a real pain.

What did the original HP-12C from 1981 do?


RE: (12C) Does a STO pop the stack or not? - rprosperi - 06-19-2019 12:44 PM

While there are several inconsistencies between 12C and 12CP, I do not believe there are any between the various mfg. versions of the 12C Gold, but could be wrong.

For the 12CP, see this old thread too:

https://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/archv020.cgi?read=190342

While the 12C Gold and 12CP are broadly compatible, the small details in these articles show that they cannot be considered compatible for any arbitrary program without testing. Note that some of the techniques discussed in the threads (e.g. inserting extra Enter statements) can make programs behave the same on both models, but doing so adds extra commands making it longer, and can also appear confusing to other folks ("why is there an extra Enter here?").


RE: (12C) Does a STO pop the stack or not? - Didier Lachieze - 06-19-2019 12:48 PM

As a side note, you don't need to use STO to store to the financial registers: 123 [FV] will store 123 in the FV register.

On the original 12C, pressing [FV] to store a number in the FV register doesn't enable stack lift, so when you follow by entering 0 it just replaces the value in the X register.

This is documented in a footnote in the Appendix A of the 12C manual:
Quote:* In addition, the stack does not lift when a number is entered if the last operation performed was storing a number into a financial register. For example, the stack will not lift when a number is entered following the sequence 100000 [PV], but will lift when a number is entered following the sequence 100000[PV][FV].

I don't know why it is different on the Platinum. Maybe because the firmware is different and this peculiar feature has not been reproduced.


RE: (12C) Does a STO pop the stack or not? - Joe_H - 06-19-2019 12:48 PM

Thanks Bob. It makes things a real pain but the platinum is easier to understand and now I realise why I was having problems writing software for 12C as i didn't know it behaved that way and I noticed something strange was going on at times that I couldn't quite figure out.

Are there any other software differences like this?


RE: (12C) Does a STO pop the stack or not? - Joe_H - 06-19-2019 01:09 PM

Didier,

Thanks for the advice. I had forgotten that actually. Messing around with it I prefer the STO as it is clearer what is being done with no extra memory consumed. There is also the risk of making a mistake as if the entry was:

0
i
PV
FV

The last 2 would run the TVM algorithm which isn't what I want. I wrote it instead:

0
STO i
STO PV
STO FV

Which is clearer to me and doesn't have the risk of making the mistake above (which I certainly would!)


RE: (12C) Does a STO pop the stack or not? - Gamo - 06-19-2019 03:02 PM

Since my program to solve for Profit on Pricing used
HP-12C with TVM registers for Store and Recall

The
Data Input routine is

[FV]
RV
[PMT]
RV
[ i ]
RV
[n]
.
.
.

The last data input on [n] doesn't start TVM algorithm execution because there always be an integer after [n]
The whole program run without execute any TVM function.

I did put this program to run on HP-12C Platinum and it work flawlessly.

Gamo