Dr. J's Notes on TRS-80 Extended Color BASIC for CS 370

Basic was first and foremost an interactive language, invented at Dartmouth. When at the BASIC "OK" prompt you could type expressions on the fly, enter or edit lines of program code, load or save a program to disk, or run the program.

Early pre-IBM personal computers had very little operating system on them, but most of them came with a Microsoft BASIC interpreter built-in. PC makers gladly paid Microsoft a small fee to include this feature. The programming language was free and open, inviting all to write programs, a policy which was inverted in stark contrast with Microsoft's later monopoly.

TRS-80 Extended Color BASIC was a licensed version of Microsoft BASIC, substantially enhanced by Tandy Radio Shack engineers. It included core BASIC features along with very easy to use graphics and sound capabilities.

The CS 370 project in Fall 2003 is to implement a compiler for "as much of TRS-80 Extended Color BASIC as we can". A vintage 1981 BASIC is selected as a relatively simple, yet real, language to write a compiler for.

Reserved Words

These are used in control structures. They are documented in the Radio Shack BASIC books. Any extra notes are included here.
name description/comment/example
CLOAD
CLEAR
CSAVE
DATA
END
FOR
GOSUB
GOTO
IF
INKEY$
INPUT
LIST
NEW
NEXT
PRINT
READ
REM
RESTORE
RETURN
RUN
SKIPF
SOUND
STEP
THEN
TO

Built-in Functions

Extended Color BASIC does not have user-defined functions using regular function syntax, it has "subroutines" called via GOSUB. But it does have many built-in functions which use function syntax and are reserved words. One difference between them and other reserved word is: we may lump them together into a single token category for lexical analysis, since they comprise a single syntactic category, one kind of expression.
name description
ASC return the ASCII integer for the first character in a string
CHR$ return the one-letter string for a given ASCII integer
CLS clears the screen. The parameter is OPTIONAL color (default: green)
INT convert number to integer
JOYSTK
LEFT$(s, n) return the leftmost n characters of s
LEN string length
MID$(s, n) return middle n characters of s
PEEK returns contents of a memory address (CS 370 will not do this one)
SET
RESET
RIGHT$(s, n) return rightmost n characters of s
RND returns a random number
VAL converts a string to a number

Operators

+
-
*
/
=
>
>=
=>
<=
=<
<
<>
><

Literal (constant) values

strings, enclused in double quotes
decimal integers consisting of 1 or more digits
real numbers consisting of one or more digits with a period character somewhere

Other Punctuation

: is a statement separator
( ) override default operator precedence

White space and comments

white space includes newlines and tabs
REM marks a comment line