The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

WP-34s: Strange programming/stack BUG
Message #1 Posted by W. Bruce Maguire II on 30 Apr 2012, 2:05 p.m.

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.

      
Re: WP-34s: Strange programming/stack BUG
Message #2 Posted by Bart (UK) on 30 Apr 2012, 3:01 p.m.,
in response to message #1 by W. Bruce Maguire II

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.

      
Re: WP-34s: Strange programming/stack BUG
Message #3 Posted by Marcus von Cube, Germany on 30 Apr 2012, 3:02 p.m.,
in response to message #1 by W. Bruce Maguire II

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.

            
Re: WP-34s: Strange programming/stack BUG
Message #4 Posted by W. Bruce Maguire II on 30 Apr 2012, 3:49 p.m.,
in response to message #3 by Marcus von Cube, Germany

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.

                  
Re: WP-34s: Strange programming/stack BUG
Message #5 Posted by Bart (UK) on 30 Apr 2012, 5:11 p.m.,
in response to message #4 by W. Bruce Maguire II

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) ;-).
                        
Re: WP-34s: Strange programming/stack BUG
Message #6 Posted by Tim Wessman on 30 Apr 2012, 5:40 p.m.,
in response to message #5 by Bart (UK)

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

TW

                              
Re: WP-34s: Strange programming/stack BUG
Message #7 Posted by Bart (UK) on 30 Apr 2012, 5:57 p.m.,
in response to message #6 by Tim Wessman

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

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

                                    
Re: WP-34s: Strange programming/stack BUG
Message #8 Posted by Antonio Petri (UK) on 30 Apr 2012, 6:21 p.m.,
in response to message #7 by Bart (UK)

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? ;)

                                          
Re: WP-34s: Strange programming/stack BUG
Message #9 Posted by Gerson W. Barbosa on 30 Apr 2012, 6:50 p.m.,
in response to message #8 by Antonio Petri (UK)

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.

                              
Re: WP-34s: Strange programming/stack BUG
Message #10 Posted by Gerson W. Barbosa on 30 Apr 2012, 6:20 p.m.,
in response to message #6 by Tim Wessman

I second, third and forth that! :-)

Gerson.

                                    
Re: WP-34s: Strange programming/stack BUG
Message #11 Posted by Tim Wessman on 30 Apr 2012, 11:54 p.m.,
in response to message #10 by Gerson W. Barbosa

Nice! :-)

TW

      
Please IGNORE this thread! Just my STUPID mistake!
Message #12 Posted by W. Bruce Maguire II on 30 Apr 2012, 3:53 p.m.,
in response to message #1 by W. Bruce Maguire II

Please IGNORE this thread! Just my STUPID mistake!

            
PLEASE, allow us to do what we ougth to!
Message #13 Posted by Luiz C. Vieira (Brazil) on 30 Apr 2012, 5:09 p.m.,
in response to message #12 by W. Bruce Maguire II

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.

            
Re: Please IGNORE this thread! Just my STUPID mistake! - Not at all !!
Message #14 Posted by Bart (UK) on 30 Apr 2012, 5:50 p.m.,
in response to message #12 by W. Bruce Maguire II

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.

                  
Thanks, guys!
Message #15 Posted by W. Bruce Maguire II on 30 Apr 2012, 6:00 p.m.,
in response to message #14 by Bart (UK)

Luiz and Bart:

Thanks, guys! :-)

Bruce.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall