In the summer of 2003, I quit working for Microsoft and took a few months off while I decided what direction I wanted to go in my career. One of the last things I did when I left Microsoft was take a trip to the company store, where I bought a copy of Charles Petzold's book CODE: The Hidden Language of Computer Hardware and Software. This turned out to be a surprisingly good book that explained a lot more than computer programming.
Over the years of my career I had read a few books describing the history of computer development. None really explained how computers worked though. I knew all of the primary parts of a computer. I could write programs in many different languages, including the assembly languages for a few microprocessors and the IBM System 370 mainframe, but I never really knew how the machines interpreted the instruction codes to produce a result.
Charles Petzold's book was an eye opener. I finally saw how logic gates could be combined to do all sorts of interesting things. I had already been exposed to the concept of the half-adder and the full adder, the flip-flop and the like, but with this book, I could actually see how they worked. I was inspired to write this simulation upon reading these words (emphasis added) on page 203 of my copy of the book:
As I implied earlier, 64 KB was a common amount of memory in personal computers purchased around 1980, although it wasn't constructred from telegraph relays. But could you really build such a thing using relays? I trust you won't consider it. Our design requires nine relays for each bit of memory, so the total 64K x 8 RAM array requires almost 5 million of them!
I couldn't leave a challenge like that unanswered. For the next three months, I tried to implement a simulated computer based upon electomagnetic relays. My initial implementation was rather cumbersome, and I had to limit it to about 256 bytes of ram, but it worked. Sort of anyway. It was slow, unstable, and ran out of stack space rather quickly because of the way I built it. It wasn't a complete computer, but the RAM worked, and the adder worked. I could use it to do manual addition and subtraction.
Eventually I had to return to the working world. Sitting at home writing software as an intellectual exercise doesn't pay the bills. After three months of this, I archived the program and went to find a job.
A couple of years later, I picked the program back up, but I decided to try a different approach. The approach I took this time was based on the idea of a finite state machine. This proved to be a much more tractable way to write the simulation. I spent a couple of months of my spare time working on the second iteration, and managed this time to implement 64 KB of ram and to get a little automation working. Unfortunately I couldn't work out the timing issues with running the instruction cycle for writing results back to RAM. Again, I put the program aside for a while.
In November of 2007 I decided to give it another try. On November 6th, I was writing an article about the pitfalls of automation, especially where the human element is involved. While doing research for the article I ran across Charle's Petzold's website. There he had a technical addendum to his book. What interested me most was the four bit ring counter he described, but he also had a couple of other circuit designs that were simpler than the ones I had come up with for handling control signals. On November 11th, I started re-writing my simulation - from scratch this time, because I had lost the code I wrote for the second iteration.
By November 23rd I had a complete, fully working implementation of the computer described in Chapter 17 of Charles Petzold's book. Since then I have taken that implementation a bit further, adding several other instructions to the instruction set, and refining the user interface a bit.
This project is an attempt to re-write the computer in Java, to add a few more features, including a working stack pointer with push/pop, call and return instructions.
And this time, it's open source!