Ow, my brain!

Apollo 11 astronautI write code for a living. But we web developers have it easy. Server-side scripting languages like PHP may look alien at first, but they’re pretty easy to pick up and intuitive enough that you can really get going pretty fast, and once you’re familiar with the basic principles, it’s not hard to look at a block of code and figure out what it does.

But programming in the old days was a much finer and darker art. System resources were scarce, and everything had to be as efficient as possible — on the computer hardware, at least. A lot more of the “processing” had to happen inside the brains of the programmers before any of the code was even written. Looking at this kind of old code fries my brain.

The most notorious example of old-school assembler code I’ve encountered is the language used to program the Atari 2600. That’s something I’ve never been willing to touch, myself. And it’s for something trivial — video games. But here’s something that really freaks me out: the original source code from Apollo 11. This code is every bit as inscrutable — or more — and it was mission critical: the lives of three astronauts, over 200,000 miles from Earth depended on it working flawlessly.

Well, they made it back, so I guess it worked. But looking at the code, I have no idea how. Here’s an excerpt:

GUILDEN		EXTEND			# IS UN-AUTO-THROTTLE DISCRETE PRESENT?
# STERN					# RSB 2009: Not originally a comment.
  		READ CHAN30
		MASK	BIT5
  		CCS	A
  		TCF	STARTP67	# YES
P67NOW?		TC	CHECKMM		# NO:  ARE WE IN P67 NOW?
		DEC	67
		TCF	STABL?		# NO
STARTP66	TC	FASTCHNG	# YES
		TC	NEWMODEX
DEC66		DEC	66
		EXTEND
		DCA	HDOTDISP	# SET DESIRED ALTITUDE RATE = CURRENT
		DXCH	VDGVERT		# 	ALTITUDE RATE.
STRTP66A	TC	INTPRET
		SLOAD	PUSH
			PBIASZ
		SLOAD	PUSH
			PBIASY
		SLOAD	VDEF
			PBIASX
		VXSC	SET
			BIASFACT
			RODFLAG
		STOVL	VBIAS
			TEMX
		VCOMP
		STOVL	OLDPIPAX
			ZEROVECS
		STODL	DELVROD
			RODSCALE
		STODL	RODSCAL1
			PIPTIME
		STORE	LASTTPIP
		EXIT
		CAF	ZERO
		TS	FCOLD
		TS	FWEIGHT
		TS	FWEIGHT +1
VRTSTART	TS	WCHVERT

Source: Daring Fireball (of course).