http://t3x.org/kimuno/kimcalc.html   (light|dark)

KIM Uno Pocket Calculator Program

Download source code: kimcalc.a65 (3KB) (listing)
Download binary: kimcalc.bin (493 bytes)
Download papertape file: kimcalc.tap (1397 bytes)

Update: Thanks to the valuable feedback of Hans Otten (retro.hansotten.nl) the program now also runs on the original KIM-1.

Having made a pocket calculator case for the KIM Uno, what was missing was a program that implements a simple calculator on the device. Of course there is a very powerful calculator in the ROM of the KIM Uno, but doing simple calculations with it is a bit awkward. So I wrote my own calculator program.

The program has a size of less than 512 bytes, so it fits in the first half of the NVRAM at $0400, leaving another 512 bytes for other programs. Because it is located in the NVRAM, all you have to do is to enter 400G after powering on to turn the Uno into a calculator.

The calculator uses RPN, but does not really have a stack. It has two registers called RESULT and INPUT. When you enter a number, it is stored in the INPUT register. When you press an operation key (op) after entering the number, the operation " RESULT op INPUT" is performed and the result stored in RESULT. This sounds more complicated than it is. Let's see:

INPUT  DISPLAY
       0000 00  INPUT and RESULT are 0
5      0005 00  INPUT is now 5
C      0005 00  C is "plus"
                5 is now in RESULT
7      0007 00  INPUT is 7
C      0012 00  RESULT is 12
C      0019 00  INPUT is still 7
D      0012 00  D is "minus"
D      0005 00
E      0035 00  E is "times"
                INPUT is still 7
10     0010 00  new INPUT
C      0045 00
5      0005 00  new INPUT
F      0009 00  F is "divide"

Easy, isn't it? There are a few interesting things you can do with this simple calculator.

Add rows of numbers:

B number C number C number C ...

Square:

B number C E

Powers of two:

B 2 C E E E ...

The "B" key clears (sets to zero) both the INPUT and RESULT register. Here is the full keypad template for the calculator:

C
 ADD 
D
 SUB 
E
MUL
F
DIV
8
 
9
 
A
POINT
B
CLEAR
4
 
5
 
6
 
7
 
0
 
1
 
2
 
3
 

The "point" operator ("A" key) switches between integer and fractional part input. E.g. to enter the number 2.5, type

2 A 5 0

The calculator goes back to integer input after each calculation or when pressing "B". The calculator works in fixed point mode, there are always four integer and two fractional digits. When only doing addition and subtraction, the decimal point can be ignored:

123 C 456 C 789 C

basically yields the same result as

1 A 23  C  4 A 56  C  7 A 89  C

When calculating multiples, up to three-digit numbers can be multiplied when first dividing them by ten. E.g.:

12 A 30  C  45 A 60  E

will yield 560.88 (123456 is 56088). So here it is, a very simple pocket calculator program for the KIM Uno. By far not as powerful as the one in the ROM, but much easier to use.


contact | privacy