Tiny BASIC is a dialect of the BASIC programming language that can fit into as little as 2 or 3 KB of memory. This small size made it invaluable in the early days of microcomputers (the mid-1970s), when typical memory size was only 4–8 KB. The prevalence of BASIC on the first generation of home computers is an outcome of Tiny BASIC.
An early free software project
Tiny BASIC is an example of a free software project that existed before the free software movement. It started in the newsletter of the People's Computer Company in 1975. Dennis Allison, a member of the Computer Science faculty at Stanford University, wrote a specification for a simple version of the BASIC programming language. He was urged to create the standard by Bob Albrecht of the Homebrew Computer Club. He had seen BASIC on minicomputers and felt it would be the perfect match for new machines like the MITS Altair 8800, which had been released in January 1975. This design did not support text strings and only used integer arithmetic. The goal was for the program to fit in 2 to 3 kilobytes of memory.
The Tiny BASIC contents of the newsletter soon became Dr. Dobb's Journal of Tiny BASIC with a subtitle of "Calisthenics & Orthodontia, Running Light Without Overbyte." Hobbyists began writing BASIC language interpreters for their microprocessor-based home computers and sending the source code to Dr. Dobb's Journal and other magazines to be published. Dick Whipple and John Arnold wrote an interpreter that required only 3K of RAM. By the middle of 1976, Tiny BASIC interpreters were available for the Intel 8080, the Motorola 6800 and MOS Technology 6502 processors. This a forerunner of the free software community's collaborative development before the internet allowed easy transfer of files, and was an example of a free software project before the free software movement. Computer hobbyists would exchange paper tapes, cassettes or even retype the files from the printed listings.
Jim Warren, editor of Dr. Dobb's Journal, wrote in the July 1976 ACM Programming Language newsletter about the motivations and methods of this successful project. He started with this: "There is a viable alternative to the problems raised by Bill Gates in his irate letter to computer hobbyists concerning 'ripping off' software. When software is free, or so inexpensive that it's easier to pay for it than to duplicate it, then it won't be 'stolen'." The method was to have an experienced professional do the overall design and then outline an implementation strategy. Knowledgeable amateurs would implement the design for a variety of computer systems. Warren predicted this strategy would be continued and expanded.
The May 1976 issue of Dr. Dobbs Journal had Li-Chen Wang's Palo Alto Tiny BASIC for the Intel 8080 microprocessor. The listing began with the usual title, author's name and date but it also had "@COPYLEFT ALL WRONGS RESERVED". A fellow Homebrew Computer Club member, Roger Rauskolb, modified and improved Li-Chen Wang's program and this was published in the December 1976 issue of Interface Age magazine. Roger added his name and preserved the COPYLEFT Notice.
Tiny BASIC grammar
The grammar is listed below in Backus-Naur form. 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 their being listed on separate lines. The symbol "CR" denotes a carriage return (usually generated by a keyboard's "Enter" key).
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 ::= < (>|=|ε) | > (<|=|ε) | = A BREAK from the console will interrupt execution of the program
Source: Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Volume 1, Number 1, 1976, p. 9.
Implementation in interpreted language
For some implementations, an interpreted language (IL) is used. (At least two later versions, Palo Alto Tiny BASIC and 68000 Tiny BASIC, are direct interpreters). An interpreter written in IL interprets a line of Tiny Basic code and executes it. The IL is run on an abstract machine, which interprets IL code. The idea to use an interpreted language goes back to Val Schorre (with META II, 1964) and Glennie (Syntax Machine). See also virtual machine.
The following table gives a partial list of the commands of the interpreted language in which the Tiny BASIC interpreter is written. The length of the whole interpreter program is only 120 IL operations. Thus the choice of an interpretive approach economized on memory space and implementation effort, although the BASIC programs run thereon were executed somewhat slowly. The CRLF in the last line symbolizes a carriage return followed by a line feed.
|TST lbl, string||If string matches the BASIC line, advance cursor over string and execute the next IL instruction; if the test fails, execute the IL instruction at the label lbl|
|CALL lbl||Execute the IL subroutine starting at lbl; save the IL address following the CALL on the control stack|
|RTN||Return to the IL location specified at the top of the control stack|
|DONE||Report a syntax error if after deleting leading blanks the cursor is not positioned to reach a carriage return|
|JUMP lbl||Continue execution of the IL at the label specified|
|PRS||Print characters from the BASIC text up to but not including the closing quotation mark|
|PRN||Print number obtained by popping the top of the expression stack|
|SPC||Insert spaces to move the print head to next zone|
|NLINE||Output a CRLF to the printer|
Source: Dr. Dobb's Journal, Volume 1, Number 1, 1976, p. 12.
- Tiny Basic User Manual and Experimenter's Kit – by Tom Pittman
- Robert Uiterwyk's BASIC and Robert Uiterwyk's Micro Basic – A MC6800 tiny BASIC later sold with the SWTPC 6800 computer
- MINOL – Erik Mueller's MINOL – Tiny BASIC with strings for Intel 8080
- TBL – A similar IL to Tiny BASIC's, used in the first successful compilers for PL/I, Fortran, etc., on limited memory minicomputers
- 68000 Tiny BASIC – Based on Li-Chen Wang's Palo Alto Tiny BASIC, and published in the 100th edition of Dr. Dobb's
- Tiny BASIC – An implementation written in SmallBASIC
- tinyBasic – An implementation written in iziBasic
- Tiny BASIC – A live web version, ported to Run BASIC from iziBasic
- TinyBasic – A port of Tom Pittman's TinyBasic C interpreter to Java, C# and Adobe Flex. Includes live web versions.
- "Dr. Dobb’s Journal"
- Allison, Dennis (July 1976). "Design notes for TINY BASIC". SIGPLAN Notices (ACM) 11 (7): pp. 25–33. doi:10.1145/987491.987494. The ACM Special Interest Group on Programming Languages (SIGPLAN) reprinted the Tiny Basic design notes from the January 1976 Tiny BASIC Journal.
- Warren, Jim C. (July 1976). "Correspondence". SIGPLAN Notices (ACM) 11 (7): pp. 1–2. ISSN 0362-1340.
- 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. Source code begins with the following six lines. "TINY BASIC FOR INTEL 8080; VERSION 1.0; BY LI-CHEN WANG; 10 JUNE, 1976; @COPYLEFT; ALL WRONGS RESERVED" The June date in the May issue is correct. The magazine was behind schedule, the June and July issues were combined to catch up.
- Rauskolb, Roger (December 1976). "Dr. Wang's Palo Alto Tiny BASIC". Interface Age 2 (1): 92–108. The source code begins with the following nine lines: TINY BASIC FOR INTEL 8080; VERSION 2.0; BY LI-CHEN WANG; MODIFIED AND TRANSLATED TO INTEL MNEMONICS; BY ROGER RAUSKOLB; 10 OCTOBER, 1976 ; @COPYLEFT; ALL WRONGS RESERVED