CALCULATOR
by B. McIntosh
from ZX Computing Jun/Jul.1984

[WARNING: The calculator does not carry forward its answer]
[to the next calculation, thus entering:                  ]
[ 12 K 4 ENTER (12 + 4 = 16)                              ]
[ B 10 ENTER   (* 10)                                     ]
[will give "C Nonsense in BASIC", not 160.            JimG]

COOL AND CALCULATING

While most of us hotly deny that personal computers are only
glorified calculators, B McIntosh of Glasgow proves that that
is one of their most useful functions.


This program, for the 16 or 48K Spectrum, is different to
other calculator programs in that the functions are
displayed as you type them in.


Arithmetic

Enter numbers by pressing the keys as seen. Enter arithmetic
functions by pressing the keys on the keyboard where they
are printed. For example:

ADD     12 + 5
PRESS   1,2,K,5,ENT
DISPLAY =17

SUB     -13 - 7
PRESS   J,1,2,J,7,ENT
DISPLAY =-20

MULT    4 * 32
PRESS   4,B,3,2,ENT
DISPLAY =128

DIV     18 / 6
PRESS   1,8,V,6,ENT
DISPLAY =3


Roots and percent

The square root function is obtained by typing the first
letter; ie (R)oot followed by a number. This function can be
used on its own or in calculations involving other numbers.
For example:

FIND ROOT 2 by typing
R,2,ENT
or ROOT 2/2  by typing
R,2,V,2,ENT

The percentage function must always have two numbers, one to
carry out the function and the multiplier for the
percentage. This can also be used on its own or in
calculations. For example:

FIND 5% of 17 by typing
1,7,B,5,P, ENT


Memory

The calculator is equipped with eight memories. To store a
number there must be an "=" in front of it and then you type
"F" to get you into the special function mode followed by
"M" for memory and then the number of the memory that you
wish to be used. This number can then be used as an operand;
ie. you can type F,M,1,K,5. This displays M1+5. Press enter
to find the answer. Memories can also be used with each
other; ie. M1xM2 etc.

The contents of any memory can be displayed in two ways.
Firstly, when the display is showing "0" then by typing as
"=10" or such like. Secondly, at any time you can type
F,D,M,1 . This will display the contents of memory 1 at the
top of the display without interfering with any calculations
which might be in progress.

The contents of all memories can be reset to zero by typing
F,X and following the prompt. If you change your mind, then
any other key will abort the memory clear.


Number conversions

This program will also do conversions from HEX to DEC and
vice versa. HEX letters are obtained by typing "F" and the
number under which they appear. For example:

Find the HEX for 255
Press 2,5,5,H
The display then shows FF

Find the DEC for 1AB
Press 1,F,1,F,2,D
The display then shows 427

The only function left is the C/E
which, by typing "C", will erase
the last thing that you entered.


Program breakdown

Here follows a brief description of the program functions:

10-40     Sets up variables and flags and puts the computer
          into CAPS mode.
50-96     Sets up graphics and POKEs the USR routine for the
          letters into the memory.
98        Screen colour etc.
100-200   Draws the calculator.
210-490   More variables.
500-560   Handle the input of data (main loop).
600-850   Special instructions for any key pressed which is not
          a number.
1000-1020 Calculates the answer and running totals.
1100-1140 Converts from decimal to hex.
1200-1300 Displays contents of memory.
1400-1420 Converts from hex to decimal.
1500-1520 Input from keyboard.
6000-6050 Main loop for special functions.
6100-6140 Handles memory functions. Decides whether to
          update memory or include it in calculations.
6200-6250 Resets all memories to zero.
9000-9060 Converts to and displays large characters.
9900      Saves program.


--
Another Fine Product transcribed by:
Jim Grimwood (jimg@globalnet.co.uk), Weardale, England
--
