HP-12C TUTORIAL
T
Z
Y
X

The HP automatic memory stack and its associated logic, RPN, is the most efficient method available for solving complex problems. RPN, HP's logic system, was named in honor of a logic notation devised by the Polish mathematician Jan Lukasiewicz. In 1951, he showed that arbitrary mathematical expressions could be specified unambiguously without parentheses. Originally developed to make the evaluation of algebraic expressions as simple as possible, RPN has been implemented in HP calculators be means of the stack and postfix operators. The term "postfix operators" simply means that you specify the operation to be performed after, rather than before, you specify the number or numbers involved. RPN enables you to see all intermediate answers, to recover easily from errors, to reuse numbers without reentering them, to solve problems one step at a time, and to evaluate virtually any expression without copying and remembering parentheses.

Four special registers in the HP-12C are used for storing numbers during calculations. To understand how these registers are used, they should be visualized as stacked on top of each other. (For this reason, they are generally referred to as the "stack registers" or collectively as "the stack.") The stack registers are designated X, Y, Z, and T. The number shown in the display is the number in the X-register (modified according to the current display format).

The number in the X-register--and, for two-number functions, the number in the Y-register--are the number(s) used in calculations. The Z- and T-registers are used primarily for automatic retention of intermediate results during chain calculations, as described below.

Let's take a quick look at how the stack is used in a simple arithmetic calculation and in a chain calculation. For each key pressed in the keysroke sequence, the diagram illustrating the calculation shows, above the key, the numbers in each of the stack registers after that key is pressed.

First, let's consider the calculation of 5 - 2:

T-reg 0 0 0 0
Z-reg 0 0 0 0
Y-reg 0 5 5 0
X-reg 5 5 2 3
Keys 5 E
N
T
E
R
2 -

The diagram shows why the ENTER key separates the second number from the first number entered. The ENTER key copies the number from the displayed X-register into the Y-register. It simultaneously "lifts" the stack by also copying the former contents of the Y-register into the Z-register and the former contents of the Z-register into the T-register. The former contents of the T-register are lost as the stack is raised. Note also that this positions the 5 in the Y-register above the 2 in the X-register--just like they would be positioned if you wrote the calculation vertically on paper.

5
-2
---

Now let's see what happens in the stack during a chain calculation:

     (3 * 4) + (5 * 6)
1 + -------------------
    7

T-reg 0 0 0 0 0 0 0 1 1 1 1 1 1 1
Z-reg 0 0 0 1 1 0 1 12 12 1 1 1 1 1
Y-reg 0 1 1 3 3 1 12 5 5 12 1 42 1 1
X-reg 1 1 3 3 4 12 5 5 6 30 42 7 6 7
Keys 1 E
N
T
E
R
3 E
N
T
E
R
4 * 5 E
N
T
E
R
6 * + 7 / +

Try the above example and others for yourself using the calculator provided above and see how the stack changes with each entry.

See how the intermediate results are not only displayed when they are calculated, but also automatically stored and available in the stack at just the right time!