Sunday, November 8, 2026

Classic RPN Stack Operations

 Classic RPN Stack Operations


Starting Stack:



T:  d

Z:  c

Y:  b

X:  a


OVER:   Copies b to the Z and X stacks, while leaving a in the Y stack.   c is pushed to the T stack.


T:  d  -> c
Z:  c  -> b
Y:  b -> a
X:  a -> b


RPN Keystrokes:

x<>y
ENTER
R↓
x<>y
R↑



ROT:  Rotate Up.   The contents of the T stack is untouched.



T:  d  -> d
Z:  c  -> b
Y:  b -> a
X:  a -> c


RPN Keystrokes:

R↓
R↓
x<>y
R↓



UNROT:  Rotate Down.   The contents of the T stack is untouched.

T:  d  -> d
Z:  c  -> a
Y:  b -> c
X:  a -> b


RPN Keystrokes:

R↑
X<>Y
R↑
R↑


DROP:  Drops the contents of the X stack.   It is named DROPX on the R47.  d is copied onto the Z stack.  



T:  d  -> d
Z:  c  -> d
Y:  b -> b
X:  a -> c


RPN Keystrokes:

CL x
+



NIP:  Drops the contents of the Y stack.   It is named DROPY on the R47.  d is copied onto the Z stack.  

T:  d  -> d
Z:  c  -> d
Y:  b -> c
X:  a -> a


RPN Keystrokes:

x<>y
CL x
+



DROP2:  Deletes a and b from the X and Y stacks, respectively, and replaces them with c and d.  



T:  d  -> 0
Z:  c  -> 0
Y:  b -> d
X:  a -> c


RPN Keystrokes:

R↓
CL x
ENTER
R↓
R↓



DUP2:  Duplicates a and b on to the Z and T stacks, respectively.

(Ball, John A.  Algorithms for RPN Calculators.  John Wiley & Sons, Inc. New York, NY.  1978)



T:  d  -> b
Z:  c  -> a
Y:  b -> b
X:  a -> a


RPN Keystrokes:

ENTER
ENTER
CL x
-
R↓
x<>y
R↓




Eddie


All original content copyright, © 2011-2026. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.



Classic RPN Stack Operations

  Classic RPN Stack Operations Starting Stack: T:  d Z:  c Y:  b X:  a OVER :   Copies b to the Z and X stacks, while leaving ...