Applesoft BASIC
Microsoft's floating-point 6502 BASIC as adapted by Apple: the tokenised, line-numbered interpreter at the ] prompt of every Apple II from the II Plus onward, with hi-res graphics, two-character variable names and a hook for machine code.
Created by Microsoft (6502 BASIC, usually credited to Marc McDonald and Ric Weiland), adapted for the Apple II at Apple by Randy Wigginton and colleagues
Applesoft BASIC is the dialect of Microsoft BASIC that Apple licensed for the Apple II and, from the Apple II Plus of 1979 onward, built into the ROM of every machine in the line. Switch on an Apple II Plus, IIe, IIc or IIGS with no disk to boot (on disk-equipped machines, typically after pressing Reset to stop the drive searching) and you land at a ] prompt: that bracket is Applesoft waiting for input. For a generation of home and school programmers it was simply what “programming the computer” meant.
As a language it is a typical late-1970s Microsoft BASIC: line-numbered, unstructured, dynamically typed, with floating-point arithmetic, whole-value strings and multi-dimensional arrays. Apple added graphics commands for the Apple II’s low- and high-resolution screens and a small set of hooks into machine code. This entry concentrates on the language as programmers wrote it and on how the interpreter works. The encyclopedia’s separate AppleSoft entry covers the licensing story and the Microsoft-Apple deal in more detail, and Apple IIe BASIC covers the IIe-specific firmware.
History & Origins
Dating the first Applesoft
The 1977 date holds up. A surviving Apple manual, the APPLESOFT Extended Precision Floating Point BASIC Language Reference Manual for the “Cassette – RAM Version”, is dated November 1977 and carries two copyright lines: “Copyright, 1977, Apple Computer Inc.” and “Copyright, 1977, Microsoft Co.” Its introduction describes Applesoft as “a powerful, floating point BASIC written expressly for the Apple II computer by Microsoft” and aims it at “business, science and educationally oriented applications which require extensive manipulation of decimal numbers.” Those were the uses Wozniak’s integer-only BASIC could not serve.
That first release, now called Applesoft I, was built on Microsoft’s 6502 BASIC version 1.1 and loaded from cassette into RAM. It kept Microsoft’s MEMORY SIZE? start-up prompt, replaced Microsoft’s OK prompt with a ], and used oddly abbreviated low-resolution graphics commands such as PLTG, PLTC and PLTP. It had no high-resolution graphics, no ONERR error trapping and no & statement.
Applesoft II
Applesoft II, released in 1978, is the version nearly everyone means by “Applesoft”. Its reference manual (©1978) describes two ways to get it: on cassette, “provided … at no charge, with each APPLE II” and occupying about 10K of RAM, or in ROM on a plug-in Firmware Card (Apple part A2B0009X), where “the flick of a switch and two key-strokes” started the machine in Applesoft. The manual still positions the two BASICs side by side. Integer BASIC is “very fast” and suited to “education, game playing, and graphics”, while Applesoft is “better suited for most business and scientific applications.”
When the Apple II Plus appeared in 1979, Applesoft II moved into the motherboard ROM at $D000–$F7FF, and Integer BASIC became a file on the DOS 3.3 disk. From then on Applesoft was the Apple II’s default language, and it stayed so on every later model.
Design Philosophy
Applesoft was not designed from a clean sheet. It is Microsoft’s portable 6502 BASIC with Apple-specific commands grafted on, and its character follows from that:
- Numbers are floating point by default. Microsoft’s core gave every numeric variable a 5-byte real representation. This was the feature Apple’s customers were asking for, and it is also the main reason the language is slower than Integer BASIC.
- Memory efficiency over readability. Keywords are stored as single-byte tokens, spaces are discarded on entry, and only the first two characters of a variable name are kept. On a 16K–48K machine, program space mattered more than descriptive names.
- Compatibility with Integer BASIC habits. Applesoft II adopted Integer BASIC’s names for the low-resolution graphics commands (
GR,COLOR=,PLOT,HLIN,VLIN) and its screen commands (HTAB,VTAB,CALL,PR#,IN#), so existing Apple II users did not have to relearn them. - An escape hatch to machine code. Apple assumed that serious programs would drop into assembly language for speed.
PEEK,POKE,CALL,USRand&are all part of the language, not afterthoughts.
Key Features
Program structure
A program is a sequence of numbered lines. According to the Applesoft II manual, line numbers run from 0 to 63999, and a line may hold up to 239 characters as typed. Several statements can share a line, separated by colons. ? is accepted as shorthand for PRINT and becomes the same token.
| |
Two Applesoft quirks are visible here. The manual says a FOR loop’s variable is compared with its limit “only at the bottom of the FOR…NEXT loop, [so] the portion of the program inside the loop is always executed at least once.” Without the IF guard on line 60, FOR J = 1024 TO 1000 would still run once and fail with a bad subscript. A false IF also skips everything else on its line, so the whole inner loop on line 60 is skipped when the condition fails. The loop variables are reals because the manual states that an integer variable used as a FOR index gives ?SYNTAX ERROR.
Data types
| Type | Written | Storage (per the Applesoft II manual) | Range |
|---|---|---|---|
| Real | AB | 5 bytes (40 bits) | about ±9.99999999E+37; prints up to nine digits |
| Integer | AB% | 2 bytes in arrays | ±32767 per Apple’s manuals (Wikipedia gives -32768 to 32767) |
| String | AB$ | 3-byte descriptor plus 1 byte per character | 0 to 255 characters |
Each simple variable takes 7 bytes: 2 for the name and 5 for the value, even for integers. So the % type saves memory only in arrays, and integer arithmetic is converted back to floating point anyway. Arrays can have many dimensions. The manual is not quite consistent about the limit: its syntax chapter gives 89 dimensions, while its worked example says 88 zero-size dimensions succeed and 89 give ?OUT OF MEMORY ERROR. It also notes that an array used before it is DIMensioned gets a default maximum subscript of 10.
Variable names and reserved words
Only the first two characters of a name are significant, so AB% and AB3QS% are the same integer variable. And because the tokeniser looks for keywords anywhere in the input, a name may not contain a reserved word. The manual’s own examples of illegal names are TO and RGOTO, and the classic trap is SCORE, which hides OR. The manual also admits some oddities: XPLOT is reserved but “does not correspond to a current APPLESOFT command,” and COLOR, HCOLOR, SCALE, SPEED and ROT are treated as keywords only when followed by =.
Graphics
Applesoft II’s graphics vocabulary splits in two:
- Low resolution (40×48 in 16 colours):
GR,COLOR=,PLOT,HLIN,VLIN,SCRN(. - High resolution (280×192):
HGR,HGR2,HCOLOR=,HPLOT ... TO ..., plus shape tables drawn withDRAWandXDRAWand transformed withROT=andSCALE=, loaded from cassette withSHLOAD.
Mixed mode leaves four lines of text at the bottom of the screen. The double-high-resolution mode of later 128K machines and the IIGS’s own graphics modes were never supported directly.
Talking to hardware and machine code
| Mechanism | What it does |
|---|---|
PEEK(addr) / POKE addr, value | Read or write any memory location, including soft switches in the I/O space |
CALL addr | Jump to a machine-language subroutine |
USR(x) | Pass a value to a machine-language routine and get a numeric result back |
& | Jump to location $3F5, where a program can place a vector to its own command parser |
PR#n / IN#n | Redirect output or input to the card in slot n |
WAIT addr, mask | Pause until a memory location’s bits match |
The 1978 manual describes & as “intended for the computer’s internal use only; it is not a proper APPLESOFT command.” It became the most important extension point in the language anyway. Ampersand packages parsed whatever followed the & by calling routines inside the Applesoft ROM, which let them add new statements that looked native.
Disk access was not part of Applesoft at all. Under DOS 3.3, and later under ProDOS’s BASIC.SYSTEM, a program issued disk commands by PRINTing a Ctrl-D followed by text such as OPEN, READ or CATALOG. The operating system watched the output stream and intercepted them.
How the Interpreter Works
Applesoft is a tokenising interpreter, and its internals were documented in unusual detail in Apple’s own manual, which is why so many programmers learned to poke at them.
Tokenisation. When a line is entered, each reserved word is replaced by a one-byte token from 128 (END) to 234 (MID$), and spaces outside strings are discarded. LIST reconstructs the text and adds its own spacing, so 10 C=+5/-6: B=-5 lists as 10 C = + 5 / - 6 : B = - 5. Numeric literals are not converted to binary at entry time; they stay as ASCII digits and are parsed again every time the line runs.
Memory map. In the ROM version a program starts at $801. Zero-page pointers mark the boundaries of each region. $67–$68 holds the start of the program, $69–$6A the start of simple variables (LOMEM:), $6B–$6C the start of arrays, $6D–$6E the end of arrays, $6F–$70 the bottom of string storage and $73–$74 HIMEM:. Strings grow downward from HIMEM: toward the arrays. The manual warns that string space “may fill with old data and run over the high-resolution screens,” and recommends X=FRE(0) to force a clean-up.
Execution. The interpreter’s CHRGET routine, copied into zero page, fetches each character of the running program. Lines are stored as a linked list, so a GOTO or GOSUB searches from the start of the program for its target. Variables sit in a table in the order in which they were first encountered, and each reference searches that table.
Stack use. The manual lists the costs: 16 bytes per active FOR loop, 6 bytes per pending GOSUB, and 4 bytes per parenthesis level plus 12 bytes per temporary result during expression evaluation. FOR loops nested more than 10 deep produce ?OUT OF MEMORY ERROR.
Performance
Apple’s Applesoft II manual includes an appendix titled “Speeding Up Your Program” whose first hint is in capitals: “THIS IS PROBABLY THE MOST IMPORTANT SPEED HINT BY A FACTOR OF 10: use variables instead of constants,” because converting a literal to floating point costs more than fetching a variable. The other hints follow directly from the internals:
- Refer to the most-used variables first, so they sit near the front of the variable table.
- Write
NEXTrather thanNEXT I, which skips a check. - Put frequently called subroutines near the start of the program, because every
GOTOandGOSUBsearches from the lowest line.
The most thorough published measurement is “A Comparison of Five Compilers for Apple BASIC” by Joseph H. Taylor and Jeffrey S. Taylor in BYTE, September 1982. They ran eight benchmark programs on a 48K Apple II or II Plus and used the Applesoft interpreter as the baseline. The interpreter’s own timings:
| Benchmark | What it does | Applesoft interpreter time |
|---|---|---|
| PRIME1 | Primes below 1000 by the Sieve of Eratosthenes | 16.9 s |
| PRIME2 | Primes below 1000, Porter’s algorithm | 28.2 s |
| SIGAV | Signal-averager program | 44.2 s |
| KBAUD7 | Rugg and Feldman’s Kilobaud benchmark 7 | 46.3 s |
| SORT | Sort a list of numbers | 24.8 s |
| ALPHA | Sort a list of words alphabetically | 15.4 s |
| MATINV | Invert a 10×10 matrix | 40.2 s |
| FFT | 64-point complex Fourier transform | 22.6 s |
Across these programs the Taylors found that code from the four Applesoft compilers “generally runs 2 to 10 times faster” than the same programs under the interpreter. Microsoft’s TASC was fastest “by a substantial margin” when its integer option could be used, because it and Hayden’s compiler did 16-bit integer arithmetic where the interpreter did not. On floating-point-heavy programs such as MATINV and FFT the compilers performed more alike. All of them called the interpreter’s own ROM routines for floating-point work and functions like SQR, SIN and LOG. The same article measured Galfo Systems’ Integer BASIC compiler at “15 or more times faster than Applesoft” on programs that Integer BASIC could handle, which shows how much the floating-point default cost when it was not needed.
Evolution
Very little changed in the language after 1978. Because a great deal of commercial software called entry points inside the ROM, Apple kept the interpreter essentially fixed:
| Machine | Date | Effect on Applesoft |
|---|---|---|
| Apple II Plus | 1979 | Applesoft II moves into motherboard ROM, replacing Integer BASIC |
| Apple IIe | January 1983 | Same interpreter; new firmware adds 80-column and arrow-key editing around it |
| ProDOS | 1984 | Disk commands move from DOS 3.3 to BASIC.SYSTEM; the language itself is unchanged |
| Enhanced IIe | March 1985 | Lowercase keyword entry; GET, HTAB, TAB, SPC and comma tabbing fixed for 80 columns |
| Apple IIGS | September 1986 | Applesoft kept in ROM for compatibility |
Improvements came from outside Apple instead: ampersand utilities, program editors, and compilers. The 1982 BYTE review lists four Applesoft compilers, priced from $100 to $175.
Compatibility mattered beyond Apple, too. Coleco said the Adam’s SmartBASIC was source-compatible with Applesoft for programs that did not PEEK or POKE into the hardware, and Microsoft licensed an Applesoft-compatible BASIC to VTech for the Laser 128 clone.
Current Relevance
Applesoft is historical. No current hardware runs it natively, and there is no official container image or supported toolchain. It is still easy to run, though:
- Emulators run the original ROM. AppleWin, an Apple II emulator for Windows, is still maintained; its v1.32.0.0 release is dated May 2026.
- Reimplementations skip the hardware entirely. Joshua Bell’s Applesoft BASIC in JavaScript, developed on GitHub since 2013, runs Applesoft listings in a web browser.
- Source code is now public at the Microsoft end. On 3 September 2025 Microsoft published the source of Microsoft BASIC for 6502 version 1.1 under the MIT License. It is the version Applesoft I was built on, and it includes an Apple II build configuration. Michael Steil’s reconstruction project, msbasic, reassembles Applesoft I byte-for-byte from a single source tree shared with Commodore, OSI and KIM BASIC. Its README notes that it cannot yet build Applesoft II.
- Documentation survives as scans. The November 1977 Applesoft manual, the 1978 Applesoft II reference manual and the TASC manual are all on the Internet Archive.
Why It Matters
- It was the default language of a major personal computer for fourteen years. From 1979 to 1993, every new Apple II dropped to Applesoft when there was no disk to boot. Many people’s first program was written at its
]prompt. - It is a well-documented example of the Microsoft 6502 BASIC family. Applesoft, Commodore BASIC and their siblings shared one code base. With Microsoft’s 2025 source release and the byte-exact reconstructions, Applesoft has become one of the easiest early interpreters to study at the source level.
- Its trade-offs are a lesson in design for 8-bit machines. Two-character names, tokenised storage, ASCII literals re-parsed at run time and linear line searches all saved memory at a measurable cost in speed. The compiler market that grew up around Applesoft existed because of those choices.
- It shows how extension hooks outlive the language’s own development. Apple changed Applesoft very little after 1978, but
&,USR,CALLandPEEK/POKElet third parties keep extending it for as long as the Apple II was sold.
Timeline
Notable Uses & Legacy
Akalabeth: World of Doom
Richard Garriott wrote Akalabeth, the precursor to the Ultima series, mostly in Applesoft BASIC in 1979; California Pacific Computer Company published it for the Apple II in 1980
Scientific benchmarking on the Apple II
Princeton physicist Joseph H. Taylor and his son Jeffrey used Applesoft programs for matrix inversion, a 64-point Fourier transform and string sorting as the reference workload in BYTE's September 1982 comparison of Apple II BASIC compilers
Commercial software shipped as compiled BASIC
Compilers such as TASC, Expediter II and Speed Star let developers distribute an Applesoft program as machine code, which BYTE's 1982 review noted was bought for improved execution speed or security of source code
Ampersand and USR extension packages
Because the interpreter's & statement jumps to a user-settable vector at $3F5, third-party commercial packages added new commands to Applesoft rather than waiting for Apple to change the ROM
Modern browser and emulator execution
Joshua Bell's Applesoft BASIC in JavaScript (on GitHub since 2013) runs listings in a web browser, and emulators such as AppleWin (v1.32.0.0, May 2026) run the original ROM interpreter