The Museum of HP Calculators

HP Forum Archive 20

[ Return to Index | Top of Index ]

HP RPN stack permutations graph
Message #1 Posted by Xavier A. (Brazil) on 18 May 2011, 9:47 a.m.

Hello happy few,

After reading – very lately, I confess - the excellent French book « Programmer HP-41 » published in the 80’s, I decided to redraw the « Logigraphe » of page 41, very confused to everyone, even to French people (yes, it’s possible).

The « Logigraphe » is the graph of all permutations available in the RPN (4 elements) stack, a very useful tool to anyone who wants to program a calc from HP-65 to 16c model. You can view and read the original document here:

Link to Programmer HP-41's PDF version

Using this strange map is simple : focus on the beginning of the graph, search for the aimed combination, and find the shortest path using Rd, x<->y, etc.

Nevertheless in these ancient times without OpenOffice, drawing a good graph was not easy, and this document appears 30 years later a bit old-fashioned. By thanking the two writers P. Descamps & J.-J. Dhénin for this wonderful book and their precious work, I chose to publish this new graph (a flattened truncated octahedron) which will be perhaps useful to some people, at least in this museum.

Here it is :

HP RPN stack permutations graph PDF version

For any OpenOffice version, please mail me.

Many thanks to Luiz C. Vieira for his HP fonts.

Xavier

Post Scriptum : I didn’t read every documentation about it (!), and perhaps this graph is a very old idea published already in some country… In this case, I do apologize for this wasted time of reading. If not, maybe that a further step in this direction (in my humble opinion) would be an HP-41 program to inform the shortest path for any permutation combining the 4-elements stack plus the L register : the 120 permutations are by far too many for a simple 2D-graph.

      
Re: HP RPN stack permutations graph
Message #2 Posted by x34 on 18 May 2011, 4:06 p.m.,
in response to message #1 by Xavier A. (Brazil)

Excellent idea, I'll try to do 35s version adding Lastx and xyzt stack commands.

      
Re: HP RPN stack permutations graph
Message #3 Posted by Paul Dale on 18 May 2011, 5:53 p.m.,
in response to message #1 by Xavier A. (Brazil)

This reminds me of a command I had in the WP-34s for a while.

    SHFL abcde

Where a, b, c, d & e are all from the set { X, Y, Z, T, L } allowing duplication.

This command shuffled the stack and LastX register in any permutation. For example:

  • SHFL YXZTL was X<>Y
  • SHFL YZTXL was Rv
  • SHFL TXYZL was R^
  • SHFL LXYZL was LastX
  • SHFL XXXXL was FILL

Anyway, these examples ought to give an idea of the kinds of things that were possible.

- Pauli

            
Re: HP RPN stack permutations graph
Message #4 Posted by Walter B on 19 May 2011, 1:55 a.m.,
in response to message #3 by Paul Dale

Now imagine that for an 8-level stack [:-)

                  
Re: HP RPN stack permutations graph
Message #5 Posted by Paul Dale on 19 May 2011, 2:34 a.m.,
in response to message #4 by Walter B

We didn't have an eight level stack nor plans for one then :-)

- Pauli

                  
Re: HP RPN stack permutations graph
Message #6 Posted by exschr on 19 May 2011, 4:27 a.m.,
in response to message #4 by Walter B

Quote:
Now imagine that for an 8-level stack [:-)
Poor fellow that gets the assignement to draw that graph!
;^)
                        
Re: HP RPN stack permutations graph
Message #7 Posted by Paul Dale on 19 May 2011, 5:30 a.m.,
in response to message #6 by exschr

The nice bit about the stack shuffle is that the graph becomes very simple. Everything is one step away from the initial stack state.

- Pauli

                              
Re: HP RPN stack permutations graph
Message #8 Posted by Marcus von Cube, Germany on 19 May 2011, 5:47 a.m.,
in response to message #7 by Paul Dale

But will such a command fit our op code scheme? I doubt it. And what do you do if the stack depth is set to 4 and you encounter a command that treats all 8 or 9 registers? What about complex mode?

If we could ignore LastX and allow shuffling of ABCD in any mode, things become easier. Then we only need an abbreviated notation so that only registers which are to be affected are named such as SHFL ZXY. This would leave T, A, B, C and D alone. We would still need 3 bits per register in eight positions, totaling 24 bits for every possible combination.

Edited: 19 May 2011, 5:47 a.m.

                                    
Re: HP RPN stack permutations graph
Message #9 Posted by Paul Dale on 19 May 2011, 6:00 a.m.,
in response to message #8 by Marcus von Cube, Germany

There were only four stack levels plus last x when I implemented this and 5^5 fitted easily. I even contemplated allowing 0 as well :-)

- Pauli

      
Re: HP RPN stack permutations graph
Message #10 Posted by Frido Bohn on 19 May 2011, 7:38 a.m.,
in response to message #1 by Xavier A. (Brazil)


Interestingly, already in the "HP-45 Applications Book" a Section "Stack Register Operations" describes how to manipulate the stack.
It has not the nice graphical representation but shows the keystrokes to be applied, and also interestingly, what HP considered to be noteworthy:

  • Clear stack
  • Delete x
  • Delete y
  • Reverse the stack
  • Fetch t or roll up
  • Fetch t to Y
  • Fetch z
  • Copy x into Z and T
  • Copy y into Z
  • Copy y into Z and T
  • Copy y and x into Z and T respectively
  • Copy y and x into T and Z respectively
  • Swap x and rk [k: number of storage register]
  • Swap y and z
  • Swap z and t
  • Swap x and t
  • Swap x and z
  • Swap y and t
            
Re: HP RPN stack permutations graph
Message #11 Posted by Jake Schwartz on 19 May 2011, 1:08 p.m.,
in response to message #10 by Frido Bohn

Hi,

Has anybody seen John Ball's book, "Algorithms for RPN Calculators"? It has a stack-permutations chart in there that is at least 30 pages long for RPN permutations related to machines from the "Classic Series" era.

Jake

                  
Re: HP RPN stack permutations graph
Message #12 Posted by Thomas Chrapkiewicz on 19 May 2011, 6:54 p.m.,
in response to message #11 by Jake Schwartz

I believe I have a copy.

                  
Re: HP RPN stack permutations graph
Message #13 Posted by Allen on 19 May 2011, 9:55 p.m.,
in response to message #11 by Jake Schwartz

Agree with Jake. Ball was the "Donald Knuth" of HP stack permutations.

                        
Re: HP RPN stack permutations graph
Message #14 Posted by Xavier A. (Brazil) on 20 May 2011, 12:46 p.m.,
in response to message #13 by Allen

Thank you for all your comments. I shall have a look at those books.

Edited: 20 May 2011, 5:38 p.m.

                  
Re: HP RPN stack permutations graph
Message #15 Posted by exschr on 20 May 2011, 6:54 p.m.,
in response to message #11 by Jake Schwartz

Quote:
Has anybody seen John Ball's book, "Algorithms for RPN Calculators"?
check this out: TAS offer


[ Return to Index | Top of Index ]

Go back to the main exhibit hall