Meet the Altair · Following a pointer

Printing
a message.

The computer can send text without waiting for you to type. Store a message in RAM, then let a small loop read and send its bytes one at a time.

Begin here: HELLO and a line feed are already in memory. Step once to set HL to 0100. The first message byte becomes highlighted, but A and the display have not received it yet.

Loaded message program · reference card All addresses and bytes here are hexadecimal
These fourteen program bytes are already loaded at 0000. The six message bytes begin at 0100. RAM shows what is stored now.
AddressReferenceRAMCheck

0000–0002: 21 00 01 puts 0100 into HL.
0003–0004: 06 06 puts 6 into B.
0005: 7E reads the byte at HL into A.
0006–0007: D3 01 sends A to the display.
0008: 23 advances HL.
0009: 05 subtracts one from B.
000A–000C: C2 05 00 jumps to 0005 if Z = 0.
000D: 76 halts the CPU.

The lesson checks all fourteen program bytes before executing. The message at 0100–0105 starts as 48 45 4C 4C 4F 0A: HELLO and line feed. Message data can be changed while stopped.

Operate the memory panel

The 8080 behind the panel

A decimal
0
PC hex
0000
HL address · hex
0000
B remaining · decimal
0

Message in RAM

Addresses and bytes in hexadecimal; characters interpreted as ASCII.
AddressByteCharacter
0100 48H
0101 45E
0102 4CL
0103 4CL
0104 4FO
0105 0ALF

Enable JavaScript to follow HL.

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

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 subtraction’s answer

CPU halted: no

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.

    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 uses the existing 8080 HELLO example: a program at 0000, message bytes at 0100, and the same teaching output device at port 1. Start again restores the program and message, clears the registers, flags, halted state, output, counts, and history, and stops at PC 0000. It is not the hardware RESET switch.

    Keep an address in the processor.

    The message occupies six consecutive locations, 0100 through 0105. Each holds one byte: H, E, L, L, O, and LF. Addresses and bytes in the memory window are hexadecimal.

    We need somewhere to remember which location to read next. The 8080 combines two of its byte registers, H and L, into the sixteen-bit pair HL. H holds the high byte and L the low byte: H = 01 and L = 00 together give address 0100.

    When a register value is used as an address, we call it a pointer. The first instruction, LXI H,0100H, puts the message’s starting address into HL. Setting an address does not read the byte stored there.

    PC and HL have different jobs here. PC tracks where to fetch instructions; HL points to message data. This example puts its program at 0000 and its message at 0100. The panel lights still follow PC; the new memory window follows HL.

    Read a byte. Then send it.

    The second instruction, MVI B,06H, puts 6 into B. This is the number of bytes the loop will send, including line feed. B is another byte register; its role as a counter comes from this program.

    The third instruction is MOV A,M. In this 8080 spelling, M means the memory location addressed by HL. It is not another register. The instruction reads the byte at 0100 into A, so A now holds 72. HL stays at 0100, and RAM keeps its byte.

    The fourth instruction, OUT 01H, sends that 72 to the display. H finally appears. Loading the pointer, setting the count, and reading RAM produced no output.

    Move the pointer, then repeat the work.

    INX H adds one to the register pair HL. The highlight moves from 0100 to 0101. A still holds 72, and the output still reads H: advancing an address does not load the next character automatically.

    DCR B subtracts one from the count, leaving 5 and clearing Z. JNZ 0005H returns to MOV while that count is nonzero. The loop reuses the same instructions, but MOV now reads through the new address in HL.

    Each trip reads, sends, advances, counts down, and tests. The changes happen in that order. Just after OUT, the byte has been sent but B has not yet decreased; just after INX, HL has advanced but A still holds the previous byte.

    The two L bytes live at different addresses, 0102 and 0103. Each trip produces its own OUT transfer. Equal byte values still make two visible letters.

    Let the count decide when to finish.

    On the sixth trip, the byte at 0105 is LF. OUT moves the display to a new line. INX advances HL to 0106, just beyond the message window, and DCR leaves B at zero with Z = 1. The final JNZ continues past the loop.

    The program does not use line feed as a stop signal. B decides how many bytes to send. If one of the six bytes changes, the loop still makes six trips.

    The next instruction is HLT. This is the program telling the CPU to halt. PC advances to 000E, the halted indicator becomes yes, and RUN and Step become unavailable. The message and final state remain visible.

    The viewer’s STOP button only pauses between instructions; RUN can resume that pause. HLT changes the CPU’s own state. EXAMINE can change PC but cannot release HALT. Use Start this lesson again to restore the complete example.

    How many instructions ran?

    Two setup instructions, six trips through a five-instruction loop, and one HLT: 33 instructions. Final HL is 0106, B is 0, A is 10 (LF), and PC is 000E. The output device received six writes, and the display reads HELLO followed by a new line.

    Change the data, keep the program.

    The memory window reads actual RAM. You can change the message with the familiar panel while stopped, leaving the instructions alone.

    Try printing JELLO instead
    1. Start this lesson again.
    2. Set the panel switches to 0100 and press EXAMINE.
    3. Set the switches to 004A and press DEPOSIT. The first message byte changes from H to J; nothing is sent yet.
    4. Lower all switches and EXAMINE 0000 to return PC to the program.
    5. RUN, or step through it. Predict whether the instruction path and byte count will change.

    The display prints JELLO and a line feed, using the same 33 instructions and six writes. Restart restores HELLO.

    Only the message data changed. The same pattern—read through a pointer, advance it, and repeat—can also copy a buffer, add a series of numbers, or inspect a sequence of bytes.