Christmas Break Project

Over the Christmas break I put together a small side project to emulate an Apple 1. I grew up with an Apple ][+, which has the same CPU. It was fun to look back at 6502 assembly language.

Hello, world!

The Apple 1 is a remarkable machine. Open source did not formally exist in 1976, but in the true hacker spirit, everything about the Apple 1 was well documented and publicly available. It came with instructions on how to modify the computer, it’s schematics and also the source code for it’s Monitor, which was really just a minimal way to enter programs by typing hexadecimal codes.

Using this information about the hardware design and the software, it was fairly trivial to implement an emulator.

Wikipedia has a great Apple 1 entry with lots of detail. You can find a scan of the original Operation Manual (PDF) at the Computer History Museum.

My emulator contains a straightforward implementation of the 6502 CPU, which is a very simple 8-bit processor with just three registers and about sixty instructions. Originally it runs at 1.023 MHz, or about 2500 times slower than a modern laptop. I have made no attempts to optimize the code in any way and it seems to run at about 80 MHz. There is also no speed throttle, so the Apple 1 is really going crazy fast.

There also is a minimal implementation of the 6821 Peripheral Interface Adapter (PIA), the second major component in the Apple 1. This chip was responsible for moving data to the screen buffer and taking data from the keyboard.

If you are interested in playing around with my emulator, you can find the project at github.com/st3fan/ewm.