Applesoft BASIC - Background

Background

The Apple II was unveiled to the public at the West Coast Consumer Electronics Expo in April 1977 and became available for sale in June. As Apple began to get buyer feedback, one of the most common complaints about the computer was BASIC's lack of floating-point capability. Steve Wozniak had not bothered to implement it because he'd primarily been interested in writing games, a task for which integers alone were sufficient. This meant that Integer BASIC was limited to whole numbers between -32767 and 32768 and caused problems for users attempting to write business applications on it. 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.

In 1976, Microsoft had developed a BASIC interpreter for the newly-released 6502 microprocessor, but as there was not yet any production computer that used it, the program merely sat on the shelf. Upon learning that Apple had a 6502 machine, they called on the phone and asked if there was any interest in purchasing BASIC. However, Steve Jobs merely told them "We appreciate the offer, but sorry we already have a BASIC."

Now in need of an upgrade, Apple contacted Microsoft and asked for help. They 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. Applesoft was designed to be backwards-compatible with Integer BASIC and used the core of Microsoft's 6502 BASIC implementation, which included using the GET function for detecting key presses and not requiring any spaces on program 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. A common feature of all Microsoft 6502 BASICs was the lack of double-precision variables or true integers. BASIC normally always worked in single-precision and although a % could be placed in front of variables to mark them as integer, they would merely be converted back into single-precision, slowing down program execution and wasting memory as each % required one extra byte to store. The integer variable type on Microsoft 6502 BASIC was really only designed for arrays because each element would take two bytes (versus four on single-precision).
  • 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 II'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.

Read more about this topic:  Applesoft BASIC

Famous quotes containing the word background:

    Silence is the universal refuge, the sequel to all dull discourses and all foolish acts, a balm to our every chagrin, as welcome after satiety as after disappointment; that background which the painter may not daub, be he master or bungler, and which, however awkward a figure we may have made in the foreground, remains ever our inviolable asylum, where no indignity can assail, no personality can disturb us.
    Henry David Thoreau (1817–1862)

    ... every experience in life enriches one’s background and should teach valuable lessons.
    Mary Barnett Gilson (1877–?)

    In the true sense one’s native land, with its background of tradition, early impressions, reminiscences and other things dear to one, is not enough to make sensitive human beings feel at home.
    Emma Goldman (1869–1940)