Meet the Altair · Writing through a pointer

Remembering
what you type.

A character need not be printed as soon as it arrives. The program can save several characters in RAM, then read them back when the message is ready.

Begin here: Send the prepared H while stopped. Step eight times to receive it and check that it is not LF. A holds 72, but RAM and the display are unchanged. The ninth instruction, MOV M,A, makes the first stored character appear in the buffer.

Loaded buffer program · reference card All addresses and bytes here are hexadecimal
These forty-four program bytes are loaded at 0000. The nine-byte buffer at 0100 starts at zero. RAM shows what is stored now.
AddressReferenceRAMCheck

0000: LXI H,0100H sets the write pointer; 0003: MVI B,08H sets the capacity.

0005: IN 00H, 0007: CPI 0, and 0009: JZ 0005H poll readiness. 000C: IN 01H receives a byte. 000E: CPI 10 and 0010: JZ 0019H finish on LF.

0013: MOV M,A stores a character; 0014: INX H advances HL; 0015: DCR B counts down; 0016: JNZ 0005H returns only if space remains.

0019: MVI A,00H and 001B: MOV M,A append NUL. 001C: LXI H,0100H rewinds the pointer.

001F: MOV A,M, 0020: CPI 0, and 0022: JZ 002BH check for the terminator. 0025: OUT 01H, 0027: INX H, and 0028: JMP 001FH print nonzero bytes. 002B: HLT finishes.

Instruction addresses and reference bytes are hexadecimal. CPI 10 compares with decimal 10 (0A hex). The lesson checks all forty-four program bytes. Normal collection stores at most eight characters at 0100–0107 and a terminator no later than 0108.

Operate the memory panel

The 8080 behind the panel

A decimal
0
PC hex
0000
HL address · hex
0000
B slots left · decimal
0

Character input Port 0: readiness · Port 1: data

Prepared: H. 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.

Buffer in RAM

Addresses and bytes in hexadecimal; characters interpreted as ASCII.
AddressByteCharacter
0100 00NUL
0101 00NUL
0102 00NUL
0103 00NUL
0104 00NUL
0105 00NUL
0106 00NUL
0107 00NUL
0108 00NUL

Enable JavaScript to follow HL.

The marker follows HL. Looking at these bytes changes no CPU or memory state.

0100–0107: up to eight characters. 0108: room for NUL when full. LF ends collection; it is not stored or printed. Once printing begins, later input stays pending until restart.

Zero flag Z: 0 · the latest comparison or count decrement’s answer

CPU halted: no

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

Last CPU instruction

No instruction has run.

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.

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.

    Lower all switches and press EXAMINE to select 0000.

    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, and separate teaching input and output devices. The program collects up to eight characters, appends NUL, prints the buffer, and halts. Start again restores the program, clears RAM, registers, flags, halted state, both devices, output, counts, and history, prepares H, and stops at PC 0000. It is not the hardware RESET switch.

    A place to keep the characters.

    A buffer is a region of memory used to hold data. Our program uses 0100–0107 for up to eight characters, with one extra location at 0108 available for the zero terminator. All nine locations start at zero.

    LXI H,0100H puts the first buffer address into HL. MVI B,08H puts the capacity into B. During collection, HL points to the next place to write, and B counts the character slots still available.

    The input device still holds only one pending byte. The larger buffer is ordinary RAM, filled by the program. Typing or pressing Send does not write to it.

    Use the pointer in the other direction.

    You have seen MOV A,M read through HL. MOV M,A copies in the other direction: from A into the memory location addressed by HL. M still means “the byte at HL.”

    The first store writes 48 hex, or 72 decimal, at 0100. A keeps 72, HL stays at 0100, and the display stays empty. INX H then advances HL to 0101; DCR B reduces B from 8 to 7. These are separate changes.

    If B is not zero, JNZ returns to the readiness check. The program can keep polling while you prepare the next character. Readiness checks change A, but the stored H remains in RAM.

    Tell the program the message is ready.

    After IN 01H receives a byte, the CPU compares it with 10 decimal, the value of LF. For this program, LF means finish collecting. It skips the character store, so LF takes no slot and does not enter the buffer.

    The CPU puts zero into A, stores it through HL, and resets HL to 0100. This appends NUL after the characters and brings the pointer back to the start. Even though unused RAM already starts at zero, the program explicitly writes its terminator.

    The familiar print loop now reads through HL, compares with zero, and sends each nonzero byte. Only these OUT instructions put text on the display. It halts at NUL; neither LF nor NUL is printed.

    Sending LF first makes an empty message. The program stores NUL at 0100, then halts without executing OUT.

    Keep room for the ending.

    After the eighth character, DCR leaves B at zero. JNZ does not return for more input. The program immediately appends NUL at 0108 and prints the eight stored characters, without waiting for LF.

    The extra location matters: eight characters and a terminator require nine bytes. During normal execution from the start, the program never writes past 0108. B is decreased after the store, so it may briefly show its old value beside a newly written character.

    You can prepare or offer another character while the CPU finishes. A later offer may wait in the input device, but this run will not receive or store it. Starting the lesson again clears that pending byte and the buffer.

    The output comes from memory.

    Once a character has been stored, later typing does not change it. The readback loop obtains its bytes from RAM, not from the input field or a hidden copy of your text.

    Change stored H to J before playback
    1. Start this lesson again, RUN, and send H and I one at a time, waiting for room in the input device.
    2. Wait until I has been received and the device is empty. Press STOP before sending line feed, so the program cannot begin playback while you prepare the experiment.
    3. Send line feed while stopped. Use Step one instruction until PC is 001F, just before the first readback MOV.
    4. EXAMINE 0100, set the switches to 004A, and DEPOSIT. RAM now holds J where it held H.
    5. EXAMINE 001F to restore PC, then RUN. The display prints JI.

    Editing RAM after that MOV would leave the first character already captured in A unchanged.

    The switches remain available for experiments, but manually jumping into the middle of collection can bypass the setup and capacity check. Start again to return to the program’s normal path.

    The character field offers printable ASCII, including spaces. LF is sent separately. The raw byte device can accept other values; a stored NUL would end readback early because this format uses zero as its terminator.