Thursday, May 17, 2018

My new friend KIM.

I've had a pair of Commodore KIM-1 computers for at least 15 years now, but never really did anything with them.  That all changed over the last few weeks, and now I feel sorry for how much fun I've been missing out on.

The KIM-1 is a single board, 1mhz, 1 kilobyte computer (the green thing in the picture above) with a 23 key hexadecimal keypad for input, and a 6 digit LED display for output.  It also has two edge connectors on the left-hand-side.  One is called the Expansion port, and the lower one is the Application port.  The computer is powered by applying 5V to a pin on the Application port.  This port also includes a Current-Loop RS232 interface and cassette interface for saving/loading programs.

It may be a very minimal micro-computer, and it is definitely not a Home/Personal Computer, but it is certainly a computer!

The screen is divided into two segments.  The left four hex-digits are the current working Address, and the right two hex-digits are the contents of that address.  The address can represent the program counter when stepping through a program, or just the address currently being read or written to when using the KIM-1s built-in monitor.

The keyboard has the sixteen hex digits for entering addresses or data.  The AD button selects "Address" mode, where any entry on the keyboard will change the current working address.  The DA button selects "Data" mode, where any entry will change the contents of the address shown on the LED screen.  When in either Data or Address mode, the + key will advance to the next address byte.

The switch in the upper left selects between SST mode (on), which allows you to step through an executing program one instruction at a time, and normal mode (off), which allows a program to run freely to completion.  In both modes, the GO button will begin executing the program from the current address shown.  In SST mode, the GO button is then used to execute the next instruction, and then immediately return to the monitor program.

The RS button will reset the CPU and cause the KIM to re-enter the built-in monitor.  It is the first button you must press after powering-on the KIM-1.  Lastly, the PC button does nothing except replace the current address with the program counter address.

The KIM-1 is powered by three principle chips.  One, of course, is the MOS 6502 cpu/processor.  The other two are a pair of MOS 6530 RRIOT chips.  Each has 64 bytes (!) of ram, a pair of 8-bit bi-directional I/O controllers, timer registers, and 1k of ROM.  On one of the 6530s is the ROM code for the ml-monitor and cassette interface, while the other has the paper-tape interface.

I have a couple of Corsham expansion boards hooked up to my KIM, which are awfully convenient, and part of the reason why I finally dug the KIM-1 out for play.  Pictured above is their I/O board, which provides a standard 9-pin RS-232 port, which converts to the KIM's strange current-loop port.  It also has convenient interface for regulated 5V, 12V, and ground (the colored wires you see above), as well as an audio input and output jack for plugging in a standard cassette deck.  The little switch on the bottom lets me pick between TTY input, and using the KIM's keypad.

On the Expansion port is a Corsham 60k ram expansion card, gives the computer ram from $2000 all the way through $FFF7.

Once I got it working, I hooked the KIM-1 up to my VIC-20 through the VIC-1011A TTL interface and used the VIC's keyboard and monitor to program the computer.  The protocol settings are: 2400bps, 8 data bits, no parity, two stop bits, no flow control.

One of my first programs was a memory-page address tester to make sure that the Corsham 60K ram expander was working correctly.  The program simply puts the page number into every byte in every page above $2000, and I then use the monitor to spot-check the results.

The first program I wrote on it was done by writing the assembly on paper for address $0200, and then translating the mnemonics into the machine language op-code numbers, and the branch addresses into one byte 6502 offsets.

Later, I realized that I could simply write the code in assembly, assemble it on the c64, and then key in the generated bytes onto the KIM's keyboard.

I am seriously interested in translating Microsoft BASIC for the KIM, and have discovered numerous resources on the web for doing that.  Check back here in the future for progress on that project.