> urticator.net

  About This Site
> Domains

> Numbers

  Powers and Fractions
  Notes About Squares
  Decimal Expansions
  Repeat Length Again
  Number Maze
  Intrinsic Nature of Primes
  Other Topics
> Other Topics (2)

> Machine Language
  Pascal's Triangle
  Dead Reckoning
  Multiplication in Base 10
  The Multiplication Table

Machine Language

No doubt you're tired of hearing about me and the Apple II by now, but what can I say, that's the first and really only place I learned machine language. That was for the 6502 processor, of course. Later I learned bits of machine language for the 68000 and '486 (2×35 … that's a nice number, isn't it?), but I wouldn't say I ever really knew them.

If you're not familiar with it, the deal with machine language is, it's the fundamental language a machine, or processor, understands. Processors operate by reading numbers from memory, so that's exactly what machine language is, a series of numbers. Here's an example I just made up, a function that adds two eight-byte numbers. (The 6502 itself operated only on single bytes.)

A0 07 18 B1 00 71 02 91 04 88 10 F7 60

It's bad enough that I still remember all those opcodes after twenty years, but what's really bad is, I can almost, but not quite, tell you from memory how many clock cycles the code would take to run (177). Fun trivia fact: the Apple's clock ran at 1.023 MHz (1023 … hmm).

The thing I'd forgotten, until I started writing this down, is that machine language is like magic. It's not just numbers, it's numbers that do things. I mean, what if it were letters instead of digits, words instead of numbers? Words that do things … that's practically a definition of magic! Or, to put it another way, it sounds almost biblical. It also reminds me of what Stephenson was talking about in Snow Crash.

The only comparable things I can think of are biological molecules: proteins and RNA. A molecule of RNA is a chain built from four different chemicals (bases), so, essentially a big number in base 4; a protein is a chain built from twenty different amino acids, so, essentially a big number in base 20; and both kinds of molecules can do things, namely, catalyze chemical reactions. I'm sure Hofstadter discussed this somewhere in Gödel, Escher, Bach. (Also, speaking of RNA as a catalyst, see Genetic Takeover.)

To really make the comparison work, you should probably think of the code as a single big number in base 256, or, what amounts to the same thing, just ignore the spaces between digits.

If machine language is like magic, why isn't assembly language, or C, or any other high-level language? Certainly the source code is represented as numbers internally, and even if it weren't, it would still be words, which ought to be even better. I don't know, maybe it's just me, but it seems to me that source code is less on the doing side of things and more on the being-done-unto side. You compile it, it becomes machine language, and then it does things.

There are other things represented as text that come closer. Command lines are pretty good; so is SQL. Maybe it's just that they're not arcane enough … first time anyone's ever said that about a command line.

There's one other thing I wanted to say about source code, which is that it has something in common with biological molecules … not so much with proteins and RNA, but with DNA. Actually, that analogy is much better than I expected.

proteins/RNAmachine language
DNAsource code

Anyway, what they have in common is, you can get a lot done by cutting and pasting; in fact cutting and pasting is almost a defining characteristic.

That's not to say that cutting and pasting is optimal. With DNA we're stuck with it, at least for now, but with source code you can sometimes find better methods.

You may not realize how much cutting and pasting goes on with DNA. Consider viruses, for example. The heart of a virus is a plasmid, a little ring of DNA. Now, I'm not sure if it's a necessary part of their operation, or just something that happens once in a while, but if I remember right, plasmids can get spliced into and out of the host DNA. And, maybe sometimes the splice isn't quite in the right place, and they carry off some extra DNA, or leave some behind. Creepy! DNA can be transferred between species in this way.

Speaking of viruses, I only recently realized that in the fancy-sounding name “rhinovirus”, the prefix “rhino-” is Greek for “nose”. And of course “virus” is just a simple Latin word, but it doesn't translate well. Something to think about next time you have a cold …

Finally, here's a weird nest of associations that came up while I was writing. When I said “biblical”, above, I was already thinking about words, in fact about words that do things, so how could I not think of “In the beginning was the Word” (John 1 : 1). But then, when I moved the emphasis to “do”, it seemed like maybe the version from Faust was preferable: “In the beginning was the Deed”. So, then I moved on to Stephenson, and to Snow Crash; I neglected to mention that there were some biblical connections in there, too. Then, later, when I was writing about command lines, it all came together, and I thought of a book that I hadn't thought of in years, by Stephenson of course, called In the Beginning … Was the Command Line. Unfortunately, none of this has anything to do with what I was talking about.


  See Also

  Fractions in Base 2

@ March (2004)