Apple 1 BASIC
Steve Wozniak's hand-assembled, integer-only BASIC for the Apple-1: a 4K interpreter shipped free on cassette in 1976, the first piece of software Apple sold and the direct ancestor of the Apple II's Integer BASIC.
Created by Steve Wozniak
Apple 1 BASIC (called simply “Apple BASIC” in 1976) is the BASIC interpreter Steve Wozniak wrote for the Apple-1, Apple Computer Company’s first product. It took up exactly 4,096 bytes and was loaded from a cassette tape into memory block $E000–$EFFF. It supported only integers, stored strings as fixed-size character arrays in the Hewlett-Packard style, and was given away free with Apple’s cassette interface card. Wozniak later extended it into the Apple II’s Integer BASIC, and Michael Steil describes the tape as the first software Apple ever sold. In a sense, it marks the start of Apple’s software history.
History & Origins
A computer needs BASIC
Wozniak began going to the Homebrew Computer Club in March 1975, while working at Hewlett-Packard on calculator design. The Altair 8800 and Microsoft’s Altair BASIC were the talk of the hobby scene, and Wozniak drew a firm conclusion. In his 2014 account he wrote: “I sniffed the wind and knew that the key to making my computer good (popular) was to include a high-level language and that it had to be BASIC.”
He also said this was why his designs started at 4 KB of RAM. In his view, 4K was “the minimum needed to run a higher level language”. When 4K dynamic RAM chips became affordable in 1975, he could build a computer that ran BASIC instead of another “switches and lights” machine.
Learning the language from the wrong manual
Wozniak had only used BASIC for a few days in high school, so he picked up an HP BASIC manual late one night at work and made notes on its commands. He did not realize that HP’s BASIC was, in his words, “extremely different than DEC BASIC”, the dialect used by 101 BASIC Computer Games and by Microsoft, especially in how it handled strings. As a result, Apple BASIC took its string model from HP rather than DEC. Every Microsoft-derived BASIC used LEFT$, MID$ and RIGHT$, but Wozniak’s used array-style substrings instead.
Hand-assembled, integer only
Wozniak had no formal training in writing compilers. He drew syntax diagrams for the language and designed his own way to evaluate expressions: a “NOUN” stack for operands, a “VERB” stack for operators, and two priority tables per operator. He has said the approach drew on what he knew about converting expressions into the Reverse Polish Notation used by HP calculators.
He took floating point out of the design on purpose. He hoped to write the first BASIC for the MOS 6502 and to get “a little fame in the hobby world, like Bill Gates”. Dropping decimal numbers saved “a few weeks”. He could not afford time-sharing, so he wrote and assembled the code by hand, and he kept about fifty folders of notes, each labelled GAME BASIC. He showed the interpreter at Homebrew meetings as it grew, adding a few more working commands each month. He says this was “even before Steve Jobs saw that my computer existed.”
Shipping with the Apple-1
Apple Computer was founded on 1 April 1976, and the Apple-1 went on sale that July for $666.66. It was a single assembled circuit board with a 6502, a built-in video terminal and 4K of RAM. Apple’s advertising offered three products:
| Product | Price |
|---|---|
| Apple-1 (includes 4K bytes RAM) | $666.66 |
| Apple Cassette Interface (BASIC tape included) | $75.00 |
| Apple 4K byte RAM expansion memory | $120.00 |
The ad promised that “a tape of APPLE BASIC is included free with the Cassette Interface,” and that it “features immediate error messages and fast execution.” It also stated a policy aimed at hobbyists who had been paying for software: “our philosophy is to provide software for our machines free or at minimal cost.”
By October 1976 Apple had published a 14-page Preliminary Apple BASIC Users Manual. It openly warned that it would “most likley, contain errors, incorrect wordings, etc.” (the typo is in the original).
Running Apple BASIC on an Apple-1
Loading the language took some hardware setup:
- Memory had to be rewired. The cassette interface manual tells owners to break a solder jumper and move the Apple-1’s second 4K bank of on-board RAM from the
1block to theEblock, “which is where Apple Basic resides.” BASIC itself filled that 4K, and user programs lived in the first bank. - The tape was read from the monitor. With the tape rewound, the user typed
C100Rto enter the cassette program in the interface card’s PROMs, thenE000.EFFFR, started the tape and pressed RETURN. The manual says loading takes “about 30 seconds.” - BASIC was started at a raw address. Typing
E000Rstarted BASIC with an empty workspace and showed the>prompt. TypingE2B3Rre-entered BASIC with the current program intact, which the manual notes is “extremely useful when you have unintentionally hit the ‘RESET’ button.”
Saving a program worked the same way. The user left BASIC and wrote two memory ranges to tape: BASIC’s pointer area and the program space. After reading them back, the user re-entered BASIC at E2B3. By default, LOMEM started at 2048 and HIMEM at 4096, so a program lived in the 2K between those two addresses unless the user moved the limits.
Language Design
Numbers
The manual’s first rule is simple: “Apple BASIC can represent integers in the range -32767 to +32767.” Any value outside that range caused *** >32767 ERR. Division truncates to an integer, and MOD gives the remainder. Relational and logical operators return 1 or 0. As in HP BASIC, # can be used for “not equal” alongside <>.
Because it stored numbers as 16-bit integers and had no floating-point code, the interpreter fit in 4K. That also made the language well suited to the games and logic programs Wozniak had in mind, and poorly suited to anything that needed fractions.
Variables and arrays
Variable names were short. The manual allows a letter, or a letter followed by a digit (A, T6), for numbers and arrays, and a letter followed by $ for strings. (The Apple II’s Integer BASIC later allowed long variable names.) Apple 1 BASIC had one notable quirk:
In Apple BASIC the first element of an array, A(1) is identical to the simple variable A.
Arrays had one dimension, started at index 1 (a subscript of 0 caused RANGE ERR), and were not initialized.
HP-style strings
Strings were DIMed with a maximum length from 1 to 255 characters; an undimensioned string had a maximum length of zero. Substrings used subscripts instead of functions:
| |
Line 30 prints EFG (from position 5 to the end), and line 40 prints BCDEF. To join strings, you assign into a position past the end of the target string. The manual gives B$(LEN(B$)+1) = A$ as the way to append. String comparisons in IF allowed only = and #.
Statements and commands
The complete vocabulary fits in a few lines:
| Kind | Keywords |
|---|---|
| Editing and control commands | AUTO, CLR, DEL, LIST, RUN, SCR, HIMEM=, LOMEM= |
| Statements | LET, INPUT, PRINT, TAB, FOR/TO/STEP, NEXT, IF/THEN, GOTO, GOSUB, RETURN, DIM, REM, END, POKE, CALL |
| Functions | ABS, SGN, PEEK, RND, LEN |
Several details set it apart from other BASICs:
SCR(“scratch”) cleared the program. Most dialects called thisNEW, and the Apple II later used that name too.TABwas a statement, not a function insidePRINT:TAB 20: PRINT "Hello".GOTOandGOSUBaccepted expressions, soGOTO (A+B/2)was legal.CALLjumped to a 6502 machine-language subroutine, and anRTSreturned to BASIC. Together withPEEKandPOKE, this was how programs reached the hardware.- There were no
READ/DATAstatements, no graphics and no sound. The Apple-1 had a text-only terminal with 40 columns and 24 lines. - Nesting was limited: more than 8 nested
FORloops orGOSUBs caused an error. - Pressing any key interrupted a running program at the end of the current line, printing
STOPPED AT X. The program could then be resumed withGOTO X. - Multiple statements on one line were separated by colons.
A short program in the style of the 1976 manual:
| |
Evolution into Integer BASIC
Apple 1 BASIC had only one public release. Instead of revising it, Wozniak moved the code to the Apple II. That machine was introduced in April 1977 and began shipping in June with the interpreter in ROM, now named Integer BASIC. In his own account, Wozniak recalls designing the new features around games. To write Breakout in BASIC, he added commands to plot in color, draw horizontal and vertical lines, and read paddle controllers, and he thinks this is when he added a speaker for sound effects. The Apple II version also added COLOR=, GR, TEXT, PLOT, HLIN, VLIN, SCRN, PDL, TRACE/NOTRACE, DSP, CON, POP and ASC, renamed SCR to NEW, and dropped the two-character limit on variable names.
Wozniak also wrote floating-point routines for the 6502, but they never made it into his BASIC. As he put it, “When you code by hand … it’s hard to make changes in the middle structure of things that have to be at fixed addresses.” Apple licensed Microsoft’s 6502 BASIC instead. As Applesoft BASIC, it replaced Integer BASIC in ROM when the Apple II Plus arrived in 1979.
The Apple-1 was cut to $475 in April 1977 and dropped from Apple’s price list in October 1977. Apple reportedly offered trade-ins toward Apple IIs, and about 200 boards had been built in total, according to Wozniak. Original machines and BASIC tapes are rare as a result.
Rediscovery
For decades, the interpreter survived only on the few surviving cassettes. In 2002, Achim Breidenbach of Boinx Software received an MP3 recording of an original tape owned by Apple-1 owner Larry Nelson. He decoded it with a program he wrote in GFA BASIC on an Atari ST and published an emulator with a commented disassembly. Other people later “corrected” instructions in that dump that they thought were errors, so the copies in circulation were no longer faithful to the tape.
In July 2008, Michael Steil went back to the audio. He wrote a small C program that measured the width of the pulses in the recording, where the cassette interface reportedly encodes a one bit as a longer (about 1 kHz) cycle and a zero bit as a shorter (about 2 kHz) cycle. He published what he called the “first confirmed perfect dump” of the 4,096 bytes. Four days later he released apple1basic. It is not an emulator but a static recompilation of the original 6502 binary into native Mac OS X Intel code, connected to Unix stdin and stdout. With it, a 1976 program can run as a #!/usr/bin/apple1basic script. Steil also converted several Apple-1-era game programs from tokenized hex dumps back into readable BASIC.
Current Relevance
Apple 1 BASIC is a historical language. Nobody develops it and no official container image exists. The original binary still survives, though, and people run it today in Apple-1 emulators, on hardware replicas, and in recompiled form such as Steil’s apple1basic. Its manual, advertisement and cassette-interface documentation are preserved online, including scans at the Internet Archive.
Why It Matters
- It was Apple’s first software product. It came bundled free with a hardware card at a time when many hobbyists paid for their BASIC, and Apple’s ads made a point of that.
- It shaped the Apple II. Integer BASIC, the language in the Apple II’s ROM when it launched in 1977, grew directly out of this 4K interpreter.
- It shows the HP branch of the BASIC family. Its array-style substrings,
#for “not equal” and fixed-length strings came from HP Time-Shared BASIC by way of a manual Wozniak happened to pick up. Microsoft-derived BASICs soon became the norm, and Wozniak reportedly later called the move to “the awful string functions likeLEFT$” andMID$his biggest disappointment. - It shows how much fit in 4K. A line editor, tokenizer, expression evaluator, strings, arrays, 16 error messages and a machine-code interface all fit in 4,096 hand-assembled bytes.
Timeline
Notable Uses & Legacy
Apple Cassette Interface bundle
The BASIC tape came free with Apple's $75 cassette card. Michael Steil calls it the first piece of software Apple ever sold (not counting firmware). Without the card, the only way to load a program was to type machine code in hex through the monitor
Apple-1 game tapes
Apple's 1976 advertising promised games at minimal cost. Games written for the Apple-1 in the 1970s, including Blackjack, Acey-Deucey, Bowling, Slot Machine and Star Trek, survive as tokenized BASIC programs, and Steil converted them back into readable source
Apple II Integer BASIC
Wozniak extended the same interpreter into the Apple II's ROM BASIC. It added graphics, sound, paddle input and debugging commands, and was the language early Apple II owners used until Applesoft BASIC replaced it in ROM on the Apple II Plus in 1979
apple1basic for Mac OS X
Michael Steil's 2008 static recompilation turned the original 6502 binary into a native Unix command. It reads programs from files or stdin and can be started with a #! line, so 1976 BASIC programs run like shell scripts