NeoCal Documentation

NeoCal for Palm OS User Guide

Automatic Memory Stack

The RPN input method is based upon working with numbers stored in the automatic memory stack, which consists of the x, y, z, and t registers. The stack lift and drop operations are performed automatically and are key to understanding its use. Imagine the registers stacked on top of each other with t (on the top) above z, which is above y, which is above x. Both the lift and drop operations cause values to be shifted to an adjacent register, but shift in opposite directions.

The stack lift operation is performed to make room for a new value in the x register: the value in the t register is thrown away, the t register gets the z value, the z register gets the y value, and the y register gets the x value. This allows the new x value to be stored while preserving the original x value (in the y register).

The stack drop operation is performed when an operation requiring two operands is executed: the t register remains unaffected, the z register gets the t value, the y register gets the z value, and the x register gets the y value. The result of the calculation is then stored in the x register, effectively combining (or consuming) the original x and y values. Notice that the value in the t register is propagated downward. This is useful for operations involving multiple uses of a constant value.

Calculator operations can be categorized as either lifting the stack, dropping the stack, or neither lifting nor dropping the stack. Also, some operations disable stack lift, meaning that if the next operation normally lifts the stack, then the stack won't be lifted. Or, if the next operation lifts the stack twice, the stack will only be lifted once.

Let's look at a simple example to calculate the square of the sum of two numbers,

  1. Press to enter the number 4. Entering a number is a stack lifting operation, so the previously displayed value is moved into the y register.
  2. Press to separate the two numbers. This operation lifts the stack and then disables stack lift (see the next section for details on the enter button). The number 4 is now stored in both the x and y registers.
  3. Press to enter the second number. Since stack lift was disabled, 5 is simply stored in the x register.
  4. Press to add the numbers stored in the x and y registers, drop the stack, and then store the result in the x register. The number that was displayed before we started this example is now stored in the y register.
  5. Press to calculate the square of the displayed number. This operation does not lift nor drop the stack; only the value in the x register is modified.

By default the stack contains four values, but the stack size can be increased in the Preferences dialog.