BASIC interpreter
A BASIC interpreter is an
BASIC interpreters are of historical importance. Microsoft's first product for sale was a BASIC interpreter (Altair BASIC), which paved the way for the company's success. Before Altair BASIC, microcomputers were sold as kits that needed to be programmed in machine code (for instance, the Apple I). During the Altair period, BASIC interpreters were sold separately, becoming the first software sold to individuals rather than to organizations; Apple BASIC was Apple's first software product. After the MITS Altair 8800, microcomputers were expected to ship bundled with BASIC interpreters of their own (e.g., the Apple II, which had multiple implementations of BASIC). A backlash against the price of Microsoft's Altair BASIC also led to early collaborative software development, for Tiny BASIC implementations in general and Palo Alto Tiny BASIC specifically.
BASIC interpreters fell from use as computers grew in power and their associated programs grew too long for typing them in to be a reasonable distribution format. Software increasingly came pre-compiled and transmitted on
History
BASIC helped jumpstart the time-sharing era, became mainstream in the microcomputer era, then faded to become just another application in the DOS and GUI era, and today survives in a few niches related to game development, retrocomputing, and teaching.
Time-sharing era
First implemented as a compile-and-go system rather than an interpreter, BASIC emerged as part of a wider movement towards time-sharing systems. General Electric, having worked on the Dartmouth Time Sharing System and its associated Dartmouth BASIC, wrote their own underlying operating system and launched an online time-sharing system known as Mark I featuring a BASIC compiler (not an interpreter) as one of its primary selling points. Other companies in the emerging field quickly followed suit. By the early 1970s, BASIC was largely universal on general-purpose mainframe computers.[1]
BASIC, as a streamlined language designed with integrated line editing in mind, was naturally suited to porting to the
One holdout was
Microcomputer era
The introduction of the first microcomputers in the mid-1970s continued the explosive growth of BASIC, which had the advantage that it was fairly well known to the young designers and computer hobbyists who took an interest in microcomputers, many of whom had seen BASIC on minis or mainframes. BASIC was one of the few languages that was both high-level enough to be usable by those without training and small enough to fit into the microcomputers of the day. In 1972, HP introduced the HP 9830A programmable desktop calculator with a BASIC Plus interpreter in read-only memory (ROM).[5]
In June 1974, Alfred Weaver, Michael Tindall, and Ronald Danielson of the
In March 1975,
Other members of the Homebrew Computer Club began circulating copies of Altair BASIC on paper tape, causing Gates to write his
Many firms developed BASIC interpreters. In 1976,
Microsoft ported its interpreter to the
Many vendors did "argue with that" and used other firms or wrote their own interpreters. In September 1978,
In 1978, David Lien published the first edition of The BASIC Handbook: An Encyclopedia of the BASIC Computer Language, documenting keywords across over 78 different computers. By 1981, the second edition documented keywords from over 250 different computers, showcasing the explosive growth of the microcomputer era.[23]
Interpreters as applications
With the rise of disk operating systems and later graphical user interfaces, BASIC interpreters became just one application among many, rather than providing the first prompt a user might see when turning on a computer.
In 1983, the TRS-80 Model 100 portable computer debuted, with its Microsoft BASIC implementation noteworthy for two reasons. First, programs were edited using the simple text editor, TEXT, rather than typed in line by line (but line numbers were still required).[24] Second, this was the last Microsoft product that Bill Gates developed personally.[25][26]
Also in 1983, Microsoft began bundling
BASIC interpreters were not just an American/British development. In 1984,
In May 1991, Microsoft released
Niche BASICs
In 1993, Microsoft released Visual Basic for Applications, a scripting language for Microsoft Office applications, which supersedes and expands on the abilities of earlier application-specific macro programming languages such as Word's WordBASIC (which had been introduced in 1989).
In 1996, Microsoft released
In 1999, Benoît Minisini released Gambas as an alternative for Visual Basic developers who had decided to migrate to Linux.[36]
In 2000, Lee Bamber and Richard Vanner released
In 2001, SmallBASIC was released for the Palm PDA.[38] Another BASIC interpreter for Palm was HotPaw BASIC, an offshoot of Chipmunk Basic.
In 2002, Emmanuel Chailloux, Pascal Manoury and Bruno Pagano published a Tiny BASIC as an example of developing applications with
In 2011, Microsoft released
In 2014, Robin H. Edwards released Arduino BASIC for the Arduino, and now a widely forked implementation.[47] Another implementation using the same name was adapted from Palo Alto Tiny BASIC in 1984 by Gordon Brandly for his 68000 Tiny BASIC, later ported to C by Mike Field.[48]
Many BASIC interpreters are now available for
Today, coding BASIC interpreters has become part of the
Sales and distribution
Initially, interpreters were either bundled with computer hardware or developed as a custom service, before an industry producing independently packaged software for organizations came about in the late 1960s.[50] BASIC interpreters were first sold separately from microcomputers, then built-in, before becoming sold as applications again in the DOS era.
Year | Media | Example |
---|---|---|
1975 | Paper tape | Altair BASIC |
1975 | Type-in program | Tiny BASIC Extended |
1976 | Cassette tape | Apple I BASIC |
1977 | Floppy ROM | MICRO BASIC |
1977 | ROM | Integer BASIC |
1983 | Floppy disk | GW-BASIC |
1995 | CD-ROM | Visual Basic 4.0 |
2008 | App store | Various |
As the market shifted to ROMs, ROM size came to dominate decisions about how large a BASIC interpreter could be. Because RAM were sold as 4 KB chips, Altair BASIC was initially packaged in separate editions for 4K, 8K, and 12K; this carried over to ROM chips, as manufacturers would decide how many ROM chips they could fit in their design, given price goals and other constraints.
Compilers vs. interpreters
Aspect | Compiler | Interpreter |
---|---|---|
Optimized for | Performance | Memory usage |
Execution speed | Faster | Slower |
Memory usage | Higher | Lower |
Secondary storage | Required | Optional |
Error checking | Before execution | During execution |
Source code | Not embedded in executable | Required to execute |
The first implementation of BASIC,
The main disadvantage of compilers, at least in the historical context, is that they require large amounts of temporary memory. As the compiler works, it is producing an ever-growing output file that is being held in memory along with the original source code. Additional memory for temporary lookups, notably line numbers in the case of BASIC, adds to the memory requirement. Computers of the era had very small amounts of memory; in modern terms a typical
In order to make a compiler work, the systems had to have some form of high-performance
While mainframes had small amounts of memory, minicomputers had even smaller amounts: 4 and 8 KB systems were typical in the 1960s. But far more importantly, minicomputers tended to lack any form of high-performance storage; most early designs used
Interpreters ultimately perform the same basic tasks as compilers, reading the source code and converting that into executable instructions calling runtime functions. The primary difference is when they perform the various tasks. In the case of a compiler, the entire source code is converted during what appears to the user as a single operation, whereas an interpreter converts and runs the source one statement at a time. The resulting machine code is executed, rather than output, and then that code is then discarded and the process repeats with the next statement. This dispenses with the need for some form of secondary storage while an executable is being built. The primary disadvantage is that you can no longer split the different parts of the overall process apart - the code needed to convert the source into machine operations has to be loaded into memory along with the runtime needed to perform it, and in most cases, the source code editor as well.
Producing a language with all of these components that can fit into a small amount of memory and still has room for user's source code is a major challenge, but it eliminates the need for secondary storage and was the only practical solution for early minicomputers and most of the history of the home computer revolution.
Development
Language design
Language design for the first interpreters often simply involved referencing other implementations. For instance, Wozniak's references for BASIC were an HP BASIC manual and a copy of
In contrast, Dennis Allison, a member of the Computer Science faculty at Stanford University, wrote a specification for a simple version of the language.[54] Allison was urged to create the standard by Bob Albrecht of the Homebrew Computer Club, who had seen BASIC on minicomputers and felt it would be the perfect match for new machines like the Altair. Allison's proposed design only used integer arithmetic and did not support arrays or string manipulation. The goal was for the program to fit in 2 to 3 kilobytes of memory. The overall design for Tiny BASIC was published in the September 1975 issue of the People's Computer Company (PCC) newsletter.
The grammar is listed below in Backus–Naur form.[55] In the listing, an asterisk ("*
") denotes zero or more of the object to its left — except for the first asterisk in the definition of "term
", which is the multiplication operator; parentheses group objects; and an epsilon ("ε
") signifies the empty set. As is common in computer language grammar notation, the vertical bar ("|
") distinguishes alternatives, as does being listed on separate lines. The symbol "CR
" denotes a carriage return.
line ::= number statement CR | statement CR
statement ::= PRINT expr-list
IF expression relop expression THEN statement
GOTO expression
INPUT var-list
LET var = expression
GOSUB expression
RETURN
CLEAR
LIST
RUN
END
expr-list ::= (string|expression) (, (string|expression) )*
var-list ::= var (, var)*
expression ::= (+|-|ε) term ((+|-) term)*
term ::= factor ((*|/) factor)*
factor ::= var | number | (expression)
var ::= A | B | C ... | Y | Z
number ::= digit digit*
digit ::= 0 | 1 | 2 | 3 | ... | 8 | 9
relop ::= < (>|=|ε) | > (<|=|ε) | =
This syntax, as simple as it was, added one innovation: GOTO
and GOSUB
could take an expression rather than a line number, providing an assigned GOTO[56] rather than the switch statement of the ON-GOTO/GOSUB
structure more typical of BASIC.
Sinclair BASIC used as its language definition the 1978 American National Standards Institute (ANSI) Minimal BASIC standard, but was itself an incomplete implementation with integer arithmetic only.[57] The ANSI standard was published after the design of the first generation of interpreters for microcomputers.
Architecture
Common components of a BASIC interpreter:[58]
- I/O and interrupt handling
- Keyboard and screen
- File input/output (if any)
- Editing routines
- Command line
- Program editing and storage
- Execution routines
- Parsing and interpretation
- Arithmetic package
- Memory management
- Symbol table (if any)
- Garbage collection (if any)
Coding
Early microcomputers lacked development tools, and programmers either developed their code on minicomputers or by hand. For instance, Dick Whipple and John Arnold wrote Tiny BASIC Extended directly in machine code, using
Gates and Allen did not have an Altair system on which to develop and test their interpreter. However, Allen had written an
Not that Allen couldn't handcode in machine language. While on final approach into the Albuquerque airport on a trip to demonstrate the interpreter, Allen realized he had forgotten to write a
One of the most popular of the many versions of Tiny BASIC was Palo Alto Tiny BASIC, or PATB for short. PATB first appeared in the May 1976 edition of Dr. Dobbs, written in a custom
One exception to the use of assembly was the use of
The source code of interpreters was often open source (as with Tiny BASIC) or published later by the authors. The complete annotated source code and design specifications of Atari BASIC were published as The Atari BASIC Source Book in 1983.[69]
Virtual machines
Some BASIC interpreters were coded in the
Dialect of BASIC | Virtual Machine Language | Native Machine |
---|---|---|
Tiny BASIC | Tiny BASIC Intermediate Language (TBIL) | 6800 |
NIBL | Intermediate Language (IL) | SC/MP
|
TI BASIC |
Graphics Programming Language (GPL) | TMS9900
|
While virtual machines had been used in compile and go systems such as BASIC-PLUS, these were only for executing BASIC code, not parsing it.[70] Tiny BASIC, in contrast, was designed to be implemented as a virtual machine that parsed and executed (interpreted) BASIC statements; in such an implementation, the Tiny BASIC interpreter is itself run on a virtual machine interpreter.[71] The length of the whole interpreter program was only 120 virtual machine operations, consisting of 32 commands.[72] Thus the choice of a virtual machine approach economized on memory space and implementation effort, although the BASIC programs run thereon were executed somewhat slowly. (See Tiny BASIC: Implementation in a virtual machine for an excerpt and sample commands.) While the design intent was for Tiny BASIC to use a virtual machine, not every implementation did so; those that did included Tiny BASIC Extended, 6800 Tiny BASIC,[73] and NIBL.
For its TI-99/4 and TI-99/4A computers, Texas Instruments designed a virtual machine with a language called GPL, for "Graphic Programming Language".[74] (Although widely blamed for the slow performance of TI-BASIC, part of the problem was that the virtual machine was stored in graphics ROM, which had a slow 8-bit interface.)[75]
A misunderstanding of the Apple II ROMs led some to believe that Integer BASIC used a virtual machine, a custom
Program editing and storage
Program editing
Most BASIC implementations of the era acted as both the language interpreter as well as the
Statements that were entered with leading numbers are entered into the program storage for "deferred execution",[79] either as new lines or replacing any that might have had the same number previously.[80] Statements that were entered without a line number were referred to as commands, and ran immediately. Line numbers without statements (i.e., followed by a carriage return) deleted a previously stored line.
When a program was present in memory and the user types in the RUN
command, the system enters "indirect mode". In this mode, a pointer is set to point to the first line of the program, for instance, line 10. The original text for that line is then retrieved from the store and run as if the user had just typed it in direct mode. The pointer then advances to the next line and the process continues.
Different implementations offered other program-editing capabilities. Altair BASIC 8K had an EDIT
command to shift into an editing mode for one line. Integer BASIC, also included the AUTO
command to automatically enter line numbers at a given starting number like AUTO 100
, adding 10 to the last number with every new line. AUTO 300,5
would begin numbering at line 300 by fives; 300, 305, etc. Automatic numbering was turned off by entering MAN
.[81] Some interpreters offered line-renumbering commands or utilities.
Tokenizing and encoding lines
To save RAM, and speed execution, all BASIC interpreters would encode some ASCII characters of lines into other representations. For instance, line numbers were converted into integers stored as bytes or words, and keywords might be assigned single-byte tokens (for instance, storing PRINT
as the byte value 145, in MS-BASIC). These representations would then be converted back to readable text when LIST
ing the program.
Dialect of BASIC | Line Numbers | Keywords | Numeric Constants | Variable Names |
---|---|---|---|---|
Tiny BASIC | Yes | No | No | No |
Altair BASIC | Yes | Yes | No | No |
Integer BASIC | Yes | Yes | Yes | No |
Atari BASIC | Yes | Yes | Yes | Yes |
Abbreviations
As an alternative to tokenization, to save RAM, early Tiny BASIC implementations like Extended Tiny BASIC,[82] Denver Tiny BASIC[83] and MINOL[84] truncated keywords: PR
for PRINT
, IN
for INPUT
, RET
for RETURN
. The full, traditional keywords were not accepted.
In contrast, Palo Alto Tiny BASIC accepted traditional keywords but allowed any keyword to be abbreviated to its minimal unique string, with a trailing period. For instance, PRINT
could be typed P.
, although PR.
and other variations also worked. This system was retained in Level I BASIC for the TRS-80, which used PATB, and was also found in Atari BASIC and the BASIC of various Sharp Pocket Computers.[85]
To expand an abbreviation, the Atari BASIC tokenizer searches through its list of reserved words to find the first that matches the portion supplied. More commonly used commands occur first in the list of reserved words, with REM
at the beginning (it can be typed as .
). When the program is later LIST
ed it will typically write out the full words. MS BASICs also allowed ?
as a short-form for PRINT
, but did expand it when listing, treating it as an abbreviation, not a synonym.
Tokenization
Most BASIC interpreters perform at least some conversion from the original text form into various platform-specific formats. Tiny BASIC was on the simple end: it only converted the line number from its decimal format into binary. For instance, the line number "100" became a single byte value, $64, making it smaller to store in memory as well as easier to look up in machine code (a few designs of Tiny BASIC permitted line numbers from only 1 to 254 or 255, although most used double byte values and line numbers of at least 1 to 999). The rest of the line was left in its original text format.[86] In fact, Dennis Allison argued that, given memory constraints, tokenization would take more code to implement than it would save.[87]
MS-BASICs went slightly further, converting the line number into a two-byte value and also converting keywords, like FOR
or PRINT
, into a single-byte value, the "token".[88] The token value had the high bit set to allow them to be easily distinguished at runtime. Everything else on a line was left in its original format, so for instance, the line:
10 FOR I=1 TO 10
would be tokenized as:
$64$81 I$B211$A410
Note that the space between FOR
and I
remains in the tokenized line, and the variable names and constants are not tokenized. The code that performed this tokenization, known as "the chunker", simply copied anything it did not recognize as a token back into the output, preserving spaces as-is. This meant that PRINTA
was stored in two bytes, while PRINT A
was stored in three bytes, and removing spaces was a common way to improve memory use.[89] Sinclair BASIC modified this slightly, removing spaces from the stored code and inserting them in code during a LIST
, such that PRINTA
would appear as PRINT A
yet not take up the extra byte in memory.
In contrast, Integer BASIC would convert the line 10 GOTO 100
entirely into tokens that could be immediately read and performed. In MS-BASIC, the line would produce $64 $89 100
, and at runtime the "100" would have to be converted to 16-bit format every time it was encountered. In contrast, Integer BASIC also tokenized numeric variables, avoiding this conversion and speeding up execution. The resulting two byte value was inserted into the tokenized code along with a prefix byte indicating a number followed. The prefix was a value between $B0 and $B9, the last nibble of the value being the first decimal digit in the original value. String literals, like "HELLO WORLD" were instead encoded by setting the high bit of each character so that A
was stored as $C1. Variable names were converted in the same fashion, with the letters encoded to have their high-bit turned on, and any digits in the name represented by the corresponding $B0 through $B9, so that the variable A5
would be encoded as $C1B5 (not reduced to a token).[90] There were numerous other optimizations; where Microsoft BASIC had one token for the keyword PRINT
, Integer BASIC had three tokens: one if the keyword was followed by no arguments, one if followed by an arithmetic expression, and one if followed by a string literal.[91]
Carrying this even further, Atari BASIC's tokenizer parses the entire line when it is entered or modified. Numeric constants are parsed into their 48-bit internal form and then placed in the line in that format, while strings are left in their original format, but prefixed with a byte describing their length. Variables have storage set aside as they are encountered, instead of at runtime, and their name is replaced with a pointer to their storage location in memory. Shepardson referred to this early-tokenizing concept as a "pre-compiling interpreter"; statements with syntax errors could not actually be stored, and the user was immediately prompted to correct them.[92]
Tokenization at the keyboard
Some interpreters, such as the Sinclair systems, basically had the user do the tokenization by providing special keystrokes to enter reserved words. The most common commands need one keystroke only; for example, pressing only P at the start of a line on a Spectrum produces the full command PRINT
. Less frequent commands require more complex key sequences.[93] As every line starts with a keyword, LET
is not optional, after a keyword is typed the system drops back to accepting text character-by-character. One upside to this approach is that the tokenizer cannot confuse strings with keywords. For instance, it allows a variable to be named PRINT
and output its value with PRINT PRINT
.
Many "pocket computers" similarly use one keystroke (sometimes preceded by various kinds of shift keys) to produce one byte (the keyword token) that represented an entire BASIC keyword, such as EXP, SQR, IF, or PEEK, such as Sharp pocket computer character sets and TI-BASIC. The BASIC expansion for the Bally Astrocade use this as well.
Line management
Range | Dialect |
---|---|
1 to 254 | MINOL |
1 to 255 | Tiny BASIC Design Note |
2 to 255 | Denver Tiny BASIC |
0 to 999 | UIUC BASIC |
1 to 2045 | DEC BASIC-8 |
0 to 32767 | LLL BASIC, NIBL |
1 to 32767 | Palo Alto Tiny BASIC
|
1 to 65535 | Altair 4K BASIC, MICRO BASIC 1.3, 6800 Tiny BASIC, Tiny BASIC Extended |
1 to 99999 | Dartmouth BASIC |
1 to 999999 | SCELBAL |
Valid line numbers varied from implementation to implementation, but were typically from 1 to 32767.
Most of the memory used by BASIC interpreters was to store the program listing itself. Numbered statements were stored in sequential order in a sparse array implemented as a linear collection (technically not a list as no line number could occur more than once).
Many Tiny BASIC implementations stored lines as follows:
- Binary equivalent of line number (one or two bytes, depending on range of valid line numbers supported)
- ASCII source statement (variable length)
- Carriage return (one byte, set to 13)
Microsoft BASIC, starting with Altair BASIC, stored lines as follows:[94]
- Pointer to the next line (two bytes)
- Binary equivalent of line number (two bytes, unsigned)
- Tokenized source statement (variable length)
- Null (one byte, set to 0)
LLL BASIC:[95]
- Binary equivalent of line number (two bytes)
- Forward pointer to next sequential line (two bytes)
- Length of ASCII source statement (one byte)
- ASCII source statement (variable length)
The maximum length of a line varied: 64 characters in Palo Alto Tiny BASIC, including the decimal representation of the line number; 120 characters in Atari BASIC; 128 characters in Integer BASIC;[96] and 255 characters in MS-BASIC (not including the line number).
Interpreters would search the program a line at a time, looking at each line number. If it were lower than the new line number, the later lines would be moved in memory to make room for the space required for the new line. If it were the same line number, and not the exact same length, subsequent lines would need to be moved forward or backward.[97] (Because sequential order was always maintained in memory, these were not linked lists.)
In Tiny BASIC, these searches required checking every byte in a line: the pointer would be incremented again and again until a carriage return was encountered, to find the byte before the next line. In Altair BASIC and LLL BASIC, on the other hand, the pointer would instead be set to the start of the next sequential line; this was much faster, but required two bytes per line. Given that Tiny BASIC programs were presumed to be 4 KB or less in size, this was in keeping with Tiny BASIC's general design philosophy of trading off performance in favor of minimizing memory usage.
When the user typed LIST
into the command line, the system would loop over the array of lines, using one of these methods, convert the line number back to decimal format, and then print out the rest of the text in the line, decoding any tokens or other encoded representations.
As developers added
Variables and data types
Variable names
Dartmouth BASIC and HP-BASIC limited variable names to at most two characters (either a single letter or a letter followed by one digit; e.g., A to Z9). MS-BASIC allowed variable names of a letter followed by an optional letter or digit (e.g., A to ZZ) but ignored subsequent characters: thus it was possible to inadvertently write a program with variables "LOSS" and "LOAN", which would be treated as being the same; assigning a value to "LOAN" would silently overwrite the value intended as "LOSS".
Integer BASIC was unusual in supporting any length variable name (e.g., SUM, GAMEPOINTS, PLAYER2), provided it did not contain a reserved word.[98] Keywords could not be used in variables in many early BASICs; "SCORE" would be interpreted as "SC" OR "E", where OR was a keyword.
With the exception of arrays and (in some implementations) strings, and unlike Pascal and other more structured programming languages, BASIC does not require a variable to be declared before it is referenced. Values will typically default to 0 (of the appropriate precision) or the null string.
Symbol table
Because Tiny BASIC only used 26 single-letter variables, variables could be stored as an array without storing their corresponding names, using a formula based on the ASCII value of the letter as the index. Palo Alto Tiny BASIC took this a step further: variables 'two-byte values were located in RAM within the program, from bytes 130 (ASCII 65, 'A', times two) to 181 (ASCII 90, 'Z', times two, plus one for the second byte).[85]
Most BASICs provided for the ability to have far more than 26 variables and so needed
In LLL BASIC, each entry in the symbol table was stored as follows:[99]
- Variable name (byte 1: ASCII letter; byte 2: 0-9 ASCII or binary 0)
- Forward pointer (2 bytes)
- Value (4 bytes per element, 1 element if a scalar variable, otherwise as many elements as DIMensioned for an array)
Unlike most BASIC interpreters, UIUC BASIC had a
- Flag (bit 0: entry in use; bit 6: user-defined function; bit 7: array}
- Variable name (byte 1: ASCII letter; byte: 0-9 ASCII, " ", or "(") or function name (byte 1: ASCII letter or token 154 for
FN
; ASCII letter) - Value (5 bytes):
- Floating-point value for a scalar
- Array definition (last 3 bytes: upper dimension of first, second, third dimension, all assumed to start at 0)
- User function (first 2 bytes with the address of the function; byte 3 is symbol table displacement to the dummy variable parameter in function definition).
In Atari BASIC, a set of pointers (addresses) indicated various data: variable names were stored in the variable name table (VNTP – 82, 8316) and their values were stored in the variable value table (pointed to at VVTP – 86, 8716). By indirecting the variable names in this way, a reference to a variable needed only one byte to address its entry into the appropriate table. String variables had their own area.
One BBC BASIC performance optimization included using multiple linked lists for variable lookup rather than a single long list, as in Microsoft BASIC.
Memory management
Because of the small RAM capacity of most systems originally used to run BASIC interpreters, clever memory management techniques had to be employed. Altair BASIC let users reclaim the space for trigonometry functions if those weren't being used during a session. PATB placed the start of the most common subroutines at the front of the program for use by the 1-byte RST
8080 opcode instead of the 3-byte CALL
opcode. In LLL BASIC, some variables occupied the same memory locations, in cases where the different variables were used only in command mode or only at runtime.[100]
Video was often memory addressable, and certain esoteric functions were available by manipulating values at specific memory values. For instance, addresses 32 to 35 contained the dimensions of the text window (as opposed to the graphics window) in Applesoft BASIC. The POKE
command and the PEEK
function (adapted from
Some implementations of the Microsoft interpreter, for example those running on the TRS-80 Models I/III, required the user to specify the amount of memory to be used by the interpreter. This was to permit a region of memory to be reserved for the installation of machine language subroutines that could be called by the interpreted program, for greater speed of execution. When the Models I/III are powered up, the user is greeted with the prompt "Memory size?" for this purpose.
Mathematics
Integer BASIC, as its name implies, uses integers as the basis for its math package. These were stored internally as a 16-bit number, little-endian (as is the 6502). This allowed a maximum value for any calculation between −32767 and 32767. Calculations that resulted in values outside that range produced an error.[103]
Most Tiny BASIC interpreters (as well as Sinclair BASIC 4K) supported mathematics using integers only, lacking
Other computer number formats were sometimes used. For instance, the MINOL Tiny BASIC supported only unsigned bytes,[84] and the MICRO-BASIC Tiny BASIC used Binary Coded Decimal.[104] But floating point would come to predominate.
Floating point
One story encapsulates why floating point was considered so important. The original prototype of the TRS-80 Model I ran
SCELBAL used
Consultants were typically brought into handle
In contrast, time-shared systems had often relied on hardware. For instance, the GE-235 was chosen for implementing the first version of Dartmouth BASIC specifically because it featured an "Auxiliary Arithmetic Unit" for floating point and double-precision calculations.[112][113]
Early interpreters used 32-bit formats, similar to the IEEE 754 single-precision binary floating-point format, which specifies:
- Sign bit: 1 bit
- Exponentwidth: 8 bits
- precision: 24 bits (23 explicitly stored)
Here is the value 0.15625 as stored in this format:
While 32-bit formats were common in this era, later versions of BASIC, starting with
Operators and functions
Infix operators typically included +
(addition), -
(subtraction), *
(multiplication), /
(division), and exponent using the ^
character. Relative operations included the standard set of =
, >
, <
, >=
, <=
, and for "not equal" either <>
or the HP-TSB-inspired #
.[115] Binary operators, such as AND
, OR
and NOT
, weren't in every implementation, and some did Boolean algebra and some did not.
Dartmouth BASIC's initial edition included the following functions: ABS
(
DEF FN
statement to declare one-line functions, which would then be referred to as FNA()
, FNB()
, etc.
The RND
function was the most widespread function to be supported in early BASICs, though implementations varied:
- Dartmouth's
RND
ignored the parameter and always returned a new pseudorandom number between 0 and 1. - Altair BASIC and later Microsoft BASICs used the sign of the parameter: For RND(X), "X<0 starts a new sequence of random numbers using X. Calling RND with the same X starts the same random number sequence. X=0 gives the last random number generated."[116]
- Being unable to return a decimal, integer-only BASICs instead used the value of the parameter, typically to specify an upper bound for the randomization; for example, in Integer BASIC itself,
RND(6)+1
would simulate a die roll, returning values from 1 to 6. - In contrast, in some TRS-80 BASICs, the parameter was the upper bound that could be returned; for instance,
RND(6)
would return a value from 1 to 6, andRND(1)
would always return 1.[117]
Arrays
The second version of Dartmouth BASIC supported matrices and matrix operations, useful for the solution of sets of simultaneous linear algebraic equations; MAT
matrix operations such as assignment, addition, multiplication (of compatible matrix types) and evaluation of a determinant were supported.
In contrast, Tiny BASIC as initially designed didn't even have any arrays, due to the limited
A()
.
SCELBAL supported multiple arrays, but taken together these arrays could have no more than 64 items. Integer BASIC supported arrays of a single dimension, limited in size only by the available memory.[118] Tiny BASIC Extended supported two-dimensional arrays of up to 255 by 255. Altair BASIC 4K supported only arrays (one dimension) while the 8K version supported matrices of up to 34 dimensions.[119]
Many implementations supported the Dartmouth BASIC practice of not requiring an array to be dimensioned, in which case it was assumed to have 11 elements (0 to 10); e.g., {{{1}}}
would create the 11-element array as a side effect.
The dope vector of arrays varied from implementation to implementation. For instance, the dope vector of an Altair BASIC 4K array:[94]
- Variable name (2 bytes)
- Size of the array elements in bytes (2 bytes, so 4 times the number of elements, which was the upper bound plus one)
Then the array values themselves:
- Element 0 value (4 bytes)
- Element 1 value (4 bytes)
- ...
- Element N value (4 bytes)
Implementations that supported matrices had to record the number of dimensions and the upper bound of each dimension. Further, as some interpreters had only one data type (either floating point or integer), the dope vector merely needed to record the number of dimensions and the upper bound of each dimension. Interpreters with multiple data types had to record the data type of the array.
Even though Microsoft and other BASICs did support matrices, matrix operations were not built in but had to be programmed explicitly on array elements.
Strings
The original Dartmouth BASIC, some of its immediate descendants, and Tiny BASIC implementations lacked string handling. Two competing schools of string-handling evolved, pioneered by HP and DEC, although other approaches came later. These required different strategies for implementation.
Dialect of BASIC | Type | Substrings |
---|---|---|
HP Time-Shared BASIC | Fixed length | Slicing |
DEC BASIC-PLUS | Variable length | Functions |
Dartmouth BASIC Fourth Edition | Variable length | Array indexing |
Tiny BASIC | Integer array | Array indexing |
The simplest string handling copied HP Time-Shared BASIC and defined string variables as arrays of characters that had to be DIM
ensioned prior to use. Strings in HP TSB are treated as an array of characters, up to 72 in total, rather than a single multi-character object. By default, they are allocated one character in memory, and if a string of longer length is needed, they have to be declared. For instance, DIM A$[10]
will set up a string that can hold a maximum of 10 characters.[120]
Substrings within strings are accessed using a "slicing" notation: A$(L,R)
or A$[L,R]
, where the substring begins with the leftmost character specified by the index L and continues to the rightmost character specified by the index R, or the A$[L]
form where the substring starts at the leftmost character specified by the index L and continues to the end of the string. TSB accepts () or [] interchangeably. Array and substring indices start with 1.
This is in sharp contrast to BASICs following the DEC pattern that use functions such as LEFT$()
, MID$()
, and RIGHT$()
to access substrings. Later adopted by ANSI BASIC, HP's notation can also be used on the destination side of a LET
or INPUT
statement to modify part of an existing string value, for example 100 A$[3,5]="XYZ"
or 120 B$[3]="CHANGE ALL BUT FIRST TWO CHARS"
, which cannot be done with early implementations of LEFT$/MID$/RIGHT$
.
Later versions of Dartmouth BASIC did include string variables. However, they did not use the LEFT$/MID$/RIGHT$
functions for manipulating strings, but instead used the CHANGE
command which converted the string to and from equivalent ASCII values. (Later adopted as is by DEC and adapted by HP, which changed the keyword to CONVERT
.[120]) Additionally, one could use the single-quote to convert a numeric constant to an ASCII character, allowing one to build up a string in parts; A$='23 '64 '49 "DEF"
produced the string "ABCDEF", without the need for the CHR$()
function.[120] Dartmouth BASIC Sixth Edition supported SEG$
(for MID$
) and POS
(for INSTR
).
Integer BASIC, North Star BASIC[121] and Atari BASIC[122] mimicked HP's approach, which again contrasted with the style found in BASICs derived from DEC, including Microsoft BASIC, where strings are an intrinsic variable-length type.[123]
Some of the
KP
and TV
for this purpose).
Garbage collection
Having strings use a fixed amount of memory regardless of the number of characters used within them, up to a maximum of 255 characters, may have wasted memory[124] but had the advantage of avoiding the need for implementing garbage collection of the heap, a form of automatic memory management used to reclaim memory occupied by strings that are no longer in use. Short strings that were released might be stored in the middle of other strings, preventing that memory from being used when a longer string was needed.
On early microcomputers, with their limited memory and slow processors, BASIC garbage collection could often cause apparently random, inexplicable pauses in the midst of program operation. Some BASIC interpreters, such as Applesoft BASIC on the Apple II family, repeatedly scanned the string descriptors for the string having the highest address in order to compact it toward high memory, resulting in O(n2) performance, which could introduce minutes-long pauses in the execution of string-intensive programs. Garbage collection was notoriously slow or even broken in other versions of Microsoft BASIC.[125] Some operating systems that supported interrupt-driven background tasks, such as TRSDOS/LS-DOS 6.x on the TRS-80 Model 4, exploited periods of user inactivity (such as the milliseconds-long periods between keystrokes and periods following video screen refresh) to process garbage collection during BASIC program runs.
Other functionality
Graphics and sound
Most BASIC interpreters differed widely in graphics and sound, which varied dramatically from microcomputer to microcomputer. Altair BASIC lacked any graphics or sound commands, as did the Tiny BASIC implementations, while Integer BASIC provided a rich set.
In contrast, Integer BASIC supported color graphics, simple sound, and game controllers. Graphics mode was turned on with the GR
statement and off with TEXT
.[127] Drawing was modal and normally started by issuing a command to change the color, which was accomplished by setting a pseudo-variable; COLOR=12
would set the drawing color to 12, light green. One could then PLOT 10,10
to produce a single spot of that color,[128] HLIN 0,39 AT 20
to draw a horizontal line at row 20 that spanned the screen, or VLIN 5,15 AT 7
to draw a shorter vertical line down column 7.[129] A=SCRN X,Y
returned the color of the screen at X,Y.[130][b]
PRINT CHR$();
.
Microsoft added many graphics commands to IBM BASIC: LINE
, PSET
(Pixel SET), PRESET
(Pixel RESET), GET
(stores a rectangle of the screen to an array), PUT
(displays a stored rectangular segment), LOCATE
(to move the text cursor), and DRAW
, which sketches shapes using a LOGO-like syntax. Bill Gates and Neil Konzen wrote DONKEY.BAS, a bundled game, to demonstrate the interpreter's color graphics and sound.[131]
Input/output
Another area where implementations diverged was in keywords for dealing with media (cassettes and floppy disks), keyboard input, and game controllers (if any).
Since ROM-based BASIC interpreters often functioned as
Palo Alto Tiny BASIC lacked strings but would allow users to enter mathematical expressions as the answer to INPUT
statements; by setting variables, such as Y=1; N=0
, the user could answer “Y” or “1” or even "3*2-5" at a yes/no prompt.
Some systems supported game controllers. Astro BASIC supported JX()
(specified joystick's horizontal position), JY()
(joystick vertical position), KN()
(knob status), and TR()
(trigger status).
PDL
function, passing in the controller number, 0 or 1, like A=PDL(0):PRINT A
, returning a value between 0 and 255.[133][c]Integer BASIC lacked any custom input/output commands, and also lacked the DATA
statement and the associated READ
. To get data into and out of a program, the input/output functionality was redirected to a selected card slot with the PR#x
and IN#x
, which redirected output or input (respectively) to the numbered slot. From then on, data could be sent to the card using conventional PRINT
commands and read from it using INPUT
.[130] Producing sounds was accomplished by PEEK
ing the memory-mapped location of a simple "beeper", −16336.[d]
Structured programming
While
).Of the Tiny BASIC implementations, only National Industrial Basic Language (NIBL) offered a loop command of any sort, DO/UNTIL
.[135] This was despite the inventor of Tiny BASIC, Dennis Allison, publicly lamenting the state of BASIC.[136]
The following example is in Microsoft QBASIC, Microsoft's third implementation of a structured BASIC (following Macintosh BASIC in 1984 and
REM QBASIC example
REM Forward declaration - allows the main code to call a
REM subroutine that is defined later in the source code
DECLARE SUB PrintSomeStars (StarCount!)
REM Main program follows
DO
INPUT "How many stars do you want? (0 to quit) ", NumStars
CALL PrintSomeStars(NumStars)
LOOP WHILE NumStars>0
END
REM subroutine definition
SUB PrintSomeStars (StarCount)
REM This procedure uses a local variable called Stars$
Stars$ = STRING$(StarCount, "*")
PRINT Stars$
END SUB
Object oriented
Initial support for object-oriented programming provided only the re-use of objects created with other languages, such as how Visual Basic and PowerBASIC supported the Windows Component Object Model. As BASIC interpreters continued to evolve, they added support for object-oriented features such as methods, constructors, dynamic memory allocation, properties and temporary allocation.
Included assembler
The Integer BASIC ROMs also included a
One of the unique features of BBC BASIC was the
Execution
Debugging
As in most BASICs, programs were started with the RUN
command, and as was common, could be directed at a particular line number like RUN 300
.[141] Execution could be stopped at any time using Ctrl+C[142] (or BREAK such as on the TRS-80) and then restarted with CONT
inue (CON
in Integer BASIC).[143] Taking advantage of the unique capabilities of interpreted programs (code is processed in realtime one statement at a time, in contrast to compilers), the user at the console could examine variable data using the PRINT statement, and change such data on-the-fly, then resume program execution.
For step-by-step execution, the TRON
or TRACE
instruction could be used at the command prompt or placed within the program itself. When it was turned on, line numbers were printed out for each line the program visited. The feature could be turned off again with TROFF
or NOTRACE
.[144]
Some implementations such as the Microsoft interpreters for the various TRS-80 models included the command ON ERROR GOSUB
. This would redirect program execution to a specified line number for special error handling.
Unlike most BASICs, Atari BASIC scanned the just-entered program line and reported syntax errors immediately. If an error was found, the editor re-displayed the line, highlighting the text near the error in
In many interpreters, including Atari BASIC, errors are displayed as numeric codes, with the descriptions printed in the manual.[145] Many MS-BASIC used two-character abbreviations (e.g., SN for SYNTAX ERROR). Palo Alto Tiny BASIC and Level I BASIC used three words for error messages: "WHAT?" for syntax errors, "HOW?" for run-time errors like GOTOs to a line that didn't exist or numeric overflows, and "SORRY" for out-of-memory problems.
Parsing
While the BASIC language has a simple syntax, mathematical expressions do not, supporting different precedence rules for parentheses and different mathematical operators. To support such expressions requires implementing a recursive descent parser.[146]
This parser can be implemented in a number of ways:
- As a virtual machine, as discussed above for many Tiny BASIC implementations. The value of the Tiny BASIC initiative was in specifying an implementation of a parser.
- As a finite-state machine, as in UIUC BASIC IUC, where it was implemented as a control table.[147]
- Directly in code, as in Palo Alto Tiny BASIC and Integer BASIC. In Integer BASIC, the runtime interpreter used two stacks for execution: one for statement keywords and the other for evaluating the parameters. Each statement was given two priorities: one that stated where it should occur in a multi-step operation, like a string of mathematical operations to provide order of operations, and another that suggested when evaluation should occur, for instance, calculating internal values of a parenthesis formula. When variables were encountered, their name was parsed and then looked up in the symbol table. If it was not found, it was added to the end of the list. The address of the variable's storage, perhaps freshly created, was then placed on the evaluation stack.[90]
Performance
The range of design decisions that went into programming a BASIC interpreter were often revealed through performance differences.
Line-management implementations often affected performance and typically used linear search. Delimiting each line with a CR would make a GOTO or GOSUB to a later line would take longer, as the program would need to iterate over all the lines to find the target line number. In some implementations, such as Atari BASIC, the length of each line was recorded and stored after the line number, so that the program did not have to scan each character of the line to find the next carriage return. Many implementations would always search for a line number to branch to from the start of the program; MS-BASIC would search from the current line, if the destination line number was greater. Pittman added a patch to his 6800 Tiny BASIC to use a binary search.[148]
Working solely with integer math provides another major boost in speed. As many
System | CPU | BASIC | Test 1 | Test 2 | Test 3 | Test 4 | Test 5 | Test 6 | Test 7 |
---|---|---|---|---|---|---|---|---|---|
Apple II | 6502 @ 1 MHz | Integer BASIC | 1.3 | 3.1 | 7.2 | 7.2 | 8.8 | 18.5 | 28.0 |
Apple II | 6502 @ 1 MHz | Applesoft BASIC | 1.3 | 8.5 | 16.0 | 17.8 | 19.1 | 28.6 | 44.8 |
In theory, Atari BASIC should have run faster than contemporary BASICs based on the Microsoft pattern. Because the source code is fully tokenized when it is entered, the entire tokenization and parsing steps are already complete. Even complex mathematical operations are ready-to-run, with any numerical constants already converted to its internal 48-bit format, and variables values are looked up by address rather than having to be searched for. In spite of these theoretical advantages, in practice, Atari BASIC is slower than other
Most of the language's slowness stemmed from three problems.[153] The first is that the floating-point math routines were poorly optimized. In the Ahl benchmark, a single exponent operation, which internally loops over the slow multiplication function, was responsible for much of the machine's poor showing.[153] Second, the conversion between the internal floating-point format and the 16-bit integers used in certain parts of the language was relatively slow. Internally, these integers were used for line numbers and array indexing, along with a few other tasks, but numbers in the tokenized program were always stored in binary-coded decimal (BCD) format.[156] Whenever one of these is encountered, for instance, in the line number in GOTO 100
, the tokenized BCD value has to be converted to an integer, an operation that can take as long as 3500 microseconds.[157] Other BASICs avoided this delay by special-casing the conversion of numbers that could only possibly be integers, like the line number following a GOTO
, switching to special ASCII-to-integer code to improve performance. Third was how Atari BASIC implemented branches and FOR
loops. To perform a branch in a GOTO
or GOSUB
, the interpreter searches through the entire program for the matching line number it needs.[158] One minor improvement found in most Microsoft-derived BASICs is to compare the target line number to the current line number, and search forward from that point if it is greater, or start from the top if less. This improvement was missing in Atari BASIC.[153] Unlike almost all other BASICs, which would push a pointer to the location of the FOR
on a stack, so when it reached the NEXT
it could easily return to the FOR
again in a single branch operation, Atari BASIC pushed the line number instead. This meant every time a NEXT
was encountered, the system had to search through the entire program to find the corresponding FOR
line. As a result, any loops in an Atari BASIC program cause a large loss of performance relative to other BASICs.[153]
See also
- List of BASIC dialects
- List of Computers With On-Board BASIC
- Microsoft Binary Format
Notes
- ^ Microsoft BASIC left 780 bytes free for user program code and variable values on a 4 KB machine, and that was running a cut-down version lacking string variables and other functionality.
- ^ Note the odd syntax of the SCRN, which is technically a function because it returns a value, but does not use function-like syntax which would be
A=SCRN(X,Y)
. - ^ The manual suggests, but does not outright state, that the actual range of values is less than 0 to 255.[133]
- ^ The negative number is a side-effect of the integers being stored in signed format, so any memory location over 32767 appeared as a negative value in BASIC.[134]
- ^ Bill Gates complained about this, stating that it was unfair to compare Integer BASIC to a "real" BASIC like MS.[149]
References
- ^ "IBM VS the World: That's How It Is". Computerworld. 5 December 1973.
- ^ "Hewlett-Packard 2100 Processor Description, 1972" (PDF). Retrieved 2020-08-18.
- ^ "Can we get a complete timeline on the IRIS Operating System for Data General Novas?". Retrieved 2020-08-05.
- ^ Savetz, Kevin (April 2013). "Dave Ahl and Betsy Ah" (Interview).
- ^ "Old Computers: HP-9830A". Retrieved 2020-08-18.
- ^ A BASIC Language Interpreter for the Intel 8008 Microprocessor. Department of Computer Science, University of Illinois at Urbana-Champaign (published 1974). June 1974.
- ^ "We have a BASIC". New Mexico Museum of Natural History and Science. Archived from the original on November 30, 2012. Retrieved April 18, 2007.
- ISBN 9780313354748.
- ^ Hertzfeld 1985.
- ^ Pittman, Tom. "you had to pay $5 up front to get it…". www.ittybittycomputers.com. Retrieved June 14, 2017.
- ^ Arnold, Mark; Wadsworth, Nat (February 1976a). "SCELBAL - A Higher Level Language for 8008/8080 Systems". Dr. Dobb's Journal. Vol. 1. pp. 30–34.
- ^ "Part 1 Of LLL 8080 BASIC Interpreter" (PDF).
- ^ Lorenzo 2017, p. 118.
- ^ Curran, Lawrence J.; Shuford, Richard S. (November 1983). "IBM's Estridge". BYTE. pp. 88–97. Retrieved 19 March 2016.
- ^ Wilkinson 1982, pp. iv–v.
- ^ Cromemco 1978.
- ^ Wilkinson 1982, p. ix.
- ^ Wilkinson 1982, p. v.
- ^ "Video processor for Acorn/BBC computer". BBC News. Retrieved 30 November 2010.
- ^ "BBC Micro ignites memories of revolution". BBC News. 21 March 2008. Retrieved 30 November 2010.
- ^ "ECN - July/Aug. 1985". Archived from the original on 2018-03-07. Retrieved 2020-08-04.
- ^ Smith, Tony (12 February 2014). "You're NOT fired: The story of Amstrad's amazing CPC 464". The Register. Retrieved 17 February 2014.
- ISBN 0-932760-00-7.
- ^ Lorenzo 2017, p. 83.
- ^ Gates, Bill. "Bill Gates Interview". National Museum of American History, Smithsonian Institution (Interview). Interviewed by David Allison. Retrieved April 10, 2013.
- ^ Malloy, Rich (May 1983). "Little Big Computer / The TRS-80 Model 100 Portable Computer". BYTE. p. 14. Retrieved October 19, 2013.
- ^ Lorenzo 2017, p. 122.
- ^ Williams, Gregg (February 1984). "The Apple Macintosh Computer". BYTE. p. 30.
- ^ "Mac GUI :: Re: Re: MAC Basic vs MS Basic?". macgui.com. Retrieved 23 January 2015.
- ISBN 0671880748.
- ^ Bill Atkinson interviewed on the TV show Triangulation on the TWiT.tv network
- ^ "Was Family BASIC for the NES/Famicom powerful enough to create full games and applications?". Retrieved 2020-08-27.
- ^ Thomas, Neil (19 Aug 2019). "STOS & Amos - Francois Lionet | Retro Tea Break". YouTube. Retrieved 11 Mar 2020.
- ISBN 978-0-521-85336-1.
Summary of positive issues: Visual Basic is easy to learn and widely available.
- ^ "The History of Visual Basic". www.johnsmiley.com.
- ^ Frank Wieduwilt (October 2008). "Programming with the Gambas Basic IDE". Linux Pro Magazine. Retrieved 2011-12-10.
- ^ "About the Game Creators - TheGameCreators".
- ^ "Small Basic download". 19 November 2018. Retrieved 2020-09-07.
- ISBN 2841771210.
- ^ Price, Ed (29 April 2014). "Small Basic Curriculum". TechNet. Microsoft. Retrieved 9 February 2014.
- ^ Price, Ed; Takahashi, Nonki (25 February 2014). "Small Basic Getting Started Guide". TechNet. Microsoft. Retrieved 12 February 2015.
- ^ "Small Basic". Retrieved 6 September 2020.
- ^ Price, Ed (22 October 2012). "The Unique Features of Small Basic". Small Basic. TechNet. Microsoft. Retrieved 22 April 2015.
- ^ Price, Ed (8 October 2012). "What are the 14 Keywords of Small Basic?". Small Basic. MSDN Blogs. Microsoft. Retrieved 9 February 2014.
- ^ "Announcing Small Basic Online 1.0 – Public Preview". 20 February 2019.
- ^ "Microsoft Small Basic Online v1.0 (CS): Installation Guide". Microsoft TechNet. Retrieved 8 January 2022.
- ^ "Contributors to robinhedwards/ArduinoBASIC". GitHub.
- ^ "BleuLlama/TinyBasicPlus: A C implementation of Tiny Basic, with a focus on support for Arduino". GitHub. Retrieved 2020-09-11.
- ^ "Vintage BASIC - Home". Retrieved 2020-09-11.
- ISBN 978-0-262-05093-7.
- ^ Wozniak 2014.
- ^ BASIC-PLUS Language Manual (PDF). Maynard, Massachusetts: Digital Equipment Corporation. 1972. pp. 3–13.
- ^ Lorenzo 2017, p. 106.
- Special Interest Group on Programming Languages (SIGPLAN) reprinted the Tiny Basic design notes from the January 1976 Tiny BASIC Journal.
- ^ Allison, Dennis (1976). "Build Your Own BASIC". Dr. Dobb's Journal. Vol. 1, no. 1. p. 9.
- ^ Allison, Dennis (1976). "Quick Reference Guide for Tiny BASIC". Dr. Dobb's Journal. Vol. 1, no. 1. p. 6.
- ^ "ZX80 – 8K BASIC ROM UPGRADE".
- ^ a b A BASIC Language Interpreter for the Intel 8008 Microprocessor. Department of Computer Science, University of Illinois at Urbana-Champaign (published 1974). June 1974. pp. 16–19.
- ^ "TB Code Sheet". Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Running Light Without Overbyte. 1 (1). December 1975.
- ^ "Robert Uiterwyk's Micro Basic".
- ^ Weyhrich 2001, The [Integer] BASIC, which we shipped with the first Apple II's, was never assembled — ever. There was one handwritten copy, all handwritten, all hand-assembled..
- ^ Wozniak 2018.
- ISBN 0-471-56886-4.
- ^ Gates, Bill (January 1976). "An Open Letter To Hobbyists". Homebrew Computer Club Newsletter. 2 (1). Mountain View, California: Homebrew Computer Club: 2.
- ^ "We have a BASIC". New Mexico Museum of Natural History and Science. Archived from the original on March 23, 2012. Retrieved 2007-04-18.
- ISBN 0-471-56886-4.
- ^ "XBASIC -- A Conversational BASIC Interpreter". GitHub. Retrieved 2020-09-07.
- ^ Lennart Benschop (March 8, 2002). "BASIC interpreter Version 1.22". Retrieved 2020-09-23.
- ^ Wilkinson, O'Brien & Laughton 1983.
- ^ "BASIC-PLUS inline operators, do they actually make sense?". Retrieved 2020-08-05.
- ^ Allen, Dennis. "TINY BASIC". People's Computer Company. Vol. 4, no. 3.
- ^ Greening, Bernard (1976). "Corrected Tiny BASIC IL". Dr. Dobb's Journal. Vol. 1, no. 1. p. 12.
- ^ Veit, Holger. "Tom Pittman's 6800 tiny BASIC". Retrieved 2 May 2017.
- ^ Nouspikel, Thierry. "GPL: Graphic Programming Language". Retrieved 2 August 2020.
- ^ "I grew up and learned basic on a TI-99/4a. It was a wonderful and simple time..." Hacker News. Retrieved 2 August 2020.
- ^ Wozniak 1977, p. 43.
- ^ Apple Programmers Aid (PDF). Apple. 1978.
- ^ Raskin 1978, p. 11.
- ^ Raskin 1978, p. 46.
- ^ Raskin 1978, pp. 49–55.
- ^ Raskin 1978, pp. 65–67.
- ^ "Tiny BASIC Extended". Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Running Light Without Overbyte. 1 (2). February 1976.
- ^ "Denver Tiny BASIC". Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Running Light Without Overbyte. 1 (3). March 1976.
- ^ a b "MINOL". Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Running Light Without Overbyte. 1 (4). April 1976.
- ^ a b Rauskolb, Roger (December 1976). "Dr. Wang's Palo Alto Tiny BASIC" (PDF). Interface Age. pp. 92–108.
- ^ Allison, Dennis (January 1976). "Design notes for Tiny BASIC". Dr. Dobb's Journal. Vol. 1, no. 1. p. 9.
- ^ Allison, Dennis (January 1976). "Build Your Own BASIC". Dr. Dobb's Journal. Vol. 1, no. 1. p. 8.
- ^ Steil, Michael (13 January 2015). "Microsoft BASIC for 6502 Original Source Code".
- ^ Hardiman, Roger. "Altair BASIC 3.2 (4K) – Annotated Disassembly". p. 1.11. Archived from the original on 5 November 2001.
- ^ a b c Wozniak 1977, p. 42.
- ^ Paul R. Santa-Maria. "Apple II Integer Basic Disassembly" (PDF). Retrieved 2020-09-14.[permanent dead link]
- ^ Wilkinson, O'Brien & Laughton 1983, p. 5.
- ^ Vickers 1983, p. 7–8.
- ^ a b "The BASIC Interpreter - Explained". Retrieved 2020-09-15.
- ^ "Part 1 Of LLL 8080 BASIC Interpreter" (PDF).
- ^ Raskin 1978, p. 118.
- ^ Wang, Li-Chen (May 1976). "Palo Alto Tiny BASIC". Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Running Light Without Overbyte. 1 (5): 12–25.
- ^ Raskin 1978, p. 38.
- ^ "Part 1 Of LLL 8080 BASIC Interpreter" (PDF).
- ^ "Part 1 Of LLL 8080 BASIC Interpreter" (PDF).
- ^ "What is the oldest reference to PEEK, POKE, and USR?". Retrieved 15 August 2020.
- ^ Altair 8800 BASIC Reference_Manual 1975, Page 68 of PDF, "Using the PEEK function and OUT statement of 8K BASIC, the user can write a binary dump program in BASIC. Using INP and POKE it is possible to write a binary loader. PEEK and POKE can be used to store byte oriented information. When you initialize BASIC, answer the MEMORY SIZE? question with the amount of memory in your ALTAIR minus the amount of memory you wish to use as storage for byte formatted data."
- ^ Raskin 1978, p. 27.
- ^ "Robert Uiterwyk's BASIC".
- ^ Welsh, David; Welsh, Theresa (2007). Priming the Pump: How TRS-80 Enthusiasts Helped Spark the PC Revolution. p. 7.
- ^ Reed, Matthew. "Level I BASIC". TRS-80.org. Retrieved 27 August 2017.
- ^ Arnold & Wadsworth 1976, p. 10.1.
- ^ Arnold & Wadsworth 1976, Chapter 10.
- ^ "Floating Point Routines for the 6502". Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Running Light Without Overbyte. 1 (7). August 1976.
- ^ "Part 1 Of LLL 8080 BASIC Interpreter" (PDF).
- ^ A BASIC Language Interpreter for the Intel 8008 Microprocessor. Department of Computer Science, University of Illinois at Urbana-Champaign (published 1974). June 1974. p. 20.
- ^ "GE-2xx documents". www.bitsavers.org. CPB-267_GE-235-SystemManual_1963.pdf, p. IV-4.
- ^ Lorenzo 2017, p. 149.
- ^ Steil, Michael (20 October 2008). "Create your own Version of Microsoft BASIC for 6502".
- ^ Raskin 1978, p. 61.
- ^ MITS Altair BASIC. Albuquerque, NM: MITS. 1975. p. 37.
- ISBN 0-932760-33-3.
- ^ Raskin 1978, p. 94.
- ^ MITS Altair BASIC. Albuquerque, NM: MITS. 1975. p. 31.
- ^ a b c HP 2000/Access BASIC Reference Manual (PDF). Hewlett Packard. May 1976., Part No. 22687-90001
- ^ North Star BASIC version 6 (PDF). North Star Corporation. 1977. Archived from the original (PDF) on 2020-03-05. Retrieved 2020-08-01.
- ^ The ATARI BASIC Reference Manual. Atari Inc. 1980. Archived from the original on 2005-05-01. Retrieved 2020-08-01.
- ^ "Integer, Floating Point and String Variables". C64 Programmer's Manual. Commodore.
- ^ Raskin 1978, p. 89.
- ^ "Create your own Version of Microsoft BASIC".
- ^ Lien, David (1977). User's Manual for Level I (First ed.). Fort Worth, TX: Tandy Corporation. pp. 105–108, 137. Retrieved 9 August 2020.
- ^ Raskin 1978, p. 31.
- ^ Raskin 1978, p. 32.
- ^ Raskin 1978, p. 33.
- ^ a b Raskin 1978, p. 120.
- ^ Lorenzo 2017, p. 120.
- ^ "Would some BASIC interpreters for microcomputers be considered operating systems?". Retrieved August 7, 2020.
- ^ a b Raskin 1978, p. 36.
- ^ Mini 1977, p. 18.
- ^ "NIBL". Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Running Light Without Overbyte. 1 (10). November 1976.
- ^ "Problems with BASIC". Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Running Light Without Overbyte. 1 (2). February 1976.
- ^ "Differences Between GW-BASIC and QBasic". 2003-05-12. Archived from the original on 2013-10-19. Retrieved 2008-06-28.
- ^ Lorenzo 2017, p. 137.
- ^ Helmers 1978, p. 18.
- ^ Weyhrich 2001.
- ^ Raskin 1978, p. 100.
- ^ Raskin 1978, p. 15.
- ^ Raskin 1978, p. 52.
- ^ Raskin 1978, p. 107.
- ^ Manual 1980, Appendix B.
- ^ "What type of interpreter were most 8-bit BASIC implementations?". Retrieved August 9, 2020.
- ^ A BASIC Language Interpreter for the Intel 8008 Microprocessor. Department of Computer Science, University of Illinois at Urbana-Champaign (published 1974). June 1974. pp. 24–36.
- ^ Pittman, Tom (1981). "The First Book of Tiny BASIC Programs". Retrotechnology.com. Itty Bitty Computers. Retrieved August 5, 2020.
Because TA is so large (19,703 bytes), I found that execution became excruciatingly slow, simply due to the memory scan for GOTOs, GOSUBs, and RETURNs. A simple patch to the interpreter converts it to a binary search algorithm, for about an order of magnitude speedup in execution time. The necessary changes are listed in the Appendix.
- ^ a b Rugg, Tom; Feldman, Phil (October 1977). "BASIC timing comparisons… revised and updated". Kilobaud. pp. 20–25.
- ^ a b Rugg, Tom; Feldman, Phil (June 1977). "BASIC Timing Comparisons… information for speed freaks". Kilobaud. pp. 66–70.
- ^ Gilbreath, Jim (September 1981). "A High-Level Language Benchmark". Byte. p. 192.
- ^ Ahl, David (November 1983). "Benchmark Comparison Test". Creative Computing. p. 260.
- ^ a b c d e Wilkinson 1985, p. 139.
- ^ Ahl, David (November 1983). "Benchmark comparison test". Creative Computing. pp. 259–260.
- ^ Ahl, David (January 1984). "Creative Computing Benchmark". Creative Computing. p. 12.
- ^ Wilkinson, O'Brien & Laughton 1983, p. 17.
- ^ Crawford 1982, p. 8.45.
- ^ Winner, Lane (1982). "De Re Atari, Chapter 10: Atari BASIC". Atari, Inc.
Bibliography
- Apple II Mini Manual. Apple. 1977.
- Arnold, Mark; Wadsworth, Nat (1976). SCELBAL: A higher level language for 8008/8080 systems (PDF). SCELBI Computer Consulting.
- The ATARI BASIC Reference Manual. Atari Inc. 1980. Archived from the original on May 1, 2005.
- Crawford, Chris (1982). De Re Atari. Atari Program Exchange.
- Cromemco 16K Extended BASIC (PDF). Cromemco. 1978.
- Helmers, Carl (March 1978). "An Apple to Byte". Byte. pp. 18–24, 30–32, 35, 40–46.
- Hertzfeld, Andy (June 1985). "The sad story of MacBasic". Folklore.
- Lorenzo, Mark (2017). Endless Loop: The History of the BASIC Programming Language. Philadelphia: SE Books. ISBN 978-1974-27707-0.
- Raskin, Jef (1978). Apple II BASIC Programming Manual (PDF). Apple Computer.
- Vickers, Steven (1983). Sinclair ZX Spectrum BASIC Programming (2 ed.). Sinclair Research.
- Weyhrich, Steven (12 December 2001). "History part 3: The Apple II". Retrieved 2007-09-16.
- Wilkinson, Bill (1982). Inside Atari DOS. Optimized Systems Software, Inc. ISBN 0-942386-02-7. Retrieved 2009-04-04.
- Wilkinson, Bill (February 1985). "INSIGHT: Atari". Creative Computing. pp. 139–140.
- Wilkinson, Bill; O'Brien, Kathleen; Laughton, Paul (1983). The Atari BASIC Source Book. Compute! Books. ISBN 0-942386-15-9.
- Williams, Gregg; Moore, Rob (December 1984). "The Apple Story / Part 1: Early History". Byte. pp. A67–A71. Retrieved 23 October 2013.
- Wozniak, Steven (May 1977). "System Description / The Apple-II". Byte. pp. 34–43.
- Wozniak, Steven (1 May 2014). "How Steve Wozniak Wrote BASIC for the Original Apple From Scratch". Gizmodo.
- Wozniak, Steven (3 January 2018). "Apple BASIC". Woz.org.
Further reading
Source code and design documents, in chronological order of the release of the BASIC implementations:
- Weaver, Alfred; Tindall, Michael; Danielson, Ronald (June 1974). A BASIC Language Interpreter for the Intel 8008 Microprocessor. Department of Computer Science, University of Illinois at Urbana-Champaign (published 1974).
- Arnold, Mark (1977). SCELBAL Mathematical Functions Supplement. SCELBI Computer Consulting.
- Arnold, Mark (1977). SCELBAL Strings Supplement. SCELBI Computer Consulting.
- "Altair BASIC 3.2 (4K) - Annotated Disassembly".
- Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Volume 1. People's Computer Company. 1976.
- Rauskolb, Roger (December 1976). "Dr. Wang's Palo Alto Tiny BASIC" (PDF). Interface Age. pp. 92–108.
- Pittman, Tom (1977). Tiny BASIC Experimenter's Kit.
- Santa-Maria, Paul. "Apple II Integer Basic Disassembly" (PDF).[permanent dead link]