Post Reply 
Question about Stack and Roll
07-01-2016, 02:03 PM
Post: #1
Question about Stack and Roll
Hi all.
I have a question for the RPN experts.
To refresh my RPN skills, I am re-reading the original manual of the HP-15C, the Owner's Handbook. I dont' have the original HP-15C, but several Android emulators.
The question is this:
Page 34 of the manual reports the simple example that fills the four registers with the digits 1, 2, 3 and 4.
The normal method is obviously:
1) 1
2) Enter
3) 2
4) Enter
5) 3
6) Enter
7) 4

At this point, with the Roll Down key is possible to inspect and verify the contents of the registers.

My problem is that if I use Roll Down to inspect the register contents after each Enter of the previous sequence (returning each time to the X register) I found at the end that the registers are filled with the sequence:
T: 2.0000
Z: 3.0000
Y: 3.0000
X: 4.0000

This surprises me, because I was expecting the sequence 1, 2, 3, 4.
Probably I am missing some subtlety of the RPN Roll behaviuor, could you please help me to understand what happens?
Thanks.
Find all posts by this user
Quote this message in a reply
07-01-2016, 02:53 PM
Post: #2
Must be a bad emulator
The behavior of that emulator is flawed. When using a physical HP-15C, it produces the expected result. On my iPhone, the Free 15C acts the same way as the real HP calculator does.

Alan
Find all posts by this user
Quote this message in a reply
07-01-2016, 03:16 PM (This post was last modified: 07-01-2016 03:17 PM by wojtek.)
Post: #3
RE: Question about Stack and Roll
(07-01-2016 02:03 PM)Antlab Wrote:  Hi all.
I have a question for the RPN experts.
To refresh my RPN skills, I am re-reading the original manual of the HP-15C, the Owner's Handbook. I dont' have the original HP-15C, but several Android emulators.
The question is this:
Page 34 of the manual reports the simple example that fills the four registers with the digits 1, 2, 3 and 4.
The normal method is obviously:
1) 1
2) Enter
3) 2
4) Enter
5) 3
6) Enter
7) 4

At this point, with the Roll Down key is possible to inspect and verify the contents of the registers.

My problem is that if I use Roll Down to inspect the register contents after each Enter of the previous sequence (returning each time to the X register) I found at the end that the registers are filled with the sequence:
T: 2.0000
Z: 3.0000
Y: 3.0000
X: 4.0000

This surprises me, because I was expecting the sequence 1, 2, 3, 4.
Probably I am missing some subtlety of the RPN Roll behaviuor, could you please help me to understand what happens?
Thanks.

It is correct (if you press Roll Down after each Enter). I believe all HP rpn calculators behave the same way. Make a quick test and clear the stack (press "clear" and Enter 4 times) then press: 1, Enter , 2. You will get the stack with: 0,0,1,2 (from T to X). But if you press Enter after 2 as well and then will inspect the stack it will contain: 0,1,2,2 (withs X register duplicated in Y). This is because of convention applied by HP that Enter moves up the stack and sets some flag what makes the next number entered replace the duplicated X register. If you press Roll down the flag is cleared and the duplicated value remains in X and Y registers
Find all posts by this user
Quote this message in a reply
07-01-2016, 03:27 PM
Post: #4
Expected behavior would not drop the 1 from the stack
wojtek, I think you misunderstand that Antlab said the '1' was missing from the stack.
(07-01-2016 03:16 PM)wojtek Wrote:  
(07-01-2016 02:03 PM)Antlab Wrote:  ... the registers are filled with the sequence:
T: 2.0000
Z: 3.0000
Y: 3.0000
X: 4.0000

This surprises me, because I was expecting the sequence 1, 2, 3, 4.
Probably I am missing some subtlety of the RPN Roll behaviuor, could you please help me to understand what happens?
Thanks.

It is correct (if you press Roll Down after each Enter). I believe all HP rpn calculators behave the same way. Make a quick test and clear the stack (press "clear" and Enter 4 times) then press: 1, Enter , 2. You will get the stack with: 0,0,1,2 (from T to X). But if you press Enter after 2 as well and then will inspect the stack it will contain: 0,1,2,2 (withs X register duplicated in Y). This is because of convention applied by HP that Enter moves up the stack and sets some flag what makes the next number entered replace the duplicated X register. If you press Roll down the flag is cleared and the duplicated value remains in X and Y registers
Find all posts by this user
Quote this message in a reply
07-01-2016, 03:38 PM
Post: #5
RE: Question about Stack and Roll
(07-01-2016 03:27 PM)striegel Wrote:  wojtek, I think you misunderstand that Antlab said the '1' was missing from the stack.
1 is missing because 3 has been duplicated. Of course I do not bet my head that I am correct :-)
Find all posts by this user
Quote this message in a reply
07-01-2016, 04:05 PM
Post: #6
RE: Question about Stack and Roll
(07-01-2016 02:03 PM)Antlab Wrote:  This surprises me, because I was expecting the sequence 1, 2, 3, 4.
Probably I am missing some subtlety of the RPN Roll behaviuor, could you please help me to understand what happens?
Thanks.

The behaviour you should have IMHO is ...

with data entry then with a bunch of roll down
Code:
Key    X  Y  Z  T  L  StackLocked
1      1  ?  ?  ?  ?  ?
ENTER  1  1  ?  ?  ?  yes
2      2  1  ?  ?  ?  yes
ENTER  2  2  1  ?  ?  yes
3      3  2  1  ?  ?  yes
ENTER  3  3  2  1  ?  yes
4      4  3  2  1  ?  yes
RDN    3  2  1  4  ?  no
RDN    2  1  4  3  ?  no
RDN    1  4  3  2  ?  no
RDN    4  3  2  1  ?  no

with data entry mixed with roll down
Code:
Key    X  Y  Z  T  L  StackLocked
1      1  ?  ?  ?  ?  ?
RDN    ?  ?  ?  1  ?  no
RDN    ?  ?  1  ?  ?  no
RDN    ?  1  ?  ?  ?  no
RDN    1  ?  ?  ?  ?  no
2      2  1  ?  ?  ?  no
RDN    1  ?  ?  2  ?  no
RDN    ?  ?  2  1  ?  no
RDN    ?  2  1  ?  ?  no
RDN    2  1  ?  ?  ?  no
3      3  2  1  ?  ?  no
RDN    2  1  ?  3  ?  no
RDN    1  ?  3  2  ?  no
RDN    ?  3  2  1  ?  no
RDN    3  2  1  ?  ?  no
4      4  3  2  1  ?  no
RDN    3  2  1  4  ?  no
RDN    2  1  4  3  ?  no
RDN    1  4  3  2  ?  no
RDN    4  3  2  1  ?  no

Sylvain
Find all posts by this user
Quote this message in a reply
07-01-2016, 04:20 PM
Post: #7
RE: Question about Stack and Roll
Sylvain, you have forgotten Enter after each number in the second example!
I have missed in turn that Antlab pressed Roll down 4 times after each Enter
Find all posts by this user
Quote this message in a reply
07-01-2016, 06:18 PM (This post was last modified: 07-01-2016 11:19 PM by Sylvain Cote.)
Post: #8
RE: Question about Stack and Roll
(07-01-2016 04:20 PM)wojtek Wrote:  Sylvain, you have forgotten Enter after each number in the second example!
I have missed in turn that Antlab pressed Roll down 4 times after each Enter

You are right, but still, I suspect that Antlab did not do exactly what he says he did because I do not have the same result here
Code:
Key    X  Y  Z  T  L  StackLocked
1      1  ?  ?  ?  ?  ?
ENTER  1  1  ?  ?  ?  yes
RDN    1  ?  ?  1  ?  no
RDN    ?  ?  1  1  ?  no
RDN    ?  1  1  ?  ?  no
RDN    1  1  ?  ?  ?  no
2      2  1  1  ?  ?  no
ENTER  2  2  1  1  ?  yes
RDN    2  1  1  2  ?  no
RDN    1  1  2  2  ?  no
RDN    1  2  2  1  ?  no
RDN    2  2  1  1  ?  no
3      3  2  2  1  ?  no
ENTER  3  3  2  2  ?  yes
RDN    3  2  2  3  ?  no
RDN    2  2  3  3  ?  no
RDN    2  3  3  2  ?  no
RDN    3  3  2  2  ?  no
4      4  3  3  2  ?  no
ENTER  4  4  3  3  ?  yes
RDN    4  3  3  4  ?  no
RDN    3  3  4  4  ?  no
RDN    3  4  4  3  ?  no
RDN    4  4  3  3  ?  no

Best regards,

Sylvain

edit: copy/paste error, corrected
Find all posts by this user
Quote this message in a reply
07-01-2016, 06:38 PM
Post: #9
RE: Question about Stack and Roll
(07-01-2016 06:18 PM)Sylvain Cote Wrote:  You are right, but still, I suspect that Antlab did not do exactly what he says he did because I do not have the same result here

Yes, that's possible. It is very easy to make a mistake, for example press Roll down once more or once less instead of 4 times assumed
Find all posts by this user
Quote this message in a reply
07-01-2016, 07:07 PM
Post: #10
RE: Question about Stack and Roll
Thanks a lot.
If I understand correctly, the answer to my doubt is explained by the effects of the flag created by pressing Enter and removed by pressing Roll Down, as Wojtek illustrated. I did not know about the flag, this makes sense now.
Actually, Sylvain, also your example is helpful. I think you obtain a slightly different result because I did not press Enter after inserting the final digit, 4.
I will make some further tests, but I am glad I asked here, because in the manual the question of the flag was not clearly explained.
Find all posts by this user
Quote this message in a reply
07-01-2016, 07:33 PM (This post was last modified: 07-01-2016 07:44 PM by Guenter Schink.)
Post: #11
RE: Question about Stack and Roll
(07-01-2016 02:03 PM)Antlab Wrote:  Hi all.
I have a question for the RPN experts.
To refresh my RPN skills, I am re-reading the original manual of the HP-15C, the Owner's Handbook. I dont' have the original HP-15C, but several Android emulators.
The question is this:
Page 34 of the manual reports the simple example that fills the four registers with the digits 1, 2, 3 and 4.
The normal method is obviously:
1) 1
2) Enter
3) 2
4) Enter
5) 3
6) Enter
7) 4

At this point, with the Roll Down key is possible to inspect and verify the contents of the registers.

My problem is that if I use Roll Down to inspect the register contents after each Enter of the previous sequence (returning each time to the X register) I found at the end that the registers are filled with the sequence:
T: 2.0000
Z: 3.0000
Y: 3.0000
X: 4.0000

This surprises me, because I was expecting the sequence 1, 2, 3, 4.
Probably I am missing some subtlety of the RPN Roll behaviuor, could you please help me to understand what happens?
Thanks.

It's the same on the real 15c. When you enter "1" "Enter" "Rdn" you'll recognise that at the first "Rdn" the "1" blinks shortly and only the next "Rdn" will show another value. If you don't enter other values rather than continue pushing "Rdn" you'll see that "1" is twice on the stack.

And this happens consequently as you continue to enter the numbers 2,3,and 4 this way.
The two "1s" and one of the duplicate "2s" are pushed from the stack, leaving one remaining "2", the two "3s" and finally the "4".

Page 33 of the manual. "enter"copies the number in the display to the y-register and prepares the x-register (display) for another input. But when you don't enter a number but execute a function (e.g. sin, ln) this will be done on the x-register. "Rdn" also is such a function, therefore you end up with the y and x-register having the same content and actually the "Rdn" didn't do a roll down yet.

HTH, Günter

Edit: have a look at appendix B "Stack lift ..."
Find all posts by this user
Quote this message in a reply
07-02-2016, 04:52 PM
Post: #12
RE: Question about Stack and Roll
Hi Guenter,
thanks for the further explanation.
Following your suggestion, I also checked the Appendix B of the manual. The problem, in my opinion, is that the precise behaviour of the Roll function is not well described. For this reason I am happy I asked here in the forum, now I have a clear answer to my original doubt.
Find all posts by this user
Quote this message in a reply
07-02-2016, 06:24 PM (This post was last modified: 07-02-2016 06:25 PM by Guenter Schink.)
Post: #13
RE: Question about Stack and Roll
(07-02-2016 04:52 PM)Antlab Wrote:  Hi Guenter,
thanks for the further explanation.
Following your suggestion, I also checked the Appendix B of the manual. The problem, in my opinion, is that the precise behaviour of the Roll function is not well described. For this reason I am happy I asked here in the forum, now I have a clear answer to my original doubt.

Yes perhaps it could be explained better. But if you look at the top of page 210, you'll read that there are only 4 "Stack disabling functions". Further, on page 211 neutral operations are listed with their specific behaviour described. "Rdn" isn't on either list, so...

Günter
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)