HP Forums

Full Version: WP-34s: Strange programming/stack BUG
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Dear WP-34s development team:

I ran into a very strange programming/stack bug in a little program that I was writing. I have tried to boil it down to a simple example. First, the "control" (works as expected) example; enter the following little program:

LBL 'AAA'
ENTER^
END

Now, set your stack to a 4-level stack (I haven't tried it with an 8-level), and do the following:

0
FILL // To fill stack with zeros.
2
XEQ 'AAA'

Then examine the stack using "Rv" (roll-down), to see the expected result:

0  // t
0 // z
2 // y
2 // x

Now, add two extra keystrokes to the problem, which should not change the result at all:

LBL 'AAA'
ENTER^
1 // ADDED STEP: Digit: one.
x // ADDED STEP: Multiplication operator.
END

This *should* yield the same result, in that the value in the 'x' register will be duplicated by the "ENTER^" statement, the values in the 'x' and 'y' will be temporarily moved up to the 'y' and 'z' registers when the "1" is entered, then the multiplication will be performed, and the values will move back down to the 'x' and 'y' registers. *BUT*, that is not what happens!:

0
FILL // To fill stack with zeros.
2
XEQ 'AAA'

And look at the stack using "Rv" (roll-down), to find:

0  // t
0 // z
0 // y <---This register should contain "2"!
2 // x

Thanks for your attention,

Bruce.

That is not a bug, it is correct. My HP-15C and HP-35s do exactly the same (and the 42S probably too). If you do it manually you will get the same (i.e. "2 ENTER" will have 2 in both X and Y, but "2 ENTER 1 x" will have 2 in just X). From this page: "The ENTER key (and CLx which clears the X register) leave the stack in state where it won't automatically lift when the next number is entered. In this case, when the next number is entered it will replace the X register".

The WP-34s also uses this kind of behaviour.

-B


Edit: I was used to RPL calculators (HP-28/48/50 series) when I first got the HP-35s, and it took some getting used to ;-)


Edited: 30 Apr 2012, 3:07 p.m.

Quote:
LBL 'AAA'
ENTER^
1 // ADDED STEP: Digit: one.
x // ADDED STEP: Multiplication operator.
END

ENTER^ disables stack lift so that after ENTER^ 1 the second 2 (in x) is replaced by 1. The multiplication drops the stack so that only the result of the multiplication remains.

Bart and Marcus (and the whole 34s team):

Doh; I'm sorry for the false alarm! Truly embarrassing! <:-/

If the RPL calculators behave differently, then that must be why this seemed wrong to me... But I should have known better. I new about stack-lift disable! I will go and wear a dunce cap in the corner for an hour. ;-)

So sorry,

Bruce.

Edited: 30 Apr 2012, 3:51 p.m.

Please IGNORE this thread! Just my STUPID mistake!

We all solely swore to help each other and anyone else willing to be helped (didn't you? So should you!), and there are moments we need support as well. Don't you think you have already helped many others that will not get into this now, just because of you?

So, thank you for letting us know about this all.

Cheers.

Luiz (Brazil)

Edited: 30 Apr 2012, 5:10 p.m.

Quote:
If the RPL calculators behave differently...

Oh YES. And let me not state which is my favourite & why, lest I start an RPB (reverse polish battle) ;-).

No reason to battle about it. RPL is clearly better.

TW

No, not stupid at all. Let me tell you that you had the guts to ask when I did not, at the time I started with the 35s three years ago. I just put in extra ENTERs to make copies of a number on the stack, because that's what made it work - only several months later did I get to understand why.

Says the man who fathered* no less than two algebraic-only calculators :-)))

(* he has been known to refer to them as "my baby" ;-))

Luiz and Bart:

Thanks, guys! :-)

Bruce.

I second, third and forth that! :-)

Gerson.

So, do you mean that there might be a TI mole in the HP calculator group with the aim of depriving us of our beloved RPN calcs? ;)

I read about it back then, but I don't remember the specs. Anyway, I think the HP 50 (not the HP 50g) was RPL.

Gerson.

Edited: 30 Apr 2012, 6:52 p.m.

Nice! :-)

TW