Programming in 1s and 0s
by Jon Foster
I recently worked with a guy who was a PHP web developer. This is one of the most used languages for writing web applications. Drupal, WordPress and Joomla, just to name a few, are all written in it. I read his marketing hype, on his employer's website, that described him as programming in ones and zeros, although not that specific phrase. And I recently started reading Kildall's computer history. If you love personal computers his history is very informative and a pretty funny. Well worth the read.
Well... I realized that compared to the numbers of people using computers or writing software, these days, there is a real teensy percentage of us that have worked in 1s and 0s. So I thought it would be informative to describe what programming in ones and zeros is like. I think I'll walk backwards through history briefly describing my usual experience with it and then to what my predecessors, those from before the micro/personal computer era or the real, real early days of the personal computer.
*NOTE* I use "personal computer" (PC) to pretty much mean every computer of the "micro" class that were produced to be owned by individuals. The term pre-existed IBM's use of it as a brand identifier. So for me "PC" would include all those micro computers like IMSAI, TRS-80, Kaypro, Osborn, the IBM PC itself and its descendants, Macs, BeBox, luggables, notebooks, iPhones, iPads, RaspberryPi, ...
Back when I was young and writing software for the BASIC interpreter in my TRS-80 it became apparent, through various purchased programs and magazine articles, that injecting "machine code" into a BASIC program could yield HUGE benefits in terms of performance and size reduction and also provide facilities that weren't available in BASIC. "Machine code" is basically the numeric language that the physical machine, more specifically the microprocessor, speaks. Everything the computer does boils down to numbers. In our current digital age numbers are made up of and stored as a strings of 1s and 0s. Each digit being called a "bit". Current microprocessors deal with 32 or 64 of these bits at once. The Z80 microprocessor in my TRS-80 could handle 8.
Growing up I had the PC but I did not have the money to buy an "assembler", to make machine code. An assembler converts a very crude textual representation of the machine code into the actual machine code (numbers). It might also provide other facilities like macros, linking, libraries, ... It turns out that if one has the right documentation, which was easier to come by for me, you can do the "assembly" process by hand.
Normally I would approach this process by writing the "assembly language" code down, on paper, in one column. Then I would lookup each instruction in the "dictionary" and see how each bit was set to perform the desired action with the parameters I needed. Then write down the strings of ones and zeros in another column. Next I'd convert those to the decimal or hexadecimal numeric equivalent and feed the appropriate commands with the resulting strings of numbers into a BASIC program which would hopefully load those values into RAM and execute them. This was a very tedious and error prone procedure. But as a school kid on summer break I could find the time. It was also enjoyable getting to know what made the computer tick at the lowest level.
Now to take a step further back in computing history, which amusingly enough was forward in my history. Some years after my dad brought home the TRS-80 he had a truck pull up with a DDP-24. These machines were made in the '60s. I found a picture of one about half way down this page. I haven't embedded their image in my page to avoid stepping on toes. Their unit is configured slighly different then ours was. But to get an idea of what this thing was it took up all of my grandfather's wood working shop. If you've seen '60s & '70s movie computer rooms, with banks of tall white cabinets, tons of blinking lights, lots of spinning tape reels, teletypes, ... that's pretty much what this was. It was four racks wide, about 6' tall, A large tape reel deck, paper tape reader, lots of blinking lights, switches and an IBM typewriter as a teletype. Instead of monitor, keyboard and mouse the display was printed onto paper with the typewriter and input was made with the typewriter keys. To this day I have no idea what possesed my dad to get this beast nor where it came from. I imagine he did it because it was cool. I think he got rid of it because the electric bill to run it was insane and he never did get it running, that I know of. Besides the TRS-80, taking up only a desk, was SO much more potent.
Now that the stage is set, back to the 1s and 0s: At the time the DDP-24, and the many predecessors, were designed they didn't have "ROM", "FLASH", "EPROM", ... a permanent memory of any kind that could store "boot instructions" like a "BIOS" in current PCs. The closest thing would have been "rope memory" that NASA developed for the Appollo trips. Fortunately ROM existed by the time PCs started to come around. A computer without software is basically an electricity consuming paper-weight, or in the case of this massive machine, a boat-anchor for a sizeable boat. In short they do nothing but burn electricity.
To get the computer to boot you had to program it with the switches on the front panel. A switch in the off position was "0" and in the on position a "1". You needed the smallest program you could devise to load a more useful program from the paper or magnetic tape readers. Once devised it would be changed to machine code (1s and 0s) and then feed into the computer by setting the switches to the appropriate positions, then toggling that instruction into the RAM (magnetic core memory in this case) with another switch. Then set the switches to the correct sets of 1s and 0s for the second instruction, toggle it, ... and repeat, and repeat, and repeat, ... until the boot code was hopefully entered correctly. Hit the "run" switch and hopefully you had the right tape mounted, and hopefully it loaded correctly.... then some kind of expression, like a prompt, should print out on the typewriter. It was very difficult to get this thing into a usable state and once running you never wanted to turn it off... or it might be days to get it running again.
There were a few real early PCs that could be "boot strapped" this way. Needles to say if you could afford it you bought ROMs and burned your boot code into those. Fortunately my TRS-80 came with a 12K ROM that would start with a BASIC interpreter and later versions would check for a floppy disk and load boot code from the first one if present.
Moral of the story: Real programmers code with toggle switches.
I still find nothing in computer-dom so exciting as getting down and dirty with the guts of a computer. Then the only limits are my imagination and the hardware I can strap on it.