Programming the Kim-1 (Uno)


Introduction to Programming the Kim-1 (Uno)

Programming the Kim-1 (Uno) is a lot of fun, and you can learn very quickly. You can read the instructions to build the Kim Uno here. In my case, I just downloaded the gerber files, and had the boards made. They are much easier to build if you have the board, than to build one manually. Additionally, you can usually find an entire kit on Ebay.

In this post, we’ll simply go over how to enter a simple program. Once you learn a few commands, you can use the First Book of Kim to learn more. You can study the programming examples.

In this case, we’ll put a simple program in the Kim Uno that increments a counter, and writes this to the display. Basically, we will enter the machine code directly. The Kim-1 can support some higher level programming languages such as VTL-2. It’s important to realize, however that your memory is limited. The higher programming languages do seem primitive.

When you enter the OPCodes directly, however, you don’t even need another computer. You can do all of the programming on the Kim-1 (Uno).

Start Writing the Program

First, power up your Kim-1, and press the ADDRESS button. This allows us to enter an address that we wish to place data into. Press 0200. If data is already at this address, it’s OK. We will overwrite this data. 0200 is a good place to start, and this allows us to use lower addresses to store some values. Additionally, it’s above some of the reserved memory locations that we don’t want our program to interfere with. Now, you are ready to enter data at this address. Press the DATA button.

Instructions for Programming the Kim-1 (Uno)

Each instruction has a particular purpose. You can look up each OPCode on 6502.org.

LDA

At Address 0200, we’ll load a value of zero into the accumulator. All of the values we’ll discuss here are in Hex. The code for the LDA that we want is A9. The value we want to load is 00. Therefore, press A9 on your keyboard, then press the + button. Now you are address 0201. Enter 00, then press + again. You will see that you are now at address 0202.

STA

At this point, we are ready to Store the value of 0 to memory location F9. This memory location will end up on the least significant digits of the Kim-1 Display. To store the accumulator to F9, press 85 then press +. Now press F9, then + again. At this point, you are at address 0204.

SCANDS

Next, we are ready to scan the display. Your Kim-1 already has a subroutine to do this for us. F9, FA, and FB will appear on the display when you jump to this subroutine. Enter 20, then press +. This is the JSR instruction that instructs the 6502 processor to execute a subroutine. Next, we need to tell the Kim-1 where our subroutine is. Press 1F, +, then 1F again, and +. You are now att address 0207.

Another LDA

At this point, we’ll load the value of 1 into the accumulator. Later on, we’ll add the value of F9 to 1. Then we’ll write this value back to F9. This will effectively increment memory cell F9. To load the accumulator with 1, press A9, then +, and then 01, and hit +. At this point, you are at memory cell 0209.

ADC

ADC is an Add with Carry. This will add the current value of the accumulator, which is 1 to the existing value at memory cell F9. After that, the contents of the accumulator register will be F9 + 1. The opcode for ADC is 65 hex. Therefore, press 65, +, then F9 and +. You are at address 020C now.

JMP

At this point, we are ready to jump back to memory cell 202. This stores the Accumulator back to F9, and creates an infinite loop. The opcode for the JMP instruction is 4C. When we specify the address to jump to, we enter the low byte of the address first (02). After that, we will enter the high byte, which is also 02. Therefore, press 4C, +, 02, + 02.

Test for Programming the Kim-1 (Uno)

At this point, you are ready to run your program. Press the ADDRESS Button, and go back to address 0200. Press GO. Your counter should fun from 00 to FF then start over. If your program does not work, then we need to check your data. To very the program is correct, press STOP, then press ADDRESS. Go back to cell 0200, and just keep hitting + to step through your program. The program we entered is as follows:

Cell | Data
0200  A9  00                  LDA  #00
0202  85  F9                  STA  $F9
0204  20  1F  1F              JSR  SCANDS (20 1F 1F)
0207  A9  01                  LDA  #01
0209  65  F9                  ADC  $F9
020C  4C  02  02              JMP  02  02

For more information, visit the Vintage Computer Category Page!

— Ricky Bryce

Leave a comment

Your email address will not be published. Required fields are marked *