AddMach Documentation
---------------------

Paperless Adding Machine for HP48

By Craig A. Finseth

What it does:

This set of routines provides all of the operations[*] that are
commonly found on adding machines.  Instead of a paper printout,
however, the list of numbers is stored electronically and can be
reviewed and edited.

[*] The multiplication operation is implemented in a way different
than found on adding machines.  Division and percent are not
implemented at all.

------------------------------------------------------------
Basic Operation:

Change to the directory that contains the code.  Press CST.

Operations are:

+	Add the number in level 1 to the list.  If the stack is empty,
	use the last number entered.  The number is inserted in the list
	after the item displayed.
-	Subtract the number in level 1 from the list.  If the stack is
	empty, use the last number entered.  The number is inserted in
	the list after the item displayed.
S	Subtotal: compute the total and copy it to the last number entered.
T	Total: compute the total and copy it to the last number
	entered.  Also clear the list.
*	Store the number in level 1 as the repeat count and the number
	in level 2 as the value.  The numbers are inserted in the list
	after the item displayed.  If the stack is empty or has only one
	number, treat is as if the operation was +.
DISP	Show the status display.
 <\ DISP	Toggle the status display.
 /> DISP	Toggle the status display.

M+	Add the number in level 1 to the value stored in the memory. If
	the stack is empty, use the last number entered.
M-	Subtract the number in level 1 from the value stored in the
	memory. If the stack is empty, use the last number entered.
MR	Recall the contents of the memory to the last number.
MC	Clear the memory.
CLEAR	Clear the list and memory.
DISP	Show the status display.
 <\ DISP	Toggle the status display.
 /> DISP	Toggle the status display.

\|^	Move up one item in the list.
 <\ \|^		Move up five items in the list.
 /> \|^		Move to the top of the list.
\|v	Move down one item in the list.
 <\ \|^		Move down five items in the list.
 /> \|^		Move to the bottom of the list.
DEL	Delete the current item from the list.
\->ARR	Convert the list from internal form into a n x 2 array on level
	1 of the stack.
ARR\->	If the item on level 1 of the stack is an n x 2 array, convert
	it to internal form.  If the item on level 1 of the stack is
	a vector, convert it to internal form assuming that all items
	are to be added.
DISP	Show the status display.
 <\ DISP	Toggle the status display.
 /> DISP	Toggle the status display.

Of course, you can also program some or all of these operations on the
user keyboard.

------------------------------------------------------------
Object Summary:	

CST	(global variable) The custom menu definition.
C	(global variable) The index of the current list item.
D	(global variable) Flag that indicates whether to show the display.
L	(global variable) The last number entered.
M	(global variable) The memory.
N	(global variable) The number of items in the list.

T	(global variable) The list total.
XS	(global variable) A list that contains the sign of each of the
	values to be added: +1 means +, -1 means -, and other values
	are multiplied.  The total is computed by converting this and XV
	to vectors and taking their dot product.
XV	(global variable) A list that contains the values to be added.
ICHK	(internal procedure) Checks the presence and type of value on
	the stack.
ICLR	(internal procedure) Clears all variables.
IDEL	(internal procedure) Deletes one item from a list.

IDSP	(internal procedure) Generates the display.
IINS	(internal procedure) Does the insertion for +, -, and *.
IINS2	(internal procedure) Inserts an item into a list.
ITOL	(internal procedure) Stores the current value in L.
IUPD	(internal procedure) Updates all variables and the display.
UA\->	(user command) Converts an n x 2 array or vector to the internal
	lists.

U\->A	(user command) Converts the internal lists to an n x 2 array.
UADD	(user command) Implements the + function.
UDEL	(user command) Implements the DEL function.
UDSP	(user command) Forces a display.
UMC	(user command) Implements the MC function.
UMM	(user command) Implements the M- function.

UMOV	(user command) Implements the up and down arrow functions.
UMP	(user command) Implements the M+ function.
UMR	(user command) Implements the MR function.
UMUL	(user command) Implements the * function.
USHO	(user command) Implements the shift-DISP function.
USUB	(user command) Implments the - function.

UTOT	(user command) implements the Total and Subtotal operations

------------------------------------------------------------
Detailed Interfaces:

ICHK	Stack Input:	1 if a value is required, 0 if not
	Stack Output:	a value to use
	Global Input:	L
	Global Output:	none
	Calls:		ICLR

	Checks whether the system has been initialized.  If not, it
	calls ICLR.  If level 1 was non-zero, it also checks level 2
	for presence.  If not present, it recalls L.  If present, the
	value's type is checked and an error generated if not a real
	number.

ICLR	Stack Input:	none
	Stack Output:	none
	Global Input:	none
	Global Output:	C, D, L, M, T, XS, XV
	Calls:		none

	Clears all variables.

IDEL	Stack Input:	list
	Stack Output:	list
	Global Input:	C
	Global Output:	none
	Calls:		none

	Deletes the C'th item from the supplied list.

IDSP	Stack Input:	none
	Stack Output:	none
	Global Input:	C, D, L, M, T, XS, XV
	Global Output:	none
	Calls:		IUPD

	Generates the display.

IINS	Stack Input:	value to insert
			sign to insert
	Stack Output:	none
	Global Input:	C, N, XS, XV
	Global Output:	C, XS, XV
	Calls:		IDSP

	Inserts the items after the C'th item in XV and XS.  Increments C.

IINS2	Stack Input:	list
			value
	Stack Output:	list
	Global Input:	C
	Global Output:	none
	Calls:		none

	Inserts VALUE after the C'th item in the list.

ITOL	Stack Input:	value
	Stack Output:	value
	Global Input:	none
	Global Output:	L
	Calls:		none

	Duplicates the value and stores it in L.

IUPD	Stack Input:	none
	Stack Output:	none
	Global Input:	XS, XV
	Global Output:	N, T
	Calls:		none

	Stores the size of XS into N and the dot product of XS and XV into T.

[ Only selected User command functions are listed in detail.  The
use of the others is implied by their definitions. ]

UMOV	Stack Input:	amount
	Stack Output:	none
	Global Input:	C
	Global Output:	C
	Calls:		IDSP

	Moves the current item by AMOUNT.

UTOT	Stack Input:	doclear
	Stack Output:	none
	Global Input:	T
	Global Output:	C, XS, XV
	Calls:		ICHK, IDSP, ITOL, IUPD

	Figures the total and stores it in T.  If DOCLEAR is true,
	also clears the list.
