4-level stack manipulation on 12c - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: General Forum (/forum-4.html) +--- Thread: 4-level stack manipulation on 12c (/thread-3236.html) |
4-level stack manipulation on 12c - Don Shepherd - 03-02-2015 03:18 AM 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? RE: 4-level stack manipulation on 12c - Mark Hardman - 03-02-2015 03:40 AM (03-02-2015 03:18 AM)Don Shepherd Wrote: If my 4-level stack on my 12c contains: If you also allow Rup it can be done in six steps: Code:
The Rup can be replaced with three Rdn for a total of eight steps: Code:
I'm sure someone can do better. RE: 4-level stack manipulation on 12c - Dale Reed - 03-02-2015 03:40 AM 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 RE: 4-level stack manipulation on 12c - Dale Reed - 03-02-2015 03:50 AM 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" RE: 4-level stack manipulation on 12c - PANAMATIK - 03-02-2015 03:57 AM (03-02-2015 03:18 AM)Don Shepherd Wrote: If my 4-level stack on my 12c contains: Code: t z x x y x z z x y y Bernhard RE: 4-level stack manipulation on 12c - Mark Hardman - 03-02-2015 03:59 AM (03-02-2015 03:50 AM)Dale Reed Wrote: Mark, I would say that great minds think alike. ;-) RE: 4-level stack manipulation on 12c - Paul Dale - 03-02-2015 08:14 AM 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 RE: 4-level stack manipulation on 12c - Csaba Tizedes - 03-02-2015 08:19 AM (03-02-2015 03:18 AM)Don Shepherd Wrote: If my 4-level stack on my 12c contains: Sigma+ RCL 2 RCL 4 RCL 2 But it does not count (...too many preconditions). RE: 4-level stack manipulation on 12c - PANAMATIK - 03-02-2015 10:48 AM (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 RE: 4-level stack manipulation on 12c - RayAtHP - 03-02-2015 11:40 AM (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). Stretching the preconditions a bith further and assuming 17 and 5 are on the stack: 2dup ... hp71b in forth mode. RE: 4-level stack manipulation on 12c - Werner - 03-02-2015 12:28 PM 6 steps: Code: ENTER Cheers, Werner RE: 4-level stack manipulation on 12c - Sylvain Cote - 03-02-2015 12:31 PM (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" RE: 4-level stack manipulation on 12c - Csaba Tizedes - 03-02-2015 12:45 PM (03-02-2015 12:28 PM)Werner Wrote: 6 steps: Yes, this is REALLY elegant! Grat! RE: 4-level stack manipulation on 12c - Don Shepherd - 03-02-2015 01:49 PM (03-02-2015 12:28 PM)Werner Wrote: 6 steps: 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 RE: 4-level stack manipulation on 12c - Gene - 03-02-2015 03:30 PM 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. RE: 4-level stack manipulation on 12c - Don Shepherd - 03-02-2015 03:53 PM 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 RE: 4-level stack manipulation on 12c - Marcus von Cube - 03-03-2015 10:54 PM (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 RE: 4-level stack manipulation on 12c - PedroLeiva - 03-03-2015 11:25 PM 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 RE: 4-level stack manipulation on 12c - Massimo Gnerucci - 03-04-2015 06:52 AM (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 Same as Gene's. :) RE: 4-level stack manipulation on 12c - PedroLeiva - 03-04-2015 09:50 AM (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 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 |