Communicating stack state transitions, a notation.


I will try using the following notation to communicate RPN program's effect on the stack and LASTX register:

[d,c,b,a][e]->oper. desc.->[d',c',b',a'][e']

The first array with four elements represents the stack where d and d' refers to content of the T stack register and a and a' to content in the X stack register. The e and e' in the single element
array refers to the LASTX register's content. Ofcourse actual letters or words used may be choosen to so fit the input/output for particular program.

So for example to describe sqrt:


and addition:


Ofcourse there are other (better?) ways using tables or some kind of bar diagram but think this may work and have the advantage of being easy and fast to type in text only documents.

Anyone of your long time rpn hackers having an opinion on this topic?


Hi, Arne:

Obviously it would be far easier on the eyes and more useful if you would use X, Y, Z, T and L instead of a, b, c, d and e, like this:

[X, Y, Z, T | L] -> Sqrt -> [Sqrt(X), Y, Z, T | X ]

or a variation thereof.

Best regards from V.

Edited: 9 Oct 2007, 6:17 p.m. after one or more responses were posted


Small details, but think your way of | replacement for my 'two array' notation looks better, will use.

As for the actual letters, think may become confusing if variable bound to orginal position in register; there may be a chain of operation... And if x contains speed of light; use c.

Now, for me LEFT maps to TOP (i.e. T) and I always think of LASTX as 'below' X register... Interesting that you turned it around! Perhaps most people find yours more natural, perhaps its because I am lefthanded :-).

Hmmm, actual that is perhaps more readable... must think about it... to bad there aint enough people interested in this detail to have a poll!


Edited: 9 Oct 2007, 6:17 p.m.


God dag Arne,

I like Valentin's notation better because the x-level -- which will change most frequently -- appears leftmost, i.e. first for people reading from left to right.

Just my 20 milli-Euro


Hi Arne,

I agree with Valentin and Walter.

It's the notation I have been using since my first steps in RPN.

Best regards


I have arrived at the same conclusion myself... Good thing I asked :-)


I would advocate following the stack notation practices used with the programming language Forth. The lowest items on the stack appear to the right, only the applicable levels appear, and two dashes separate the 'before' and 'after' snapshots.

For example:

( y x -- y+x )
would be a compact representation for the '+' key.

If you want to explicitly show the entire stack (and Last X register) this could become

( t z y x | a -- t t z y+x | x ) 

Usually the stack comments would try to convey a little more meaning, such as:

( Lat1 Lon1 Lat2 Lon2 -- Bearing )

to document that calculates the initial great circle bearing
to fly from point 1 to point 2.


Interesting, I remember in my young days there was a lot of talk about the FORTH language... The notation is good and very similar to Valentin's proposal I have addopted (good I did not go ahead with my orginal syntax). I do agree names should reflect nature of value. I use X, Y, Z, T, L for the 'bystanders'...

Possibly Related Threads…
Thread Author Replies Views Last Post
  HP Prime reset to factory state? BruceH 3 4,995 11-26-2013, 07:27 PM
Last Post: BruceH
  HP 50g - select characters on the stack, copy/paste Sean Freeman 7 2,704 11-20-2013, 07:11 AM
Last Post: Sean Freeman
  Prime: Placing more than 1 item on the RPN stack in a single program? John Colvin 4 2,250 11-19-2013, 08:59 AM
Last Post: Miguel Toro
  [Download] libhpcalcs: a toolkit for communicating with Prime calcs... debrouxl 13 4,470 11-18-2013, 05:22 AM
Last Post: debrouxl
  HP Prime: Converting number to Sci notation and back BruceTTT 1 1,557 11-12-2013, 02:11 AM
Last Post: Phil Wipf
  emu48 - copy stack doesn't work (as expected) Thomas Radtke 2 1,963 11-11-2013, 02:19 PM
Last Post: Thomas Radtke
  HP Prime Stack operations from within a program John Colvin 1 1,371 11-08-2013, 09:45 PM
Last Post: Helge Gabert
  Prime: Anyway to refresh stack? kris223 5 2,121 10-16-2013, 05:09 PM
Last Post: kris223
  hp prime - sending program results to the stack giancarlo 6 2,088 10-15-2013, 02:00 AM
Last Post: Giancarlo
  HP Prime - RPN stack access from programs? Mike Mander (Canada) 10 3,393 09-30-2013, 11:20 AM
Last Post: steindid

Forum Jump: