Post Reply 
4-level stack manipulation on 12c
03-02-2015, 03:18 AM
Post: #1
4-level stack manipulation on 12c
If my 4-level stack on my 12c contains:

t - don't care
z - don't care
y - 17
x - 5

and I want it to contain:

t - 17
z - 5
y - 17
x - 5

is there an elegant way to achieve that using only ENTER, roll down, and x<->y?
Find all posts by this user
Quote this message in a reply
03-02-2015, 03:40 AM (This post was last modified: 03-02-2015 03:40 AM by Mark Hardman.)
Post: #2
RE: 4-level stack manipulation on 12c
(03-02-2015 03:18 AM)Don Shepherd Wrote:  If my 4-level stack on my 12c contains:

t - don't care
z - don't care
y - 17
x - 5

and I want it to contain:

t - 17
z - 5
y - 17
x - 5

is there an elegant way to achieve that using only ENTER, roll down, and x<->y?

If you also allow Rup it can be done in six steps:

Code:

Enter, Enter, Rup, Enter, Rdn, x<>y

t   0    0   17    5    5   17   17
z   0   17    5    5    5    5    5
y  17    5    5    5   17    5   17
x   5    5    5   17   17   17    5

The Rup can be replaced with three Rdn for a total of eight steps:

Code:

Enter, Enter, Rdn, Rdn, Rdn, Enter, Rdn, x<>y

t   0    0   17    5    5    5    5   17   17
z   0   17    5   17    5    5    5    5    5
y  17    5    5    5   17    5   17    5   17
x   5    5    5    5    5   17   17   17    5

I'm sure someone can do better.

Ceci n'est pas une signature.
Find all posts by this user
Quote this message in a reply
03-02-2015, 03:40 AM
Post: #3
RE: 4-level stack manipulation on 12c
I'm sure someone will find an 'elegant' way in fewer steps, but:

---
---
17
5 Enter ^

---
17
5
5 Enter ^

17
5
5
5 R v

5
17
5
5 R v

5
5
17
5 R v

5
5
5
17 Enter ^

5
5
17
17 R v

17
5
5
17 x <> y

17
5
17
5 Task complete

Total 8 operations.
Yep, somebody will definitely find a shorter one. But at least this is straightforward. ;-)

Dale
Find all posts by this user
Quote this message in a reply
03-02-2015, 03:50 AM
Post: #4
RE: 4-level stack manipulation on 12c
Mark,

I guess us old HP-25 users think similarly... and simultaneously! It may chew up 8 steps, but at least it's easy to remember. Repeat after me:

"Enter - Enter - Down Down Down - Enter - Down - Exchange"
Find all posts by this user
Quote this message in a reply
03-02-2015, 03:57 AM (This post was last modified: 03-02-2015 04:02 AM by PANAMATIK.)
Post: #5
RE: 4-level stack manipulation on 12c
(03-02-2015 03:18 AM)Don Shepherd Wrote:  If my 4-level stack on my 12c contains:

t - don't care
z - don't care
y - 17
x - 5

and I want it to contain:

t - 17
z - 5
y - 17
x - 5

is there an elegant way to achieve that using only ENTER, roll down, and x<->y?

Code:
 t z x x y x z z x y y
 z y z z x y x x x x x
 y x y x z x y x y x y
 x x x y x z x y y y x
Perhaps not the fastest approach, but it was asked to be elegant!
Bernhard
Find all posts by this user
Quote this message in a reply
03-02-2015, 03:59 AM (This post was last modified: 03-02-2015 04:05 AM by Mark Hardman.)
Post: #6
RE: 4-level stack manipulation on 12c
(03-02-2015 03:50 AM)Dale Reed Wrote:  Mark,

I guess us old HP-25 users think similarly... and simultaneously! It may chew up 8 steps, but at least it's easy to remember. Repeat after me:

"Enter - Enter - Down Down Down - Enter - Down - Exchange"

I would say that great minds think alike.

;-)

Ceci n'est pas une signature.
Find all posts by this user
Quote this message in a reply
03-02-2015, 08:14 AM
Post: #7
RE: 4-level stack manipulation on 12c
In fewer keystrokes but not sticking to the operations available:

Assuming that: 17 ENTER 5 has already occurred.

Then:
Code:
        1 7 ENTER 5

Pauli
Find all posts by this user
Quote this message in a reply
03-02-2015, 08:19 AM
Post: #8
RE: 4-level stack manipulation on 12c
(03-02-2015 03:18 AM)Don Shepherd Wrote:  If my 4-level stack on my 12c contains:

t - don't care
z - don't care
y - 17
x - 5

and I want it to contain:

t - 17
z - 5
y - 17
x - 5

is there an elegant way to achieve that using only ENTER, roll down, and x<->y?

Sigma+
RCL 2
RCL 4
RCL 2


But it does not count (...too many preconditions).
Find all posts by this user
Quote this message in a reply
03-02-2015, 10:48 AM
Post: #9
RE: 4-level stack manipulation on 12c
(03-02-2015 08:19 AM)Csaba Tizedes Wrote:  But it does not count (...too many preconditions).

If preconditions are allowed:

RCL 0 (R0 contains 17)
RCL 1 (R1 contains 5)

Shortest key sequence with preconditions allowed:

R/S Smile
Find all posts by this user
Quote this message in a reply
03-02-2015, 11:40 AM
Post: #10
RE: 4-level stack manipulation on 12c
(03-02-2015 10:48 AM)PANAMATIK Wrote:  
(03-02-2015 08:19 AM)Csaba Tizedes Wrote:  But it does not count (...too many preconditions).

If preconditions are allowed:

RCL 0 (R0 contains 17)
RCL 1 (R1 contains 5)

Shortest key sequence with preconditions allowed:

R/S Smile

Stretching the preconditions a bith further and assuming 17 and 5 are on the stack:

2dup

... hp71b in forth mode.

Best regards -Ray
Find all posts by this user
Quote this message in a reply
03-02-2015, 12:28 PM
Post: #11
RE: 4-level stack manipulation on 12c
6 steps:

Code:
ENTER
ENTER
-
RDN
X<>Y
LASTX

Cheers, Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
03-02-2015, 12:31 PM
Post: #12
RE: 4-level stack manipulation on 12c
(03-02-2015 03:18 AM)Don Shepherd Wrote:  is there an elegant way to achieve that using only ENTER, roll down, and x<->y?

The attached file contains all the possible stack manipulation.
From the french book "Programmer HP-41"


Attached File(s) Thumbnail(s)
   
Find all posts by this user
Quote this message in a reply
03-02-2015, 12:45 PM
Post: #13
RE: 4-level stack manipulation on 12c
(03-02-2015 12:28 PM)Werner Wrote:  6 steps:

Code:
ENTER
ENTER
-
RDN
X<>Y
LASTX

Cheers, Werner

Yes, this is REALLY elegant! Grat!
Find all posts by this user
Quote this message in a reply
03-02-2015, 01:49 PM
Post: #14
RE: 4-level stack manipulation on 12c
(03-02-2015 12:28 PM)Werner Wrote:  6 steps:

Code:
ENTER
ENTER
-
RDN
X<>Y
LASTX

Cheers, Werner

Well, I have to agree with Csaba. Elegant!

I hadn't thought about LastX, I admit, but you sure made good use of that function in this case.

Thanks to all. Lots of great minds out there.

Don
Find all posts by this user
Quote this message in a reply
03-02-2015, 03:30 PM (This post was last modified: 03-02-2015 03:33 PM by Gene.)
Post: #15
RE: 4-level stack manipulation on 12c
Tony Hutchins gave this 7-step solution without using LASTX.

ENTER
ENTER
CLx
-
Roll Down
X<>Y
Roll Down

But more importantly, the PDF where this and a large number of such ideas is found here:

Stack Rearrangements

You can find this solution by searching for ABAB, which represents XYXY as the contents of the four level RPN stack.
Find all posts by this user
Quote this message in a reply
03-02-2015, 03:53 PM (This post was last modified: 03-02-2015 05:41 PM by Don Shepherd.)
Post: #16
RE: 4-level stack manipulation on 12c
Thanks Gene. A fascinating book.

I just realized I have the book upon which Tony's book is based, "Algorithms for RPN Calculators," in my bookcase!

But I wouldn't have known about Werner's 6-step solution from that book, I suppose.

Don
Find all posts by this user
Quote this message in a reply
03-03-2015, 10:54 PM (This post was last modified: 03-03-2015 10:57 PM by Marcus von Cube.)
Post: #17
RE: 4-level stack manipulation on 12c
(03-02-2015 03:30 PM)Gene Wrote:  Stack Rearrangements

That's why we have included the shuffle command ⇄ in the 34S. It allows to shuffle the lower four stack levels in an arbitrary fashion with a single command. The main purpose of this command is readability in a program but it works interactively as well. To accomplish the requested task the command would be:

Code:
⇄ XYXY

Self explanatory, isn't it?

A solution that works for all calculators which can directly recall the stack:

Code:
RCL Y
RCL Y

Marcus von Cube
Wehrheim, Germany
http://www.mvcsys.de
http://wp34s.sf.net
http://mvcsys.de/doc/basic-compare.html
Find all posts by this user
Quote this message in a reply
03-03-2015, 11:25 PM
Post: #18
RE: 4-level stack manipulation on 12c
When I saw the discussion of management of operational scale I remembered a paper from Tony Hutching where the author presents a series of tables to relocate data (see attached). Perhaps it would be useful to analyze this issue

I take this opportunity to ask for a brief management explanation of Tony job and if it is useful today for programming the HP 35s calculator. Thank you very much for your attention, Pedro


Attached File(s)
.pdf  xyzt - Tony Huttchiins Tables.pdf (Size: 301.28 KB / Downloads: 90)
Find all posts by this user
Quote this message in a reply
03-04-2015, 06:52 AM
Post: #19
RE: 4-level stack manipulation on 12c
(03-03-2015 11:25 PM)PedroLeiva Wrote:  When I saw the discussion of management of operational scale I remembered a paper from Tony Hutching where the author presents a series of tables to relocate data (see attached). Perhaps it would be useful to analyze this issue

I take this opportunity to ask for a brief management explanation of Tony job and if it is useful today for programming the HP 35s calculator. Thank you very much for your attention, Pedro

Same as Gene's.
:)

Greetings,
    Massimo

-+×÷ ↔ left is right and right is wrong
Visit this user's website Find all posts by this user
Quote this message in a reply
03-04-2015, 09:50 AM
Post: #20
RE: 4-level stack manipulation on 12c
(03-04-2015 06:52 AM)Massimo Gnerucci Wrote:  
(03-03-2015 11:25 PM)PedroLeiva Wrote:  When I saw the discussion of management of operational scale I remembered a paper from Tony Hutching where the author presents a series of tables to relocate data (see attached). Perhaps it would be useful to analyze this issue

I take this opportunity to ask for a brief management explanation of Tony job and if it is useful today for programming the HP 35s calculator. Thank you very much for your attention, Pedro

Same as Gene's.
Smile

My apologies. I read over what Gene had written, and did not open the file. Sorry. But I still wonder if Tony tables are useful today, and what is the reason of saving so much programming steps. Pedro
Find all posts by this user
Quote this message in a reply
Post Reply 




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