• Please review our updated Terms and Rules here

Applesoft BASIC

WMH

Experienced Member
Joined
Dec 26, 2011
Messages
425
Location
Florida
(Copied from Wikipedia; feel free to edit and add to this article, and then remove this notice.)

Applesoft BASIC was a dialect of Microsoft BASIC supplied with the Apple II series of computers. It superseded Integer BASIC and was the BASIC in ROM in all Apple II series computers after the original Apple II model. It was also referred to as FP (from "floating point") because of the command used to invoke it instead of INT for Integer BASIC. Applesoft BASIC was supplied by Microsoft and its name is derived from the names of both Apple and Microsoft. Apple employees, including Randy Wigginton, adapted Microsoft's interpreter for the Apple II and added several features. The first version of Applesoft was released in 1977 only on cassette tape and lacked proper support for high-resolution graphics. Applesoft II, which was made available on cassette and disk and in the ROM of the Apple II Plus and subsequent models, was released in 1978. It is this latter version, which has some syntax differences from the first as well as support for the Apple II high-resolution graphics modes, that most people mean by the term "Applesoft."

Background

Apple's customers were demanding a version of BASIC that supported floating point calculations. As Steve Wozniak, the creator of Integer BASIC and the only person who understood it well enough to add floating point features, was busy with the Disk II drive and controller and with Apple DOS, Apple turned to Microsoft, who was the BASIC vendor of choice after their success with Altair BASIC, and licensed a 10 KB assembly language version of BASIC dubbed "Applesoft." Apple reportedly obtained an eight-year license for Applesoft BASIC from Microsoft for a flat fee of $21,000, renewing it in 1985 through an arrangement that gave Microsoft the rights and source code for Apple's Macintosh version of BASIC.[citation needed]
Applesoft was similar to (and indeed had a common code base with) Microsoft BASIC implementations on other 6502-based computers, such as Commodore BASIC: it used line numbers, and spaces were not necessary in lines. While Applesoft was slower than Integer BASIC, it had many features that the older BASIC lacked:

  • Atomic strings: A string is no longer an array of characters (as in Integer BASIC and C); it is instead a garbage-collected object (as in Scheme and Java). This allows for string arrays; DIM A$(10) resulted in a vector of eleven string variables numbered 0–10.
  • Multidimensional arrays
  • Single-precision floating point variables with an 8-bit exponent and a 31-bit significand and improved math capabilities, including trigonometry and logarithmic functions
  • Commands for high-resolution graphics
  • CHR$, STR$, and VAL functions for converting between string and numeric types (both languages did have the ASC function)
  • User-defined functions: simple one-line functions written in BASIC, with a single parameter
  • Error-trapping, allowing BASIC programs to handle unexpected errors by means of a subroutine written in BASIC

Conversely, Applesoft lacked the MOD (remainder) operator that had been present in Integer BASIC.

Whereas Wozniak originally referred to his Integer BASIC as "Game BASIC," having written it so he could write a Breakout clone for his new computer, few action games were written in Applesoft BASIC for several reasons:

  • In that era of carefully counting clock cycles and limited memory, it was inefficient to write speed-dependent programs that ran on a runtime interpreter.
  • The use of "real" (floating-point) numbers for all math operations created unnecessary overhead and degraded performance. Applesoft converted integer numbers to real before performing operations on them, converting the result back to an integer only if it was to be assigned to a (16-bit signed) integer variable.
  • Shape tables were a slow alternative to bitmaps. No provision existed for mixing text and graphics, except for the limited "hardware split screen" of the Apple II (four lines of text at the bottom of the screen). Many graphics programs thus contained their own bitmap character generator routines. No provision was added in the 128 kB Apple IIe and Apple IIc models' BASIC interpreters for the new machines' extra memory and double-resolution graphics, or for the Apple IIGS's 16-color mode. (Beagle Bros offered machine-language workarounds for these problems.)
  • The program was stored as a linked list of lines; a GOTO or GOSUB took O(n) (linear) time, and although Applesoft programs were not very long compared to today's software, on a 1 MHz 6502 this could be a significant bottleneck. Large programs were often written with the most-used subroutines at the top of the program to reduce the processing time for GOSUB calls.
  • No sound support aside from a PEEK command that could be used to click the speaker, though one could also PRINT an ASCII bell character to sound the system alert beep. The language was not fast enough to produce more than a baritone buzz from repeated clicks anyway. However, music spanning several octaves could be played by repeated calls to a machine-language tone generator.

Sample Code

Hello World in Applesoft BASIC could be entered as the following:

10 TEXT:HOME
20 ?"HELLO WORLD"

Multiple commands could be included on the same line of code if separated by a colon :)). The ? can be used in Applesoft BASIC as a shortcut for "PRINT", though spelling out the word is not only acceptable but canonical—Applesoft converted "?" in entered programs to the same token as "PRINT", thus either would appear as "PRINT" when a program was listed. The program above would be appear in a LIST command as:

10 TEXT : HOME
20 PRINT "HELLO WORLD"
 
Back
Top