Meet the Altair · Choosing a reply

A different
reply.

So far, the computer has sent back exactly what it received. Now let the program make a choice: reply to lowercase a with uppercase A, and leave every other character alone.

Begin here: Lowercase a is prepared below. Send it, then step four instructions to receive it. The register A holds 97, and the text display is still empty. The next instruction asks whether this is the character we want to change.

Loaded reply program · reference card All addresses and bytes here are hexadecimal
These twenty-one bytes are already loaded at 0100. RAM shows what is stored now.
AddressReferenceRAMCheck

0100–0101: DB 00 reads readiness into A.
0102–0103: FE 00 compares A with zero.
0104–0106: CA 00 01 jumps to 0100 if Z = 1.
0107–0108: DB 01 receives the waiting byte into A.
0109–010A: FE 61 compares A with lowercase a.
010B–010D: C2 10 01 jumps to 0110 if Z = 0.
010E–010F: 3E 41 puts uppercase A into A.
0110–0111: D3 01 sends A to the text display.
0112–0114: C3 00 01 jumps to 0100.

Checking readiness leaves pending input alone. This lesson checks all twenty-one program bytes before executing. RAM is zero outside the program.

Operate the memory panel

The 8080 behind the panel

A decimal
0
PC hex
0100
RAM[1] decimal
0

Character input Port 0: readiness · Port 1: data

Prepared: a. Enable JavaScript to see its byte value and send it.

Typing prepares a character. Send or Enter offers it to the device. Line feed sends byte 10 separately.

Device empty. No byte waiting.

Ready now: 0 · empty

One byte can wait. When full, prepare another character here; it stays unsent until you send it after the CPU receives the first.

Received text Output port 1


    Waiting for output
  

No byte sent yet.

0 writes received.

Only OUT adds text. LF starts a new line; other non-printing bytes appear as labels in angle brackets.

Zero flag Z: 0 · the most recent comparison’s answer

The program is loaded. Enable JavaScript to run or step it.

Last CPU instruction

No instruction has run.

Look inside the last instruction
Step an instruction to see its fetched bytes, memory accesses, and any port transfers.
Recent instructions

0 instructions executed.

    RUN and STOP are teaching controls at instruction boundaries. Pace is for reading, not a simulation of the Altair’s clock. This page stops running when hidden. Looking at these readouts changes no state; EXAMINE changes PC.

    EXAMINE changes PC without running a program instruction. Stepping advances PC, and the panel lights follow it. This added control executes a whole instruction; the original SINGLE STEP switch advanced one machine cycle.

    ALTAIR 8800

    Memory controls · learning view

    Address lights The selected location

    0 decimal · 0000 hex

    Data lights The byte at that location

    0 decimal · 00 hex

    A lit lamp is 1; a dark lamp is 0. The digits help you read the lights.

    Data / address switches Up = 1 · Down = 0

    15–8 · Address only

    7–0 · Address or data

    All switches as an address
    0 decimal · 0000 hex
    Lower eight as a byte
    0 decimal · 00 hex

    Setting the switches prepares a number. It does not read or write memory.

    Raise only switch 8 and press EXAMINE to select 0100.

    Select the address in the switches and read its byte.

    Move to the next address and read its byte.

    Write the lower eight switches to the selected address.

    Move to the next address, then write the lower eight switches.

    EXAMINE would select address 0. DEPOSIT would write 0 to the selected address, 0.

    Last memory operation

    Enable JavaScript to operate the panel.

    This teaching terminal adds a comparison, a conditional jump, and a replacement instruction to the polling program. Start again restores the program, empties both devices and the text display, clears counts and history, prepares lowercase a, and stops at PC 0100. It is not the hardware RESET switch or a model of a particular historical terminal.

    Ask about the byte you received.

    The first four instructions are familiar: check readiness, compare with zero, decide whether to keep waiting, then receive a byte. The new work begins at 0109, after that byte reaches the register A.

    Lowercase a is 97 decimal, or 61 hex. Uppercase A is a different byte: 65 decimal, or 41 hex. The register is also named A; it can hold either value.

    CPI 61H compares the received byte with 97. As in our earlier comparison lesson, it sets the zero flag Z when the values match and clears Z when they differ. It leaves the value in A unchanged.

    Skip the change, or make it.

    The next instruction is JNZ 0110H: jump if Z is zero. A byte that differs from lowercase a takes this jump straight to OUT. Its value in A stays unchanged.

    For lowercase a, Z is 1, so the jump is not taken. Execution continues to MVI A,41H at 010E. This instruction copies the following byte, 65, into A. “Immediate” means the value is part of the instruction itself.

    There is no output yet. MVI changes A from 97 to 65, while preserving the flags and RAM. The next instruction, OUT 01H, finally sends 65 to the display, where it appears as uppercase A.

    Two paths to the same output instruction
    ReceivedAfter comparisonJNZReply
    a · 97Z = 1Continue through MVIA · 65
    b · 98Z = 0Skip MVIb · 98

    Look inside the last instruction shows the actual fetched bytes and transfers. Recent instructions lets you compare the two paths after they finish.

    Each answer belongs to a particular question.

    This program uses Z for two comparisons. At 0102, the question is “is the input device empty?” At 0109, it is “does the received byte equal 97?” The second comparison replaces the first answer.

    After the reply, the program returns to checking readiness. A may then hold 0 or 1, and Z describes that new comparison. The output text remains. Use the captured instruction history to inspect the earlier decision.

    Test the rule with unfamiliar input.

    Try A, z, a digit, punctuation, a space, and line feed. Then try a again. Only lowercase a should change; this program does not convert all lowercase letters to uppercase.

    For a longer experiment, RUN and send the characters of “a cat” one at a time, waiting for room in the device. Predict the whole reply before reading the explanation.

    Show an explanation

    The reply is “A cAt”. Both lowercase a bytes become uppercase A, while the space, c, and t pass through unchanged. Repeated output bytes still produce repeated characters.

    The input and display are the same teaching devices as before. The difference is in the program bytes loaded into RAM. The CPU compares numbers and follows instructions; the display still only presents the bytes sent by OUT.

    STOP keeps the current decision, pending input, and output intact. Start this lesson again clears the experiment and prepares lowercase a. As before, the text display keeps the latest 256 output bytes. The reference card shows the complete fixed program; changing a program byte pauses execution until it is restored.