Saturday, February 4, 2012

Give 'em the boot...

My computing career is rather different from that of a lot of people I know. I haven't been in computing my whole life but, rather, I have two distinct periods of computing -- the first when I was a teen and the second here in my 40s.

In the first iteration, I hacked many long hours on my C64, the school's Apple ][e machines and whatever else I could get my hands on. It was a given, at that time, that one spent quite a while basically poking the innards of your machine with a virtual stick. This produced variety of results, most of which were rather boring. But the occasional "spark" of meaningful response what enough fuel to maintain motivation. Luckily none of my sparks actually involved sparks or releasing the magic smoke from the hardware. Perhaps I didn't try hard enough?

Now in my second iteration, I have to make things work in a way that supports a family and maintains my interest without completely monopolizing my time. I think this means picking out little projects and experiments that can be done in a weekend afternoon -- things that are interesting, intellectually stimulating and scratch my particular itches. And those itches seem, more and more, to hearken back to the stick poking of the first iteration. Now, since I have to actually get meaningful work done on my machines, and maintain an environment where my family can do things like write school papers and get email, I can't just start poking values into memory and the like. The cost of breaking things is too high. Thankfully, the world is full of virtualization choices....

My current interests are bootstrapping, both of languages and computing environments (arguably, very much the same thing). In my undergrad automata class we played with a Universal Turing Machine. This machine behaved, initially, in a way that is very similar to the boot sector of an x86 machine -- it performed a couple of initialization instructions and then jumped over some intervening data to get to the real program to run. The typical DOS-style boot sector does a similar thing -- initializes a few things and then (hand-wavey) jumps into the real program. This realization really struck me and has intrigued me for years. So, the idea is to play with bootstrapping a computing environment from just about nothing. How close to nothing? I think starting at the boot sector is good enough. I suppose I could mess around with writing a BIOS, but that might be too minimal.

There's quite a lot of material on bootstrapping your way into various languages, particularly Scheme and Forth. I played with Forth back in the '80s, thought it was pretty cool, but never really learned it. However, it seems ideal for bootstrapping. Apparently, just a few lines of assembler will get enough of a minimal Forth to allow building up a system gradually. So here is a rough sketch of a plan:

  1. Build some kind of boot sector code with just enough to allow me to enter machine instructions and then jump to them -- sure to lead to bad results :)
  2. Use that boot sector to boot a VM and then start hacking. Ideally the next step is to write enough code to allow saving machine state to disk. This will enable me to increment my way to something more useful over multiple sessions. Part of this step is probably rewriting the boot sector to automagically reload the saved machine state -- a basic kernel image.
  3. Start building up enough environment to get something Forth-like and from there we're off and running!
I'm not positive how this will play out, and whether I will even actually start it, but it sounds good for now. :)


My kids saw me messing around here today and were horrified at the layout I was using. My 12 yr old proceeded to rework it. Hence, the new look... ;)