Friday, February 15, 2013

Why build your own computer?

In which our protagonist rambles on about his childhood before explaining why he wants to build an 8-bit computer from scratch instead of doing something sensible.

The very first computer I owned -- ignoring my programmable calculator, which I think was a TI-58 -- was the VIC-20 from Commodore (named "VC-20" in Germany because of some unfortunate phonetic issues). My grandparents bought it for me for 800 marks (about 400 euros, currently 530 dollars). It came with slightly more than three kilobytes of memory, later expanded to whooping 19 Kb, very primitive graphics, and a tape drive for external programs.

Of course, I used it to play Pacman.

Somewhat surprisingly, I also learned how to program. The VIC-20's dialect of BASIC was limited, so I started programming machine code -- the bare metal. At first, this involved typing in line after line of hexadecimal numbers (you can become amazingly proficient at this, though you won't enjoy it). Later, somehow, I got my hands on an assembler.

I fell in love with assembly language. Call me a geek, but I have fond memories of sitting at my desk in my parent's house in front of a small TV (there was no monitor), coding 6502 assembler while listening to Kate Bush's The Dreaming on my mono cassette player. Drilling down to the lowest level of the processor, where every byte and clock tick was precious, was fascinating in a way that I've since then only encountered with biochemistry.



A bad scan of a low-quality photo of my desk. The VIC-20 is sitting on the TV with the tape drive to the left. On the very right edge of the picture, you can see the memory map I drew. I'm pretty sure that's a jar of applesauce in front of the TV.

At some point, I upgraded to an Atari ST. I took one or two stabs at 68000 assembly language, but never had the right tools, and it was hard to find documentation. Then my uncle Gary introduced me to the Internet, my hormones introduced me to girls, and I got sidetracked for about, oh, 25 years. I spent a lot of time with Linux and learned Python, but assembler, not so much.

Fast forward to late 2012, when I stumbled on the 6502.org-Website and realized: Not only was the 6502 still in production -- now as the improved CMOS 65c02 -- but it was so cheap I might just have a shot at building a computer from scratch. A simple one, of course. But a real computer. From scratch. Me.



The WDC 65c02. Image credit: Anthony King, via Wikipedia. This image is in the public domain.

But why would any sane person want to do this? The technology is 30 years old and involves things like EEPROMs that frankly belong in a museum. The 6502 was fast in its day, but could probably be emulated on a smartphone at greater speed. It hardly has any registers, can only access 64 Kb of memory, and can't even multiply.

Worse: Building an actual computer from chips involves dealing with fiddly little wires, understanding cryptic data sheets, and solving frustrating timing problems. Why not just, say, buy a Raspberry Pi and program ARM assembler if you want to get close to the machine? Or just emulate the whole thing?

Maybe that is what I will end up doing in the long run. But the idea for now is to gain a deeper understanding of how a computer works at the lowest level (almost the lowest level, that is, but I'm not ready to build my own CPU just quite yet). Modern processors such as the ARMs are too complicated for that.

The design of the 6502 is simple and its instruction set elegant -- to borrow a phrase from Python, it fits your brain. Designing and building my own computer was something of a childhood dream, though at the time, even becoming an astronaut seemed more realistic. Since my day job involves hours of multitasking, any hobby where I can concentrate on one single thing is a mental vacation. The fact that there will be all sorts of skills required that I don't have is a bonus, because I like learning for its own sake.

Finally, there are the bragging rights: I will have built my own computer. A younger me would have hotly denied this was part of the appeal, but I'm old enough to know that I enjoy this kind of an ego rush.

So that is what this blog is about: My attempt at building a computer from scratch. Updates will be infrequent, entries rambling, schematics hand-drawn and photos wobbly. There is lots of basic stuff I need to learn before I can get around to actually putting the computer together, so it could be months before it gets interesting. But feel free to watch. Listening to Kate Bush, of course, is optional.

In the next entry, I'll draw up a list of things I'll need to learn, buy, and do. It's pretty long.