Level I BASIC
Level I BASIC is a dialect of the BASIC programming language that shipped with the first TRS-80, the TRS-80 Model I.
Background
Tandy employee Steve Leininger wrote the first draft of the NIBL (National Industrial Basic Language) BASIC interpreter for the SC/MP while employed at National Semiconductor. Unable to take that source code with him, he initially hired a consultant to write an interpreter. When the consultant failed to deliver, Leininger, Don French, and BASIC manual author David A. Lien adapted Li-Chen Wang's public domain version of Tiny BASIC for the prototype TRS-80 Model I. Leininger said, "we went back through the Wang Basic and completely tore out about 60 per cent of it, the integer overhead and all that kind of stuff". The result required only 2 KB of memory for the interpreter, leaving an average of another 2 KB free for user programs in common 4 KB memory layouts of early machines.
During a demonstration to executives, Tandy Corporation President Charles Tandy tried to enter his salary but was unable to do so, because Tiny BASIC uses 2-byte signed integers with a maximum value of 32,767. The result was a request for floating-point math for the production version. This led to the replacement of the existing 16-bit integer code with a version using 32-bit single-precision floating-point numbers. Leininger further extended the language to support input/output routines. The language fits within 4 KB of ROM.
Further development
When the TRS-80 was introduced, three versions of BASIC were announced:- Level I BASIC
- Level II BASIC - developed by Microsoft and using 12 KB of ROM to add string handling, error handling, trigonometric and other dedicated functions
- Level III BASIC - also developed by Microsoft, offering disk commands
Language features
Level I BASIC supports the following keywords:- Commands:
NEW,RUN,LIST,CLOAD,CSAVE,CONT - Statements:
PRINT,INPUT,READ,DATA,RESTORE,LET,REM - Print modifiers:
AT,TAB - Structure:
GOTO,GOSUB,ON-GOTO,ON-GOSUB,RETURN,IF-THEN,FOR-TO-STEP,NEXT,STOP,END - Graphics:
CLS,SET,RESET,POINT - Functions:
ABS,INT,RND,MEM - Math:
+-*/ - Relational operators:
<>=<==><> - Logical operators:
*+
F. for FOR, G. for GOTO, P. for PRINT, and T. for THEN.The language supports 26 single-precision variables A to Z, two strings A$ and B$, and one pre-defined array A. The language lacks a DIM statement for dimensioning the array, the size of which is determined by available memory not used by the program listing. As the language lacks many common math functions, the manual provides subroutine listings for square root, exponentiation, exponentials, logarithms, arithmetic sign, and trigonometry functions.
Graphics support is minimal:, for CLear Screen;, which lights a location on the display;, which turns it off; and, which returns 1 if a location was lit, 0 if it was not. The coordinates can be any expression and ranges from 0 to 127 for the X-axis and 0 to 47 for the Y-axis. Only black-and-white display is supported.