Back to the machine

How to program an Altair 8800 by hand

No keyboard, no screen, no operating system. A program goes in one byte at a time through sixteen switches, and the lamps are the only thing that tells you it worked.

Open the panel and follow along

The machine on this site takes the same presses in the same order. It runs in the page, on a phone as well as a laptop, with nothing to download. Every switch setting and every lamp reading below is produced by driving that emulator through this exact procedure, so the page cannot drift away from the machine.

What you are working with

The bottom row has sixteen switches, numbered 15 down to 0. They are the address switches, and they do two jobs. A switch is a bit: up is one, down is zero. When you EXAMINE, all sixteen are read as an address. When you DEPOSIT, only the low eight are read, and they are the byte that gets stored.

Above them sit the control switches. Four of them matter here.

Everything is written in octal, in groups of three digits. That is not a preference: the switches are grouped in threes on the panel, so three switches spell one octal digit and a byte is three digits. An address is two bytes, so it is printed here as two groups of three, high byte first.

The program

The smallest thing that proves the machine is a computer: load two numbers, add them, store the answer, halt. Fourteen bytes, twelve of them instructions and two of them the numbers.

AddressOctalInstruction
000 000072 020 000LDA 0010hfetch the first number
000 003107MOV B,Akeep it in B
000 004072 021 000LDA 0011hfetch the second number
000 007200ADD Badd them
000 010062 022 000STA 0012hstore the sum
000 013166HLTstop — watch the HLTA lamp light
000 020002DB 2first number
000 021002DB 2second number

There is a gap in it. The instructions run from 000 000 to 000 013, and the two numbers sit at 000 020 and 000 021, out of the way of the code. That gap is why the procedure below has a second EXAMINE in the middle of it: DEPOSIT NEXT walks forward one address at a time and has no way of jumping.

The procedure

One row per press. The switches column is what the sixteen switches should read before you touch the control switch beside it, and the lamps column is what the machine answers with: the ADDRESS lamps, then the DATA lamps where they mean anything. Those lamp readings are not typed here. They are what the emulator on this site produced when a test drove it through every press in the table, which is also why the page cannot quietly stop matching the machine.

StepSwitchesPressLamps, address · data
1OFF/ONFlip OFF/ON up. The machine wakes with rubbish in memory, which is what a real one did.
2000 000EXAMINE000 000Set all sixteen address switches down and lift EXAMINE. This is where the program starts.
3072DEPOSIT000 000 · 072LDA 0010h, fetch the first number
4020DEPOSIT NEXT000 001 · 020the next byte of the one above
5000DEPOSIT NEXT000 002 · 000the next byte of the one above
6107DEPOSIT NEXT000 003 · 107MOV B,A, keep it in B
7072DEPOSIT NEXT000 004 · 072LDA 0011h, fetch the second number
8021DEPOSIT NEXT000 005 · 021the next byte of the one above
9000DEPOSIT NEXT000 006 · 000the next byte of the one above
10200DEPOSIT NEXT000 007 · 200ADD B, add them
11062DEPOSIT NEXT000 010 · 062STA 0012h, store the sum
12022DEPOSIT NEXT000 011 · 022the next byte of the one above
13000DEPOSIT NEXT000 012 · 000the next byte of the one above
14166DEPOSIT NEXT000 013 · 166HLT, stop — watch the HLTA lamp light
15000 020EXAMINE000 020The code has run out and the numbers live further along, so set the switches again and EXAMINE there.
16002DEPOSIT000 020 · 002DB 2, first number
17002DEPOSIT NEXT000 021 · 002DB 2, second number
18RESETRESET puts the program counter back to address zero.
19RUNPush STOP/RUN down. It is over in microseconds and stops on the HLT, so the HLTA lamp comes on.
20STOPPush STOP/RUN up. A HLT stops the processor but does not hand the machine back, and until it does the switches reach nothing.
21000 022EXAMINE000 022 · 004The answer, where the program stored it.

The last two steps are the part people get wrong. A HLT stops the processor, but it does not hand the machine back to the panel: until STOP/RUN comes up, EXAMINE and DEPOSIT reach nothing at all and appear simply to be broken. MITS said so plainly in the Theory of Operation, and this emulator behaves the same way.

When it does not work

Usually one byte is wrong. Fourteen switch settings is fourteen chances to leave a switch up, and nothing warns you: the machine runs whatever it was given. The fix is the one MITS printed in the Altair BASIC Reference Manual, Appendix A, steps 10 to 15. Set the switches back to the first address, EXAMINE, and compare the DATA lamps with what you meant to store. Press EXAMINE NEXT to walk forward one byte at a time. Where the lamps disagree with your listing, set the correct byte on the switches, DEPOSIT, and carry on.

The panel on this site has that check built in, because entering bytes and never verifying them is the usual reason a first program does nothing. It walks the memory, finds the first byte that differs from the listing, and puts that address on the switches for you, which is where step 11 leaves you on the real machine.

Where the procedure comes from

MITS's own documents. Each one is cited in full in the engineering notebook, which is where the rest of the evidence behind this machine lives.

After the first program

This is how every program arrived until the machine had something better to read from. The next step up is a sixteen-byte bootstrap loader toggled in the same way, which then reads a paper tape or a cassette and fills memory for you. That is how Altair BASIC got in: a program entered by hand whose only job is to read the program you actually wanted.