Give a value a name, then let the person using your program choose that value.
The same instructions can produce different answers without changing a line
of the program.
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.
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.
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.
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.
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.
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.
A name for a number
Load or resume BASIC using the instructions above, and begin at OK. If you
continued from the first BASIC lesson, your
earlier program is still stored; these immediate commands leave its lines alone.
Suppose each ticket costs 2 pounds. We would like the computer to work out the
cost for different numbers of tickets. First, give the number of tickets a
name, N:
Type, then Enter
LET N=3
BASIC replies
OK
Type, then Enter
PRINT N
BASIC replies
3
OK
N is a variable: a name BASIC associates with a value. LET N=3 stores 3
under that name. It does not print the value; PRINT N asks to see it.
The name is not an 8080 register or a memory address we have chosen. BASIC
manages the storage for us.
Use * for multiplication. With three tickets at 2 pounds each:
Type, then Enter
PRINT N*2
BASIC replies
6
OK
Now change the value of N. Predict the new result before printing it:
Type, then Enter
LET N=5
BASIC replies
OK
Type, then Enter
PRINT N*2
BASIC replies
10
OK
The expression N*2 stayed the same. It uses the value that N has when BASIC
evaluates it. Assigning a new value replaces the old one.
Turn the calculation into a small stored program. Type NEW at OK to clear any
earlier program and variables, then enter one numbered line at
a time, waiting for its complete echo before sending the next:
Type, then Enter
NEW
BASIC replies
OK
Type one line at a time, then Enter
10 PRINT "HOW MANY TICKETS"
20 INPUT N
30 PRINT N*2
40 END
Line 10 prints the question. INPUT N on line 20 waits for a number and stores
it in N. Line 30 calculates the cost from that answer. Line 40 finishes the
program. Use LIST to check the lines:
Type, then Enter
LIST
BASIC replies
10 PRINT "HOW MANY TICKETS"
20 INPUT N
30 PRINT N*2
40 END
OK
Run the program. At ?, type 3 and Enter:
Type, then Enter
RUN
BASIC replies
HOW MANY TICKETS
?
Type, then Enter
3
BASIC replies
6
OK
The ? is BASIC's invitation to enter a value. It has not finished the
program and is not asking for another command. Type the number alone, not
LET N=3. In the terminal, your answer appears beside the question mark.
The result is 6 pounds.
While it waits for your answer, leave the browser's processor RUN control
running. The interpreter is checking for input; it needs to keep executing to
receive your number. When END returns to OK, BASIC is ready for commands again.
No program line changed. This time INPUT stored 5 in N, so the same calculation
produced 10 pounds. The earlier immediate assignments do not supply the answer:
each RUN reaches INPUT and waits for the person at the keyboard.
Predict a boundary. How much should zero tickets cost? Try it:
Type, then Enter
RUN
BASIC replies
HOW MANY TICKETS
?
Type, then Enter
0
BASIC replies
0
OK
We have kept this program small: it expects a whole number of tickets, zero or
more. It does not yet check whether an answer is sensible. In the
next lesson, we will give zero its own
reply and check for negative answers.
LET gives a variable a value chosen in an instruction. INPUT receives a
value from the person using the program. PRINT displays text or the result
of an expression. Together, they let a program accept data and do something
with it, while its instructions stay the same.
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.