What's the easiest way to compare the x value with a constant during a running calculation without upsetting the stack? You can easily compare to y or to 0 but how about to a stored value?

On a side note, how many different ways did HP use for their programming? It seems that every programmable calculator does it differently.

(07-13-2020 08:39 PM)Davidy Wrote: [ -> ]What's the easiest way to compare the x value with a constant during a running calculation without upsetting the stack? You can easily compare to y or to 0 but how about to a stored value?

On a side note, how many different ways did HP use for their programming? It seems that every programmable calculator does it differently.

I don't have a 42S at hand but something like this might work:

Let's assume that the stored value is in R13 and if the value in the X stack register equals that value then execution should branch to LBL 07. To achieve what you want, do this:

RCL- 13

X=0?

GTO 07

X<> ST L

This leaves the stack as it was before the comparison, except for the LastX register (ST L).

If you don't need the value of X after the comparison, omit the X<> ST L step. If you need the value of X (and Y,Z,T) at the LBL 07 destination, put the X<> ST L there as well, like this:

LBL 07

X<>ST L

This won't work for alpha data, of course.

V.

Something like this should work:

X<> ST L

Rv

42 ; arbitrary real constant

RCL- ST L

X=0?

GTO "FOO"

RCL- ST L

+/-

....

LBL "FOO"

RCL- ST L

+/-

....

It uses LASTX for temporary storage like Valentin's solution, but allows the (real) constant to be entered literally. (It won't work for complex constants because you need two stack positions to enter a complex constant.)