Building an Assembler, One Reboot at a Time
A semester-long term project building a Macro Assembler from scratch — and the habits a fragile, reboot-happy era beat into me.
A look back — long before any of the tools we argue about now.
The mid-90s, when I was deep in school, was all MS-DOS giving way to Windows 95 — and a constant cycle of formatting my PC and swapping parts in and out. For fun, I’d try to install this thing called Linux, carrying twenty floppy disks and feeding them in one by one, only to hit a bad block partway through and start over. Among the courses, sophomore year brought System Programming, and with it Microsoft Assembly.
The Term Project
It was my first encounter with a “term project” — the kind that eats a whole semester. The assignment: build a MASM (Macro Assembler) that could correctly run programs written in Intel assembly. The programs themselves were simple things Turbo C had spat out — a bit of arithmetic, some sorting — and the job was to build something that did what MASM did, then print every line of source code and hand it in.
It was billed as a team project, but none of us had any sense of how to divide the work. I covered for a shortage of skill with patience and effort, and somehow brought it home — a fifty-page report, run off on a dot-matrix printer. My grade was surprisingly good, which makes me suspect something, somewhere, was distorted.
One Enormous If-Else, and a Debugger
The task was to parse a text file of instructions and, depending on the instruction and the mode, do this or that — so I solved it the intuitive way, with countless if-else statements. It was written in C, but there’s no chance I gave a thought to modularization; I’m sure I copy-pasted with great diligence instead. Leaning hard on Turbo C, I learned to drive a debugger fluently, and to be patient. The irony: I’d fix the values I wanted in my head, then build a simulator of the code to produce exactly those — a slightly strange way to work, looking back.
The curriculum was tangled — data structures came the next semester, compilers and file systems the year after — and those, too, had to be built from scratch. Patience-wise, the later ones felt almost manageable, which makes me think that first term project did me some good in life.
Ctrl-S
With assembly, a few wrong moves would reboot the whole machine — you were touching real memory and interrupts, after all — so power-cycling was constant, usually the moment you reached for a printf. Debug mode or not, I switched the thing off and on again more times than I can count.
Hard to imagine now, but the editors of the day often had no autosave, and losing unsaved work was a regular event. Even after you saved, you weren’t safe unless you “parked” the disk heads before cutting the power. So I built the habits: Ctrl-S, dated versions, backups — kept up faithfully. That none of it matters anymore feels like its own small lesson in how fortunes turn.
Postscript: Assembly in the 2000s
I was good at assembly, by hand and in my head — but somewhere along the way I decided not to fight a battle I couldn’t win against the machine, and drifted off; cross-compilers and the rest were things other people handled for you. Three things from lately, though, that made me smile:
- Assembly still turns up in the TIOBE top 20 — it cracked the top 10 back in 2023, and even now, slipped to around nineteenth, it’s still hanging on. Treating a coalition of different CPUs as one entry might be cheating, but for something this old and low-level, I find it quietly amazing.
- These days I mostly run into assembly through WebAssembly. The ISA is different enough from my twenty-year-old memories to feel foreign, and I doubt I’ll have much reason to read the text form.
- The last time I really sat down with it was DeepMind’s discovered sorting algorithm. In C or C++ it might have felt like a letdown.
P.S. I file this under my “patience stories.” There has been more than one.
Part of 90s Computer Science Stories — first-person notes on growing up with computers and studying CS in Korea in the 1980s and ’90s. See the full series →
Adapted from my Korean essay on Brunch: brunch.co.kr/@chaesang/49
Comments