Emulate A KIM-1 With A Commodore 64

When you think about virtualization, you usually think about making some CPU pretend to be another CPU. However, there are sometimes advantages to making a computer pretend to be the same computer.

That’s the case with [oldvcr]’s KIMplement, which emulates a KIM-1 with a 6502 using a Commodore 64, which also uses a 6502.The reason this makes sense is that you have total control over an emulated CPU. If a program, for example, writes to a critical memory location or tries to take over the screen or keyboard, you can easily make the emulator do something more appropriate. Things like breakpoints and single stepping also become trivial.

The virtual machine at the heart of it is 6o6 (6502 on 6502), and it seems to perform well. By virtualizing, you can easily protect the system from programs that try to, for example, take over an interrupt vector. This is similar to how x86 protected mode can run old real-mode code in a virtual environment and intervene for certain instructions. The emulation is good enough that the emulator can run the emulator, which then runs the emulator to actually run the real target. That’s wasteful, of course, but it does speak to the completeness of the pretend CPU.

If you want a KIM-1 (and an 1802 Elf) but only have an Arduino, you can emulate a different way. At least an emulated KIM-1 doesn’t develop bad memory chips.

Implementing Commodore’s IEC Bus Protocol On A KIM-1 Single Board Computer

Although the PET is most likely the more well-known of Commodore’s early computer systems, the KIM-1 (Keyboard Input Monitor) single board computer was launched a year prior, in 1976. It featured not only the same MOS 6502 MPU as later Commodore systems, but also an MCS6530 PIO IC that contained the ROM, RAM and programmable I/O, reminiscent of later I/O chips on Commodore systems. As the KIM-1 was only designed to be used with an external tape drive (and a terminal for fancy users), adding a floppy drive like the ubiquitous 1541 with its IEC bus interface was not a first-party accessory. How the IEC bus can be retrofitted to a KIM-1 system is demonstrated in this video by the Commodore History channel.

The Commodore KIM-1 hardware is almost directly compatible with the C64 hardware. (Credit: Commodore History on YouTube)
The Commodore KIM-1 hardware is almost directly compatible with the C64 hardware. (Credit: Commodore History on YouTube)

What is most notable is just how similar the KIM-1 hardware is to later PET and VIC hardware, with the CIA and PIO ICs featuring the same requisite pins for this purpose, and requiring only the addition of an inverting (SN7406) IC and an EPROM featuring the new code to support the proprietary Commodore IEC bus protocol, which was mostly pilfered byte-for-byte from a C64 kernal ROM.

With some creative breadboarding in place and using nothing more than the on-board LED display and keyboard matrix, it was then possible to write to the inserted floppy disk, and also to read back from it. What’s interesting here is that this essentially replaces the tape drive as target for the KIM-1, which thus retains a lot of the original functionality, but with a big performance boost. While perhaps only interesting as an academic exercise, it’s definitely an interesting look at the early beginnings of what would blossom into the Commodore 64.

Continue reading “Implementing Commodore’s IEC Bus Protocol On A KIM-1 Single Board Computer”

Kim-1: Memory Problem Resolved

At the very start of the personal computer revolution, there were relatively inexpensive boards with little more than a CPU, some memory, a display, and switches or a keypad. Some of these had expansion ports meant to allow you to build up, and some were just “trainers” to learn about computers. While you could argue that the Altair fell into this category, it had a case and a proper bus. The computers we are thinking about were usually just on a single board and — with luck — had an edge connector for expansion. Perhaps the most famous of these was the KIM-1 and [Old VCR] shows us how he brought one back to life.

These were highly popular mainly because of the low price of $245 back in 1976. For that price you got a calculator-style keyboard and LED display, 1K of RAM, and 2K of ROM. [Old VCR] has several and noticed that one was developing memory problems.

Continue reading “Kim-1: Memory Problem Resolved”

ESP8266 As A Tape Drive

1976 was the year the Apple I was released, one of several computers based on the MOS 6502 chip. MOS itself released the KIM-1 (Keyboard Input Monitor) initially to demonstrate the power of the chip. The single board computer had two connectors on it, one of which could be used for a tape recorder for long-term storage. When [Willem Aandewiel] went to the Apple Museum Nederland in 2016, he saw one and felt nostalgic for his youth. He was able to get a replica, the microKIM, and build it but he wanted to use new technology to interface with this old technology, so he decided to use an ESP8266 as a solid state tape recorder.

One of the reasons the KIM-1 was so popular when it was released was that there was lots of documentation available. [Willem] used this documentation to figure out how the KIM-1 saves data to the recording device. An ATTiny85 is used to decode the pulse stream that the KIM-1 sends when saving because the timing was too tight to both “listen” and decode the bits as well as convert and store them. For loading programs, the data can be sent digitally as 1’s and 0’s to the KIM-1. This means that the ATTiny is only used for decoding and doesn’t have to re-encode the data.  Because of this, saving is slow, but loading is very quick.

To complete the project, [Willem] added four buttons, one each for rewind, record, play and fast-forward, and a screen so you can see which program is currently selected and can go from one program to another. As a nice throwback touch, record and play have to be pressed at the same time when saving. For more 6502 projects, check out this 6502 based DIY computer, or this 6502 built from discrete parts.

Continue reading “ESP8266 As A Tape Drive”

KIM-1 To COSMAC Elf Conversion — Sort Of

In the mid-1970s, if you had your own computer, you probably built it. If you had a lot of money and considerable building skill, you could make an Altair 8800 for about $395 — better than the $650 to have it built. However, cheaper alternatives were not far behind.

In 1976, Popular Electronics published plans for a computer called the COSMAC Elf which you could build for under $100, and much less if you had a good junk box. The design was simple enough that you could build it on a piece of perf board or using wire wrap. We featured the online archive of the entire Popular Electronics collection, but hit up page 33 of this PDF if you want to jump right to the article that started it all. The COSMAC Elf is a great little machine built around a 40-pin RCA 1802 processor, and for many was the first computer they owned. I lost my original 1802 computer in a storm and my recent rebuild in another completely different kind of storm. But there is a way to reclaim those glory days without starting from scratch.  I’m going to repurpose another retro-computing recreation; the KIM-1.

I’ll admit it, Rewiring a real KIM-1 to take an 1802 CPU would be difficult and unnecessary and that’s not what this article is about. However, I did have a KIM UNO — [Oscar’s] respin of the classic computer using an Arduino mini pro. Looking at the keyboard, it occurred to me that the Arduino could just as easily simulate an 1802 as it could a 6502. Heck, that’s only two digits different, right?

The result is pretty pleasing. A “real” Elf had 8 toggle switches, but there were several variations that did have keypads, so it isn’t that far off. Most Elf computers had 256 bytes of memory (without an upgrade) but the 1802 UNO (as I’m calling it) has 1K. There’s also a host of other features, including a ROM and a monitor for loading and debugging programs that doesn’t require any space in the emulated 1802.

Continue reading “KIM-1 To COSMAC Elf Conversion — Sort Of”

KIM-1 Clock

Over on hackaday.io, [Arduino Enigma] posted the code for his clock that runs on a KIM Uno (the KIM-1 clone we mentioned late last year). Although the KIM Uno has a few demos preloaded (including Microchess and a scientific calculator), all of them take some interaction. The clock makes the KIM Uno a more dynamic desk display since it does something useful without any user interaction (once you set the clock, of course).

The project shows the code stored in ROM, but you can’t directly enter the program into ROM (which is really EEPROM on the host Arduino). The trick is to enter the address (that is press AD and then 0, 4, 0, 0) and then mash down the reset button for about a second. Then you can press DA and enter the hex codes provided (pressing + after each byte). Since the code is in nonvolatile storage, you can start it at any time by setting the time in RAM and executing the code at address 400.

Continue reading “KIM-1 Clock”

A Portable KIM-1

The KIM-1 was the first computer to use the 6502, a CPU that would later be found in the Apple, Ataris, Commodores, and the Nintendo Entertainment System. Being the first, the KIM-1 didn’t actually do a whole lot with only 1k of ROM and a bit more than 1k of RAM. This is great news for anyone with an Arduino; you can easily replicate an entire KIM-1, with a keypad and 7-segment display. That’s what [Scott] did, and he put it in an enclosure that would look right at home in a late 70s engineering lab.

The impetus for this build was [Scott]’s discovery of the KIM-Uno, a kit clone of the KIM-1 using an Arduino Pro Mini. The kit should arrive in a few weeks, so until then he decided to see if he could cobble one together with parts he had sitting around.

Inside a handheld industrial enclosure is an Arduino Uno, with a protoshield connecting the keypad and display. The display is an 11-digit, seven-segment display [Scott] picked up at a surplus shop, and the metal dome keypad came from a hamfest.

Getting the software working took a bit of work, but the most important parts are just modifications to the standard Arduino libraries.

Now that [Scott] has a KIM-1 replica, he can program this virtual 6502 one hex digit at a time, run Microchess, or use the entire thing as a programmable calculator.