Meet the Altair · Putting the pieces together
A tiny
command prompt.
The computer can print a question, remember your answer, and decide what to do. Then it can come back for another answer. You already know most of the pieces.
Begin here: Choose 20 instructions per second and press RUN. When > appears, send the prepared H. After the device becomes empty, press Send line feed. Watch H appear, followed by HELLO and another prompt. STOP pauses the program; it does not finish by itself.
Loaded command prompt · reference card All addresses and bytes here are hexadecimal
| Address | Reference | RAM | Check |
|---|
0000 sets SP to 0200. At 0003, the caller selects the prompt at 0120 and calls the printing routine at 0065. Then it sets HL to buffer address 0100 and B to eight slots.
000E calls the receive routine at 005B. LF selects the line ending at 0026. Other bytes are stored through HL, echoed with OUT, and counted with DCR B. When B reaches zero, 001E receives and discards further bytes until LF.
0026 appends NUL and outputs LF. MOV A,B copies the remaining count for comparison: eight slots means an empty line; seven means exactly one character. Longer lines select UNKNOWN. The one-character path reads RAM at 0100 and compares with 48 (H) and 3F (?).
0046 selects UNKNOWN at 0160; 004C selects HELLO at 0130; 0052 selects the help text at 0140. All call the same printing routine, then jump to 0003 for another prompt.
005B polls input port 0 until ready, receives from port 1 into A, and returns. 0065 saves HL with PUSH H, prints nonzero bytes through the pointer, restores it with POP H, and returns. Neither routine changes B.
Only the program bytes are guarded. Buffer, message, and stack data remain editable while stopped. Input is matched by the 8080 program; the viewer neither recognizes commands nor chooses responses.
This lesson connects an 8080, 65,536 bytes of RAM, and teaching byte-input/output devices. It keeps processing lines until you STOP. Start again restores the program and messages, clears the buffer, stack, CPU state, devices, output, counts, and history, prepares H, and stops at PC 0000. It is not the hardware RESET switch or a historical command interpreter.
One line at a time.
The prompt, > , is an invitation to enter a command. It is two bytes in RAM, printed by the same kind of routine we used in the previous lesson. The CPU sends them to output port 1.
This program knows two commands. Send uppercase H for a greeting, or ? for help. Finish each command with the separate Send line feed button. The program waits for that ending before deciding what your line means.
The input field still prepares just one character. Enter sends that character; it does not end the line. Wait for the input device to be empty before sending another byte. There is no line editor or backspace here.
> H HELLO > ? H=HELLO ?=HELP >
Every visible character in this conversation comes from an OUT instruction, including the echo of your input. Preparing or sending H does not immediately put it in RAM or on the display.
A main loop and two routines.
The main program repeats four jobs: print a prompt, read a line, choose a reply, and print it. A jump brings execution back to the prompt. There is no HLT instruction.
One routine receives a byte. It keeps checking readiness at input port 0, then reads input port 1 and returns with the byte in A. The other routine prints a message beginning at HL, stopping at NUL. PUSH H and POP H preserve the caller's pointer.
Both routines use CALL and RET. Open Follow the buffer and stack to see the return address. Printing also saves H and L below it. Each completed call brings SP back to 0200, so processing more commands does not keep using more stack space.
A command is data until the program interprets it.
Open Follow the buffer and stack to watch the input loop write characters at 0100 onward. HL points to the next free location, and B counts the unused slots. Line feed is not stored: it makes the program append NUL and print a new line.
MOV A,B copies the remaining count into A so CPI can test it. B itself is unchanged. Eight slots left means an empty line; seven means exactly one character. Any longer line selects UNKNOWN.
For a one-character line, the CPU reads the byte back from RAM at 0100. It compares with 72 decimal for H, then 63 for ?. Conditional jumps choose which message address to put in HL. The common printing routine reads that message from RAM.
An empty line brings back the prompt without a reply. Lowercase h, a space, HI, and every other unrecognized line produce UNKNOWN. Matching is exact: a line beginning with H is not enough.
A full buffer still needs an ending.
The buffer has eight character slots and an extra location for NUL. After the eighth store, B reaches zero and HL is 0108. The program stops storing and echoing characters, but it keeps receiving and discarding them until line feed arrives.
Only then does it append NUL, respond UNKNOWN, and print another prompt. It waits for the whole line's ending so that unwanted extra characters cannot become the next command.
Starting the next line resets HL and B. It does not erase the old bytes: the next line overwrites them and writes its own terminator. Seeing old text in RAM does not mean that text is a pending command.
The reply lives in memory too.
The greeting begins at 0130. The help message begins at 0140, and UNKNOWN at 0160. They are ordinary zero-terminated byte strings. Choosing an address and printing its contents are separate parts of the program.
Make H say JELLO
Start again and step 24 times, stopping at PC 005B. On the panel, EXAMINE 0130. Set the switches to 004A and DEPOSIT: that replaces H with J. EXAMINE 005B to restore the paused PC, then RUN and send H followed by LF. The command still selects the greeting, but the printing routine now reads JELLO from RAM. Start again restores HELLO.
STOP preserves the current instruction boundary, input, RAM, and output. RUN continues from there. Start this lesson again creates a fresh experiment, including empty devices and a restored program.
From bytes to a conversation.
You began with individual bits. This program combines numbers, memory, registers, instructions, loops, decisions, input, output, and subroutines into something you can use. The prompt is an ordinary program running on the same CPU you have been following.
Next, use the original Altair BASIC interpreter to calculate and store a small program. It runs on the same 8080, with a historical serial interface. Use All lessons below to revisit any of the pieces.
What this models
The program runs on the 8080 model with RAM and the teaching byte devices from earlier lessons. Browser controls prepare and offer input; the 8080 executes all command handling. The display retains the latest 256 output bytes. This is a teaching program, not an Altair monitor, BASIC, operating system, or model of a historical terminal. The panel remains available for memory experiments; jumping into the middle of routines can bypass their setup.