Meet the Altair · Checking readiness

Waiting for
a byte.

Previously, you made sure a byte was waiting before the computer read it. Now let a program check for itself. It can keep asking, receive a byte when one arrives, and return to ask again.

Begin here: Leave the input device empty and step three instructions. PC returns to 0100. Then Send byte to device and step six instructions to check, receive, echo, and return.

Loaded polling program · reference card All addresses and bytes here are hexadecimal
These fourteen 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: D3 01 sends A to the lamps.
010B–010D: C3 00 01 jumps to 0100.

Checking readiness leaves pending input alone. This lesson checks all fourteen 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

An input device Port 0: readiness · Port 1: data

Prepare a byte

Enable JavaScript to prepare a byte.

Device empty. No byte waiting.

Ready now: 0 · empty

Switches prepare a byte. Send stores it; IN 01H reads it. The device holds one byte at a time.

A separate lamp device Output port 1

No byte sent yet. 0 writes received.

Each OUT sends A here. The device keeps that byte until another arrives. Lit = 1; dark = 0 after a byte has arrived.

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 lesson connects an 8080, 65,536 bytes of RAM, input readiness at port 0, input data at port 1, and a separate output device at port 1. The program keeps looping until you STOP; it has no final instruction. Start again restores the program, empties both devices, clears counts and history, prepares 42, and stops at PC 0100. It is not the hardware RESET switch.

    First, ask a different question.

    The same input device now has two connections. Input port 0 answers “Is a byte ready?” with 0 for empty or 1 for ready. Input port 1 hands over the byte itself.

    IN 00H reads readiness into A. It leaves any waiting byte in the device. You can check again and again without consuming it. Only IN 01H takes the byte.

    Ready now shows the device’s current answer. A shows what the CPU last read. Looking at either display does not execute an instruction or read a port.

    Waiting can be work.

    After reading readiness, CPI 0 compares A with zero. If the values match, the zero flag Z becomes 1. A keeps its value.

    JZ 0100H means “jump to 0100 if Z is 1.” When the device was empty, the program goes back to ask again. These three instructions form a polling loop: read readiness, compare, and decide whether to repeat.

    Try RUN while the device is empty. Recent instructions keeps growing its total and shows the latest twelve steps, even though no byte reaches the lamps. The processor is executing instructions while the program waits for input.

    The earlier lesson’s pause before an empty input read is gone here. The program decides when to receive data. STOP pauses execution at an instruction boundary; it preserves A, the flags, and both devices.

    A byte takes the other path.

    Send a byte while the program is running. On its next readiness read, A becomes 1. Comparing that with zero clears Z, so JZ continues past the jump.

    Now IN 01H receives the waiting byte into A, and OUT 01H sends it to the lamps. Finally, JMP 0100H returns to the readiness check. You no longer need to EXAMINE 0100 between arrivals.

    The next check replaces A with a readiness answer. The output device keeps its last byte until another OUT. It can keep displaying 42 while A holds 0 and the CPU checks for more input.

    As before, the device holds only one pending byte. Send becomes available as soon as the data read empties it. Another byte can wait there while the first one is still in A, about to be echoed.

    Zero can be ready.

    Lower every input switch and send zero. The device holds a byte, so readiness is 1. The program follows the ready path and then receives the data value 0. All the output lamps go dark when OUT sends it, and the write count increases.

    Readiness and data answer different questions. An empty device and a device holding zero both return 0 from the data port, so checking the data value alone cannot tell them apart.

    IN does not change flags. When the data read receives zero, Z still holds 0 from comparing the earlier readiness answer 1 with zero. Z reports the last comparison; it does not automatically describe A.

    Answers belong to a moment.

    Start again and step once with the device empty. A holds 0. Now send a byte before the comparison. Ready now becomes 1, but A stays 0: the previous answer does not rewrite itself.

    The comparison and jump still take the empty path. On the next trip, the CPU reads readiness again and discovers the waiting byte. Nothing was lost; the program needed one more check.

    Sending while stopped never starts the CPU. Choose RUN or step when you want to continue. Open Look inside the last instruction to see the actual port transfer; its recorded answer stays the same even when later input arrives.

    What this view models

    These are teaching devices, not particular historical Altair peripherals. Input has one pending byte, no queue, and no interrupt. The program runs at a teaching pace, not a modeled hardware clock. It has no end boundary or HLT: use STOP to pause it. The page also stops when hidden. The lesson checks its program bytes and instruction starts, but does not prevent empty data reads. If you EXAMINE 0107, you bypass the program’s check: IN returns zero when empty and OUT can echo that zero. Start this lesson again restores the program, empties both devices, clears counts and history, prepares 42, and stays stopped.