BASIC on the Altair

Your first BASIC program

Type a calculation and see the answer. Then ask the computer to remember a few instructions and carry them out together. You can start here without knowing any 8080 instructions.

View lesson source ↗

Continue your session, or load BASIC

If the terminal below already shows your earlier BASIC session, press the browser's RUN button to continue it. You do not need to load the tape again. This tab keeps the machine, program, terminal, and pending input as you move between BASIC lessons, visit All lessons, or refresh. Returning always pauses execution first. Other tabs work independently; a newly opened or duplicated tab may begin with a copy of this tab's saved session.

Begin a lesson's commands at OK. If your previous program is still asking a question at ?, finish that conversation first; the ticket loop finishes when you answer 0. The lesson's setup explains which stored lines to keep or replace. Typing NEW at OK clears the stored program and variables without reloading BASIC.

If this is a fresh machine, follow the loading steps below.

This is the original 4K BASIC 3.2 interpreter running on our Altair. An interpreter is a program that reads your commands and carries them out. Before it can understand PRINT, the Altair must load that interpreter into memory.

  1. Get the selected paper-tape file from the machine guide (opens in a new tab). Return here and choose it in Paper tape below. The file stays on your computer.
  2. Raise only switches A11 and A10. Leave PC at 0000: do not press EXAMINE. You may then close the front panel to bring the terminal closer.
  3. Press the browser's RUN button. Click Terminal keyboard and answer each question when it appears:
When you see Enter
MEMORY SIZE? Just Enter, to let BASIC find the available memory.
TERMINAL WIDTH? Just Enter, to keep the default.
WANT SIN? Y then Enter. We will not need this math function today.

When 727 BYTES FREE and OK appear, BASIC is ready. Leave the processor running for the lesson. Switching tabs pauses it; press the browser's RUN button when you return.

If you need to start loading again, use Start fresh, raise A11 and A10 again, then RUN. This discards the current BASIC program and uses the tape you already selected. Reset CPU + serial does not reload BASIC.

The saved session stays in this browser tab's temporary storage. It is not sent to the site. Copy your numbered lines somewhere to keep them beyond the browser session. If the browser cannot save or restore a session, a message beside the machine explains that; you can still use the current page.

A computer waiting for your instructions

From paper tape to BASIC.

Resume a saved session with RUN. To load BASIC for the first time, choose the 4K BASIC 3.2 tape (guide opens in a new tab), raise the loading switches, then RUN. Loading instructions

This tab can keep your BASIC session between lessons. Checking for a saved session…

The file stays on your computer. Selecting a verified tape prepares a fresh, stopped machine.

No tape selected.

Front panel · address, data, and sense switches

To load BASIC, raise only A11 and A10 and leave PC at 0000. Do not press EXAMINE after raising the loading switches. You can then close this panel to bring the terminal closer.

Operate the front panel

ALTAIR 8800

Memory and sense switches

Address lights PC · next instruction

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 + sense

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. The CPU can read the upper eight switches at port FF, even while running.

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.

EXAMINE and NEXT change PC. Only 0000–0FFF contain RAM; other addresses read FF and discard deposits. Lights show instruction boundaries, not individual bus cycles.

Stopped · 0 instructions

RUN lets the processor execute; STOP pauses it. At BASIC’s prompt, type RUN to run your BASIC program. Break sends Control-C to BASIC.


  
  

0 keyboard bytes queued

Use uppercase commands. Enter sends a line; Backspace sends BASIC’s erase character (_). Paste one line at a time. Only the machine’s echoes appear above.

Inspect the running machine

    

Latest twelve instructions on this page · PC before → after (hexadecimal)


  

Reset keeps RAM and the switches but resets the CPU and serial device. Start fresh discards the program, restores the bootstrap, rewinds the selected tape, and clears the terminal; raise the switches again before RUN.

An answer now

Once BASIC is ready, click Terminal keyboard, type this command in uppercase, then press Enter:

Type, then Enter

PRINT 2+3

BASIC replies

 5

OK

The spaces around the answer are normal. Here, PRINT means “send the result to the terminal.” This is an immediate command: BASIC does the calculation as soon as you submit the line. OK means it is ready for another command. The examples separate what you type from BASIC's reply; the terminal also echoes your input.

Try another sum. Predict the result before entering this command:

Type, then Enter

PRINT 2+8

BASIC replies

 10

OK

Try it in the terminal ↑

Instructions for later

At OK, type NEW to clear any program left from another lesson. Then type these three lines, pressing Enter after each one. If you paste, paste one line at a time. Wait until the complete line has appeared in the terminal before sending the next.

Type, then Enter

NEW

BASIC replies

OK

Type one line at a time, then Enter

10 PRINT "HELLO"
20 PRINT 2+3
30 END

Each line begins with a line number. That tells BASIC to store the instruction for later. You see the line echoed, but you do not get HELLO, the answer 5, or a new OK yet. That is expected.

The line numbers are decimal labels, not memory addresses. BASIC uses their order to decide which instruction comes next. We have left gaps between them so there is room to insert another line later.

Quotation marks make "HELLO" a piece of text to print. Without quotation marks, 2+3 is a calculation. END marks the end of our program.

Made a typing mistake? Before Enter, Backspace erases one character. BASIC echoes an underscore rather than rubbing the old character off the display. After Enter, type the whole numbered line again correctly: BASIC replaces the line with that number. If an immediate command produces an error, wait for OK and type it again.

Think about it. Why did PRINT 2+3 give an answer earlier, while 20 PRINT 2+3 did not? The leading 20 asks BASIC to remember the instruction. It has not been asked to run the stored program yet.

Enter the program ↑

Look, then run

Type LIST and Enter. BASIC prints the stored lines in line-number order, then OK. Check your program against this listing:

Type, then Enter

LIST

BASIC replies

10 PRINT "HELLO"
20 PRINT 2+3
30 END
OK

LIST shows what BASIC remembers; it does not execute those instructions. Now type RUN and Enter:

Type, then Enter

RUN

BASIC replies

HELLO
 5

OK

BASIC starts at the lowest line number. Line 10 prints the greeting, line 20 prints the sum, and line 30 returns control to BASIC. Run it again: the program is still there, so it produces the same result.

Type, then Enter

RUN

BASIC replies

HELLO
 5

OK

The typed BASIC command RUN starts your stored program. The browser's RUN button lets the processor execute instructions. Leave that processor running even at OK: BASIC needs it to receive your next command. END finishes your BASIC program without stopping the processor.

List and run ↑

Change one line

Enter this replacement, then LIST:

Type one line at a time, then Enter

20 PRINT 2+8
LIST

BASIC replies

10 PRINT "HELLO"
20 PRINT 2+8
30 END
OK

There are still three lines, with just one line numbered 20. Its calculation now reads 2+8; the greeting and END are unchanged. Run it:

Type, then Enter

RUN

BASIC replies

HELLO
 10

OK

Replacing one stored instruction changed what the program does.

Make it yours. Replace line 10, then predict the whole output before RUN:

Type one line at a time, then Enter

10 PRINT "HI"
RUN

BASIC replies

HI
 10

OK

Changing line 10 leaves line 20 alone.

Change your program ↑

A program running a program

Earlier lessons followed individual 8080 instructions. Here those same kinds of instructions run BASIC: they read characters, store your lines, calculate, and print. Your BASIC program gives the interpreter work to do.

You can keep experimenting in the terminal. This tab carries the BASIC machine and program between these lessons, including a visit to All lessons, and restores them paused after a refresh. Press the browser's RUN button to continue. Start fresh discards the program and reloads the retained tape. Copy your numbered lines somewhere for a lasting copy; browser session storage is temporary.

The machine guide (opens in a new tab) explains the hardware, loading process, and recovery controls. These lessons use that same machine and original interpreter.