// Mote Prime - Article

Mote Prime

A personal website

Articles

Atheism

Competitions

Humour

Paranonsense

Politics

Science

Technology

Links

Atheism

Humour

Paranonsense

Reviews

Science

Technology

About

Mote Prime

Author

Other Sites

OfQuack Podcasts

H:MC18

Little Book of Clam

Ads

Stop the Saatchi Bill

free debate

10:23

Mote Prime > Technology

How We Programmed in the Olden Days

No compiler, no assembler. My first commercial project was done with a hex editor and pencil and paper.

Way back in about 1982, I wrote a few games in hex on my ZX81, for my own amusement, and got quite good at doing hex coding of Z80 machine code, to the point where I didn't actually have to write down the mnemonics. I managed to graduate this "style" of coding to my first commercial project.

Graduating from the ZX81, over the course of 1985 I wrote the Graphic Adventure Creator on an Amstrad (which was also Z80 based) entirely using a hex loader. This was not due to any beardiness (1985 was bumfluff time for me) or weirdiness (for once) but simply because I was a poor student and couldn't actually afford an assembler.

Doing this in hex was in hindsight a complete and utter bastard. Here's why:

In assembler you can mess around with the size of subroutines. I couldn't. If I wanted to extend a routine I had two choices - either move it to the end of the code (freeing up the previously used bytes) or tack a jump onto the end and put the rest of the routine at the end of the code.

Changes to the code usually involved either strategic use of NOPs, rewriting or, again, tacking a patch routine onto the end of the code. This involved taking 3 bytes out of the main code, tacking in a jump to the end, where those 3 bytes were then added together with the patch, and a jump back. Example:

...
0440: 2A 03 01 ld hl, ($103) ; oops! forgot to ld a,(hl)
0443: 11 00 00 ld de,0
...

becomes:

...
0440: C3 A0 41 jmp Patch41A0
0443: 11 00 00 ld de,0
...

... 41A0: 2A 03 01 ld hl,($103) 41A3: 7E ld a,(hl) 41A4: C3 43 04 jmp $0443 ...

Blimey. 25 years later and I can still do this from memory. My memory therefore needs a good clearout.

I also had to manually recalculate the offsets for relative jump instructions. After a couple of months, you get very, very adept at counting backwards in hex. "FF,E,D,C,B,A,9,8,7,6,5,4,3,2,1,0,EF,E,D,C,B. Aha. EB.". See, I was right.

Worst of all, when the time came for others to port the thing onto the Spectrum, Commode and BBC, I then had to write a disassembler (in hex) and spent the best part of a month fixing up the patches in a text editor and commenting the code printout in pencil. And there was a bug in the disassembler that meant that IX and IY instructions weren't handled properly.

Of course, I've learned my lesson now, and use C++ and a Big Computer (tm) to code stuff. But I still long for the old, nostalgic days of the ZX81, when men were real men, etc.

Actually, no I don't, it was a complete pig. But it made you think terribly hard about how your code worked and what went into it.

See also the article The Graphic Adventure Creator for a whole bunch more detail, including scanned listings, hex dumps and notes.