This article is about the programming language BASIC in connection to Commodore computer systems.
The acronym BASIC stands for "Beginner’s All-purpose Symbolic Instruction Code", which used to be a very famous programming language from the 70s to the 90s. It was invented in 1964 by John George Kemeny and Thomas Eugene Kurtz. During the last decades, various BASIC-dialects have emerged. This article informs you about BASIC for Commodore computers.
- 1 CBM BASIC
- 2 Commodore BASIC Commands
- 2.1 Overview of BASIC Version 2.0 (second release) Commands
- 2.2 Overview of BASIC Version 3.5 Commands
- 2.3 Overview of BASIC Version 3.6 Commands
- 2.4 Overview of BASIC Version 4.0 Commands
- 2.5 Overview of BASIC Version 4+ Commands
- 2.6 Overview of BASIC Version 7.0 Commands
- 2.7 Overview of BASIC Version 10.0 Commands
- 3 C64 U3 BASIC ROM Failure Symptoms
- 4 More advanced programming techniques
- 5 Links
From the series of PET/CBM 2001 to the home computers C64/C128/C128DCR20, C16/C116, Plus/4, Ultimax, C65 Commodore used an individually developed BASIC-version termed CBM-BASIC. There are several sub-dialects of which BASIC Version 2.0 is the most popular.
Commodore developed their BASIC under licence from Microsoft in 1977 for their systems. On Commodore systems BASIC is not only used as programming language, but also as operating system. BASIC is configured on a ROM chip.
BASIC V2.0 of C64
Another overview is the article C64-Commands.
The operating system (OS) of the Commodore 64 is CBM BASIC version 2, which has 38911 BASIC bytes (chars) free in its memory (RAM). In a wider sense, all C64 commands, which are inputted in the direct mode under BASIC, are BASIC-commands.
The BASIC-Interpreter reports
READY. and the blinking cursor shows the user that the computer is ready for input. After a BASIC command is typed in correctly, the command will be executed; otherwise an error-message will be reported, followed by READY..
Input a BASIC program
By using BASIC commands with line numbers, the BASIC interpreter is adding this BASIC line in the BASIC memory as one line of a BASIC program. If this line number exists this line will overwritten (by using empty line numbers, these line will deleted).
- BASIC programs can listening with the BASIC command LIST.
- Line numbers are also used for labels for jump commands like GOTO.
- The command RUN starts a BASIC program.
- Running BASIC programs can stopped with the key and the computer is also in direct mode.
- Written BASIC programs are first only in the memory. After switch off or resetting the computer or loading new data (with LOAD) into the RAM the actually BASIC program is lost or damaged. For saving on a data carrier (e.g. disk, datasette), you must used the BASIC command SAVE.
- With the command LOAD can loaded programs into the RAM of the C64.
The animations shows following steps:
- Calculation in direct mode: PRINT
- Loading a program from disk: LOAD
- Running a BASIC program: RUN
- Listening a BASIC program: LIST
- Editing a program (only first line)
- Restarting this program
- Soft reset by using the command SYS
- The input of a BASIC command must be finished by using the key .
- Different commands within a line can be separated with a colon
- Normally a BASIC line can have 80 characters maximum (40 characters over 2 lines) - any further characters are ignored. Excess length lines can be generated by using abbreviations (tokens) of the BASIC-commands or with compilers (e.g.
- Variables can be used in the direct mode, but not all BASIC commands (e.g. INPUT).
- By editing BASIC programs in direct mode, the content of defined variables are lost.
- You should use great steps between the line numbers (e.g. 10, 20, 30, etc.), because easy renumbering (like RENUMBER) of line numbers are only available with extra tools or special coding languages.
- Programs with only one line number followed by a SYS aren't technically BASIC programs. The command SYS is calling an assembler program and this line is only for comfortable start of this assembler program.
- The name of variables must not consist of BASIC-keywords (see BASIC-keyword-table below). Particularly, ST is a reserved variable that returns the status of the last I/O operation.
- Data and characters can only be assigned to variables with the correct properties.
- A BASIC program may only contain the line numbers from 0 to 63999 inclusive.
A BASIC line has only max. 255 bytes and this structure:
- Start address of the next BASIC line in low and high byte ($0000 is the end of a program)
- Line number in low and high byte
- The program code (until 250 bytes)
- A 0 byte is the end of a BASIC line
Commodore BASIC Commands
Overview of BASIC Version 2.0 (second release) Commands
BASIC 2.0 (second release, as used in the C64, VIC20, C128, C128D, C128DCR) contains 71 commands:
Overview of BASIC Version 3.5 Commands
BASIC 3.5 (used in the C16, C116 and Plus/4) contains 108 commands:
Overview of BASIC Version 3.6 Commands
BASIC 3.6 (used in the unreleased prototype Commodore LCD) contains 167 commands:
Overview of BASIC Version 4.0 Commands
BASIC 4.0 (used in the PET and CBM computers of the CBM 4000/8000 series) contains 89 commands:
Overview of BASIC Version 4+ Commands
Overview of BASIC Version 7.0 Commands
BASIC 7.0 (used in the C128, C128D, C128DCR) contains 168 commands:
Overview of BASIC Version 10.0 Commands
BASIC 10.0 (used in the unreleased prototype C65, and is therefore imperfect) contains 185 commands:
C64 U3 BASIC ROM Failure Symptoms
- Blank screen with border.
- Cartridge works.
More advanced programming techniques
C64 BASIC is a relatively primitive programming language compared to more modern languages. It is even primitive compared to languages that existed at the same time. There is no provision for creating specialized data types, dynamic allocation of memory or pointers. There isn't even provision for local variables!
You might think that therefore, techniques such as recursion and linked lists can not be done on C64 BASIC. However, this is not true. This section introduces some of the techniques that can be used on the C64 to mimic some of the features of more sophisticated programming languages.
It is assumed that the reader is fully aware how arrays work in C64 BASIC:
- BASIC 3.5 overview of Janne Peräaho and Anders Persson
- CBM BASIC History
- Create your own Version of Microsoft BASIC for 6502
- Bill Gates’ Personal Easter Eggs in 8 Bit BASIC
- Handbook BASIC 4 (incl. versions 1-3) at commodore.ca
- Basics Informations BASIC V2 at www.homecomputermuseum.de
- CBM8096 LOS-96 Handbuch (Handbook BASIC 4.0 Expand)
- BASIC 7.0 for Plus/4 (hungary)
- BASIC 7.0 for Plus/4 - article and infos