Est. 1977 Beginner

CBM BASIC

Commodore's in-house line of Microsoft 6502 BASIC: the READY. prompt of the PET, VIC-20, Commodore 64, Plus/4 and Commodore 128, from the 1977 PET's BASIC 1 to the C128's BASIC 7.0.

Created by Microsoft (6502 BASIC by Ric Weiland, Bill Gates and Monte Davidoff), licensed and extended in-house by Commodore Business Machines

Paradigm Procedural (line-numbered, unstructured BASIC; structured loops from BASIC 3.5)
Typing Dynamic, weak; 5-byte floating-point reals, % integers (-32768 to 32767) and $ strings (0-255 characters)
First Appeared 1977
Latest Version BASIC 7.0 (Commodore 128, 1985) was the last shipped version; BASIC 10 for the cancelled Commodore 65 (1991) lives on as the MEGA65's BASIC 65

CBM BASIC, also called Commodore BASIC or PET BASIC, is the family of BASIC interpreters that Commodore Business Machines built into its 8-bit computers. It started in 1977 with the Commodore PET and ended with the Commodore 128 in 1985. Every version grew out of the same licensed copy of Microsoft’s 6502 BASIC. Switch on a PET, VIC-20, Commodore 64, Plus/4 or C128 and you are in CBM BASIC at a READY. prompt with a blinking cursor. On the C64 alone that meant millions of people, and the startup banner **** COMMODORE 64 BASIC V2 **** became one of the best-known screens in home computing.

Commodore’s own manuals use the name. The Commodore 64 Programmer’s Reference Guide (©1982) says that “only the first two characters are considered significant in CBM BASIC.” This entry covers the family as a whole: the shared core, the versions, and how they differ.

History & Origins

Microsoft BASIC for the 6502

Microsoft’s BASIC for the MOS 6502 was a port of its Intel 8080 BASIC. Michael Steil, who reverse-engineered and compared the early versions, credits Ric Weiland, Bill Gates and Monte Davidoff with writing it in the summer of 1976. Microsoft built the 6502 code on a PDP-10 using Paul Allen’s macros. The source Microsoft later published has a separate conditional-assembly target for each customer: KIM-1, Ohio Scientific, Commodore and Apple. Steil points out that features such as file I/O and the TI/TI$ clock appear to have been written specifically for Commodore.

Commodore had bought MOS Technology, the maker of the 6502, in 1976. According to Steil it licensed the BASIC that autumn for the computer that became the PET. Commodore paid a single flat fee rather than a per-unit royalty. The figure usually quoted is $25,000, which comes from Jack Tramiel’s recollection at the Computer History Museum’s Commodore 64 anniversary event in 2007; there is no contemporary document for it.

The PET and BASIC 1

A working PET 2001 prototype appeared at the Winter Consumer Electronics Show in January 1977. A Commodore technical-support bulletin on ROM genealogy says that “when the PET-2001 first went into production in September 1977” it shipped with the ROM set “known as BASIC 1.0”. The first hundred units went out in mid-October 1977, mostly to magazines and developers.

That first version, Commodore BASIC 1, is the oldest Microsoft 6502 BASIC known to survive. Steil’s analysis lists what Commodore changed from Microsoft’s generic code:

  • No Microsoft name anywhere. The start-up screen says *** COMMODORE BASIC *** and the number of free bytes.
  • The OK prompt becomes READY.
  • New statements for files and devices: OPEN, CLOSE, PRINT#, INPUT#, CMD and VERIFY.
  • SYS, which jumps to machine code. Microsoft’s code had only the USR function.
  • All machine-specific I/O goes through the separate KERNAL jump table.

Commodore also patched the BASIC 1 binary directly. According to Steil, several patch routines were appended to the ROM image, including a fix to the garbage collector.

BASIC 2 and the WAIT 6502 easter egg

In 1979 Commodore shipped upgraded PET ROMs. Commodore’s bulletin says the upgrade “corrected an intermittent bug in the edit software and improved the garbage collection routines”, and a later set fixed “a bug limiting the dimensions on arrays”. Jim Butterfield, quoted by Steil, said Commodore paid Microsoft an extra fee for this revision.

The revision also carried something Commodore had not asked for. Typing WAIT 6502,1 on an upgraded PET prints MICROSOFT! in the top-left corner of the screen; larger second arguments repeat it. The ten characters are stored backwards, with junk in their upper bits, just after the coefficient table for SIN(), and the routine writes them straight into PET screen memory at $8000. In the original 1978 Microsoft source, the symbol for the hidden routine is purged from the listing after the second assembler pass, which suggests Microsoft meant it to escape Commodore’s notice.

Version numbering is inconsistent for this period. Steil and most later sources call the 1979 upgrade BASIC 2, but Commodore’s own bulletin counts “BASIC 2.0” and “BASIC 3.0” as separate PET ROM sets before BASIC 4.0. The PET banner itself does not show a number.

BASIC 4.0

The PET/CBM 4000 series of 1980 brought BASIC 4.0. It added disk commands to the language itself (DLOAD, DSAVE, DIRECTORY, SCRATCH, COPY and others), plus the DS and DS$ variables for reading the drive’s error channel. Commodore’s bulletin says the release “greatly improved the garbage collection”, and that a later 4.1 fixed errors in 4.0. The 80-column 8032 used the same BASIC.

BASIC V2 on the VIC-20 and Commodore 64

The VIC-20 went on sale in Japan (as the VIC-1001) in 1980 and elsewhere in 1981. The Commodore 64 was shown at CES in January 1982. Both were cheap home machines, and both got a BASIC V2 derived from the PET code instead of BASIC 4.0. So the C64, the best-selling machine of the family, had no disk commands, no graphics commands and no sound commands, although its VIC-II and SID chips were far more capable than the PET. Its users drove the hardware with PEEK and POKE, and a whole industry of BASIC extensions and cartridges grew up to fill the gaps.

A C64 powers up to:

1
2
3
4
5
    **** COMMODORE 64 BASIC V2 ****

 64K RAM SYSTEM  38911 BASIC BYTES FREE

READY.

BASIC 3.5 and BASIC 7.0

The Plus/4 and Commodore 16 of 1984 carried BASIC 3.5, the first version to go well beyond the Microsoft core. It added commands for graphics and sound, DO/LOOP with WHILE, UNTIL and EXIT, IF...THEN...ELSE, programmer’s tools such as AUTO, RENUMBER, DELETE, TRON and TROFF, and a MONITOR command for the built-in machine-language monitor.

The Commodore 128, introduced at CES in January 1985, shipped BASIC 7.0. This was BASIC 3.5 extended for the 128’s hardware: sprite commands and a built-in sprite editor (SPRDEF), BEGIN/BEND blocks for multi-line IF bodies, FAST and SLOW to switch the CPU clock, bank-switching commands, and GO64 to drop into Commodore 64 mode, which runs BASIC V2. The C128 was also the first Commodore machine whose start-up screen credits Microsoft ("(C)1977 MICROSOFT CORP.").

The Commodore 65 and after

The Commodore 65, developed in 1990–1991 as a successor to the C64, had a greatly extended BASIC 10. Commodore cancelled the project in 1991, reportedly on the decision of chairman Irving Gould, and it never shipped. Commodore went bankrupt in 1994, and the C64 was discontinued that April.

Design Philosophy

CBM BASIC was not designed from scratch. It is Microsoft’s portable interpreter with Commodore’s I/O model and screen editor attached, and most of its character comes from that combination:

  • BASIC is the operating system’s user interface. Commodore machines boot straight into BASIC. Loading, saving and running software are done with BASIC commands typed in direct mode, and device numbers (1 for tape, 8 and up for disk drives, 4 for printers) are passed as arguments.
  • The KERNAL does the I/O. From the first PET, BASIC calls machine-independent KERNAL routines for character and device I/O. That is why the same interpreter moved from the PET to the VIC-20 and C64 with relatively few changes.
  • Memory over speed and readability. Keywords are stored as one-byte tokens, only two characters of a variable name are significant, and experienced users typed programs without spaces to save bytes.
  • Machine code is expected. PEEK, POKE, SYS, USR and WAIT are part of the core language, and serious programs mixed BASIC with 6502 code.

Key Features

The full-screen editor

The Commodore screen editor is a big part of what makes CBM BASIC feel different from other home-computer BASICs. You can move the cursor anywhere on the screen, change a listed line in place and press RETURN to store it. A line starting with a number is tokenised into the program; any other line runs immediately. The C64’s editor works on an 80-character logical line (two 40-column screen rows).

Keyword abbreviations

Most keywords can be typed as their first letter or two followed by a shifted letter. The C64 reference guide’s table gives, for example, S + SHIFT-Y for SYS, V + SHIFT-E for VERIFY and W + SHIFT-A for WAIT, and ? for PRINT. Abbreviations save typing, not memory, because every keyword becomes the same one-byte token either way. LIST shows the full keywords, so a line entered with abbreviations can list as longer than 80 characters, and the manual warns that such a line then cannot be edited on screen without retyping it.

Data types

The C64 Programmer’s Reference Guide defines three simple variable types:

TypeWrittenRange (C64 reference guide)
RealXY±1.70141183E+38 down to ±2.93873588E-39; up to nine digits displayed
IntegerXY%-32768 to +32767, stored in two bytes
StringXY$0 to 255 characters

Arrays of any type are made with DIM. An array used without a DIM is given a default size automatically. As in other Microsoft 6502 BASICs, integer variables are converted to floating point for arithmetic, so their main use is to halve the memory of large arrays.

Talking to hardware

KeywordPurpose
PEEK(a) / POKE a,vRead or write any memory location, including the video, sound and I/O chips
SYS aCall a machine-language routine (a Commodore addition)
USR(x)Call machine code through a vector and return a number
WAIT a,m[,x]Wait until a memory location matches a bit pattern
OPEN, PRINT#, INPUT#, GET#, CMD, CLOSEDevice and file I/O through logical file numbers
ST, TI, TI$I/O status, the jiffy clock in 1/60 s ticks, and the clock as an HHMMSS string

Screen control in strings

BASIC V2 has no CLS or LOCATE. Cursor movement, colour changes, reverse video and clear-screen are control characters. You can embed them in a string by pressing the key inside quotes, where they appear as reverse-video symbols, or send them with CHR$(): PRINT CHR$(147) clears the screen. BASIC 3.5 and 7.0 added proper commands for this.

A small example (BASIC V2)

1
2
3
4
5
6
10 PRINT CHR$(147);"GUESS MY NUMBER (1-100)"
20 X=RND(-TI):N=INT(RND(1)*100)+1:T=0
30 INPUT "YOUR GUESS";G:T=T+1
40 IF G<N THEN PRINT "HIGHER":GOTO 30
50 IF G>N THEN PRINT "LOWER":GOTO 30
60 PRINT "GOT IT IN";T;"TRIES"

Line 20 seeds the random-number generator from the jiffy clock with a negative argument, a common idiom. BASIC V2 has no ELSE, so each branch is a separate IF that ends in GOTO.

The same idea in BASIC 7.0

BASIC 3.5 and 7.0 remove the need for most of those GOTOs:

1
2
3
4
5
6
10 SCNCLR:X=RND(-TI):N=INT(RND(1)*100)+1:T=0
20 DO
30 INPUT "YOUR GUESS";G:T=T+1
40 IF G<N THEN PRINT "HIGHER":ELSE IF G>N THEN PRINT "LOWER"
50 LOOP UNTIL G=N
60 PRINT "GOT IT IN";T;"TRIES"

Evolution

VersionMachinesYearMain additions
BASIC 1PET 20011977Microsoft core plus Commodore file I/O, SYS, TI$, READY. prompt
BASIC 2 (upgrade ROMs)PET 20011979Bug fixes, better garbage collection, WAIT 6502 easter egg
BASIC 4.0 / 4.1PET/CBM 4000, 80001980Disk commands, DS/DS$, much faster garbage collection
BASIC V2VIC-20, Commodore 641980–1982Derived from the PET BASIC 2 code for the low-cost home machines
BASIC 3.5Commodore 16, Plus/41984Graphics and sound, DO/LOOP, ELSE, TRON, RENUMBER, MONITOR
BASIC 7.0Commodore 1281985Sprites and SPRDEF, BEGIN/BEND, FAST/SLOW, bank switching, GO64
BASIC 10Commodore 65 (unreleased)1990–1991Palette, genlock, mouse and file-viewing commands among many others; never shipped

The CBM-II business line of 1982 also had its own extended BASIC 4 variant. It is poorly documented and left out of the table.

Current Relevance

No new hardware has shipped CBM BASIC in ROM since Commodore’s collapse, but the language is still easy to run and still in use among retro-computing hobbyists:

  • Emulators. VICE emulates the PET, VIC-20, C64, C128, Plus/4 and CBM-II and runs the original ROMs. Version 3.10 was released on 24 December 2025.
  • cbmbasic. Michael Steil’s 2008 static recompilation of C64 BASIC V2 runs .bas files from a Unix or Windows command line with pipe I/O. It is the original interpreter translated to C, not a reimplementation.
  • Reconstructed source. Steil’s msbasic project reassembles byte-exact copies of Commodore BASIC 1 and 2 (PET) from a combined source tree, and in September 2025 Microsoft published its own 6502 BASIC 1.1 source, including the Commodore target, under the MIT License.
  • MEGA65. The FPGA-based MEGA65 computer ships with BASIC 65, a fixed and extended version of the Commodore 65’s BASIC 10, so the family’s last branch finally runs on production hardware.

Why It Matters

CBM BASIC was the first programming language for a very large share of the home-computer generation, because it was what the Commodore 64 showed on power-up. Its limits shaped how people programmed. BASIC V2 had no commands for the C64’s graphics or sound, so users learned memory maps, POKE and eventually 6502 assembly, and magazines and third-party extensions such as Simons’ BASIC grew up around those gaps.

It also shows how the Microsoft BASIC business worked. Commodore took a flat-fee licence, kept the source and developed it for eight years on its own. Microsoft’s name was left off the start-up screen of every Commodore machine until the C128, and the hidden WAIT 6502 message is Microsoft’s signature in code Commodore sold under its own name.

Timeline

1976
Commodore buys MOS Technology and, according to Michael Steil's reconstruction of the code's history, licenses Microsoft's 6502 BASIC for the forthcoming PET the same autumn
1977
A PET 2001 prototype is shown at the Winter Consumer Electronics Show in January. Commodore's ROM genealogy bulletin dates PET production to September 1977, with BASIC 1.0 in ROM, and the first units ship in mid-October
1979
Commodore ships upgraded PET ROMs with a revised BASIC (usually called BASIC 2) that fixes array and garbage-collection bugs and contains Microsoft's hidden WAIT 6502 easter egg
1980
The PET/CBM 4000 series launches with BASIC 4.0, which adds disk commands such as DLOAD, DSAVE and DIRECTORY and a much faster garbage collector; the 80-column 8032 follows
1981
The VIC-20 (sold as the VIC-1001 in Japan from 1980) reaches markets worldwide with a BASIC V2 derived from the PET code
1982
The Commodore 64 is shown at CES in January and ships with BASIC V2 in ROM; its Programmer's Reference Guide calls the language 'CBM BASIC'
1984
The Plus/4 (June) and Commodore 16 ship with BASIC 3.5, the first version to add graphics and sound commands, DO/LOOP structured loops and IF...THEN...ELSE
1985
The Commodore 128 is introduced at CES in January with BASIC 7.0, the last CBM BASIC shipped in a production machine and the first whose start-up screen credits Microsoft
1991
Commodore cancels the Commodore 65 prototype and its BASIC 10
1994
Commodore goes bankrupt; the Commodore 64 is discontinued in April, ending new hardware with CBM BASIC in ROM
2008
On 28 October Michael Steil releases cbmbasic, a BSD-licensed static recompilation of Commodore 64 BASIC V2 to C that runs as a scripting language on Linux, Windows and Mac OS X
2022
The first production batch of MEGA65 computers reportedly reaches customers during 2022, running BASIC 65, a fixed and extended descendant of the Commodore 65's BASIC 10
2025
Microsoft publishes the source of Microsoft BASIC for 6502 version 1.1 on GitHub under the MIT License; the source includes the Commodore PET target

Notable Uses & Legacy

PET/CBM computers in schools and offices

The all-metal PET 4032 did well in schools, and BASIC 4.0's disk commands were aimed at the business buyers of the 4000 and 8000 series. On these machines BASIC was also the command line used to load and run software

Type-in programs for the VIC-20 and Commodore 64

Magazines such as COMPUTE!'s Gazette printed BASIC listings, often with machine code stored in DATA statements and POKEd into memory, for readers to type in at the READY. prompt

Simons' BASIC

David Simons' 1983 cartridge extension, sold by Commodore, added graphics, sprite, sound and structured-programming keywords to the Commodore 64's BASIC V2 instead of replacing it

Launching machine-code software

Because most Commodore 8-bit machines could not boot from disk, commercial programs commonly began with a one-line BASIC stub that used SYS to jump into machine code after the user typed RUN

cbmbasic scripting interpreter

Michael Steil's cbmbasic runs the original C64 BASIC V2 interpreter, recompiled to C, as a command-line tool with pipe I/O on modern operating systems

MEGA65

The FPGA-based MEGA65 boots into BASIC 65, which continues the Commodore 65's BASIC 10 line and keeps Commodore 64 compatibility through a C64 mode

Language Influence

Influenced By

Microsoft BASIC

Influenced

Simons' BASIC BASIC 65

Running Today

Run examples using the official Docker image:

docker pull
Last updated: