ArticleslgStudy

computer science

Color BASIC

Color BASIC is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Color BASIC rather than just read about it. In short: Color BASIC is the implementation of Microsoft BASIC that is included in the ROM of the Tandy/Radio Shack TRS-80 Color Computers manufactured between 1980 and 1991. BASIC (Beginner's All-purpose Symbolic Instruction Code) is a high level language with simple syntax that makes it easy to write simple programs.

Color BASIC — main illustration
Color BASIC — illustration

Key takeaways

  • Color BASIC belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Color BASIC to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Color BASIC from memory before moving on to harder problems.

Reference excerpt

Color BASIC is the implementation of Microsoft BASIC that is included in the ROM of the Tandy/Radio Shack TRS-80 Color Computers manufactured between 1980 and 1991. BASIC (Beginner's All-purpose Symbolic Instruction Code) is a high level language with simple syntax that makes it easy to write simple programs. Color BASIC is interpreted, that is, decoded as it is run.

Background

The nucleus of Color BASIC was Microsoft BASIC-69 which Tandy licensed from Microsoft. Color BASIC 1.0 was released with the original 4k TRS-80 Color Computer in 1980. It resides on 8k bytes of ROM, and is responsible for all 'housekeeping' duties on the system. This includes hardware initialization, memory management, interrupt processing, etc. Like most implementations of BASIC, each line of code starts with a line number and consists of one or more statements with variables and operators. 16k of memory is required for the next level of BASIC, Extended Color BASIC ("ECB"). Extended BASIC is required for the floppy disk controller, which then gives you Disk Extended Color BASIC ("DECB"). Emulators of the Color Computers running this interpreter and the others are available for modern computers, some of which require a "snapshot" file of the physical machine.

Variables Color BASIC understands one type of numeric variable and string variables. Variable names in Color BASIC have the first two characters significant. The first character of the variable name must be a letter. The second can be either a letter or number. String variables are indicated by adding a dollar sign ($) after the variable name.

Examples

Numeric variables have only one type, a binary floating point implementation. Each numeric variable uses 5 bytes of memory and can be in the range from -1E+38 up to 1E+37. Unlike most implementations of Microsoft BASIC, Color BASIC requires the user to reserve space for string variables via the CLEAR statement. Multidimensional arrays are also supported with both numeric and string variables. In the case of an array, the element address is enclosed with a parenthesis:

Multiple dimensions are separated by commas

Operators and symbols Color BASIC provides several operators for both mathematic and, to a lesser extent, string operations.

+ can be used to concatenate strings or for mathematical addition - is used for subtraction * is used for multiplication / is used for division Parenthesis ( ) are used to override mathematical order of operation

AND is used for logical 'and' operations OR is used for logical 'or' operations NOT is used for logical 'not' operations For testing, the following operators are used:

= is equal to > is greater than < is less than >= is greater than or equal to (also => is acceptable) <= is less than or equal to (also =< is acceptable) <> is not equal to (also >< is acceptable) Other symbols used in BASIC:

" " indicates string data is a constant (static) : separates multiple commands on a single program line A semicolon, when encountered in a PRINT function, will cause the output to remain on the same line A comma, when encountered in a PRINT function, will tab to the next column

Key num indicates a numeric expression is required. This can be a fixed number, a variable, or other operation or function that returns a numeric quantity. str indicates a string expression is required. This can be a static string value (in quotes), a string variable, or other function or expression that returns a string of characters. device number indicates a device. By default, device 0 (screen and keyboard) is assumed. In Color BASIC, device #-1 (cassette) and #-2 (printer) are available to the programmer.

Edit mode If you make a mistake typing in a line, you can either retype it from scratch (or DEL it).. or you can EDIT it. When in EDIT mode, you get a reprint of the line, and a second copy that you SPACEbar across chars. You cannot use arrow keys. backspace takes you left, but does not actually erase it in the buffer. 'i' puts you in insert mode. pressing return gets you out of it. 'c' changes one char, 'd' deletes one char. 'x' takes you to end of line, allowing you to e'x'tend it. 'l' redraws the line. 's' searches for the next instance of a character. For the 's', 'c' and 'd' commands you can also enter a number (#) before pressing any of them which will: 's' - search for the # instance of the character, 'c' - allow you to change # of characters, 'd' - delete # amount characters.

Functions ABS(num) returns the absolute value of num ASC(str) returns the ASCII code of the first character in str CHR$(num) returns a single string character with the ASCII code num EOF(device number) returns 0 if the file has data, or -1 if at the end of the file INKEY$ returns a character if a key on the keyboard has been pressed, or null if nothing is pressed INT(num) returns the integer portion of num INSTR(startpos,search str,target str) searches for the first string, in the target str. startpos is optional. JOYSTK(num) returns the position of the joystick axis (0-3) with a value from 0 to 63 LEFT$(str,num) returns the first ("left") num characters of string str LEN(str) returns the length (in characters) of string str MEM returns the available free memory in bytes MID$(str,start num,length num) returns a sub-string of string str beginning at position start num and length num characters long. Can also reassign by adding ="newvalue" PEEK(num) returns the value of the memory location num (0-65535) POINT(x num,y num) returns the color of the semigraphics dot at position x numm (0-63) and y num (0-31) RIGHT$(str,position num) returns the end ("right") portion of string str beginning at character position num RND(number) returns a random number (integer) between 1 and num SGN(num) returns the sign of a number num, 1 if positive, -1 if negative, 0 if 0 SIN(num) returns the sine of num in radians STR$(num) returns a string of the number num USR(num) calls a machine language subroutine whose address is stored in memory locations 275 and 276. num is passed to the routine, and a return value is assigned when the routine is done

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Color BASIC

Start with the simplest possible case. Write down what Color BASIC claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Color BASIC before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Color BASIC ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Color BASIC

In research
Color BASIC appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Color BASIC in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Color BASIC is common in secondary-school and first-year university syllabi. It links to neighbouring topics BASIC programming language family, Discontinued Microsoft BASICs, Microsoft programming languages, so understanding it makes those chapters shorter.
In everyday life
Look for Color BASIC outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Color BASIC” →

How to study Color BASIC in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Color BASIC means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Color BASIC out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Color BASIC in simple terms?

Color BASIC is the implementation of Microsoft BASIC that is included in the ROM of the Tandy/Radio Shack TRS-80 Color Computers manufactured between 1980 and 1991. BASIC (Beginner's All-purpose Symbolic Instruction Code) is a high level language with simple syntax that makes it easy to write simpl…

Why does Color BASIC matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Color BASIC?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Color BASIC.

Tags

  • BASIC programming language family
  • Discontinued Microsoft BASICs
  • Microsoft programming languages
  • TRS-80 Color Computer

Keep exploring