Saturday, December 14, 2024

RPN with HP 15C & DM32: Swapping Items in the Stack

RPN with HP 15C & DM32: Swapping Items in the Stack



A New Series


Welcome to a new series: RPN with the HP 15C & DM32. The DM32 is the Swiss Micros updated calculator of the popular model HP 32SII. The intended schedule for this series is the second Saturday starting now until at least December 13, 2025.



Product Information:


Hewlett Packard HP 15C Collector’s Edition: https://www.thecalculatorstore.com/p/hp15c-collector-s-edition-2


Swiss Micros DM15L: https://www.swissmicros.com/product/dm15l


Hewlett Packard HP 32SII (original, late 1980s-1990s, video by Logan West): https://www.youtube.com/watch?v=g4eP5ckeo9g


Swiss Micros DM32: https://www.swissmicros.com/product/model-dm32


There here plenty of emulators for the HP 15C for the smartphone, both Android and Apple iPhone iOS.



Swapping the Stack’s Elements


Our first installment of the series deals with swapping elements of the stack. Like most RPN calculators, the HP 15C and DM32 have four stack levels.


T

Z

Y

X


The stack contains four values. On the HP 15C, the stack can also contain complex numbers and matrices.


On most RPN calculators, the stack is a Rolodex of four values. The can be scrolled up (R↑) and down (R↓). The contents of the x and y stack values can be swapped by the swap key (x<>y). On RPN calculators that show one line, like the HP 15C, the value that is shown is the X stack. Some RPN calculators, such as the DM32, show all four stack levels (X, Y, Z, and T).


The following keystrokes the values on two stack levels using the stack operations R↑, R↓, and x<>y. They are multiple algorithms to accomplish each task, I will present one for each.


For illustration purposes, an example stack always starts out as:

T: 40

Z: 30

Y: 20

X: 10


You don’t need to key in these numbers, this is for illustration purposes.

Swap X and Y: x<>y

Result:

T: 40

Z: 30

Y: 10

X: 20


Swap X and Z: x<>y, R↓, R↓, x<>y, R↓

Result:

T: 40

Z: 10

Y: 20

X: 30


Swap X and T: R↑, x<>y, R↓

Result:

T: 10

Z: 30

Y: 20

X: 40


Swap Y and Z: R↓, x<>y, R↑

Result:

T: 40

Z: 20

Y: 30

X: 10


Swap Y and T: R↓, x<>y, R↓, R↓, x<>y

Result:

T: 20

Z: 30

Y: 40

X: 10


Swap Z and T: R↓, R↓, x<>y, R↓, R↓

Result:

T: 30

Z: 40

Y: 20

X: 10


An excellent resource to use is Better Program on the HP-67/97, a PPC Publication, edited by William Kolb, John Kennedy, and Richard Nelson (1978). https://www.cuveesoft.ch/rpn67/img/HP67%20Better%20Programming%20PPC.pdf



Eddie


All original content copyright, © 2011-2024. 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.

TI 84 Plus CE: Consolidated Debts

TI 84 Plus CE: Consolidated Debts   Disclaimer: This blog is for informational and academic purposes only. Financial decisions are your ...