Commodore BASIC

From Academic Kids

Commodore BASIC is the dialect of BASIC used in Commodore International's 8-bit home computer line, stretching from the PET of 1977 to the C128 of 1985. The core part was based on 6502 Microsoft BASIC, licensed from the young, cash-strapped Microsoft on a "pay once, no royalties" basis. As such it shares most of the core code with other 6502 BASICs of the time, such as Applesoft BASIC (which, like CBM BASIC, was flat-fee-licenced from Microsoft; ultimately very bad deals for MS, considering the high sales of Apple's and particularly Commodore's 8-bit home computers).

A very convenient feature of Commodore's ROM-resident BASIC interpreter and KERNAL was the brilliantly implemented full screen editor, which allowed users to input, edit, and enter direct commands as well as program lines anywhere on the screen – simply by pressing the RETURN key whenever the cursor happened to be on a line containing a valid BASIC statement. This marked a huge leap forward in program entry interfaces compared to other common home computer BASICs at the time, which typically used a separate EDIT command, or the like, to enable line editing.


Versions (in chronological order, with successively added features)

  • V1.0: PET 2001 with chiclet keyboard and built-in Datassette (original PET)
    • bug: arrays limited to 256 elements
    • bug: PEEK command won't work above memory location $C000
  • V2.0: PET 2001 with full-travel keyboard & upgrade ROMs; VIC-20; C64
    • most 1.0 bugs squashed
    • PET Easter egg – enter WAIT 6502,<x> and see what happens...
  • V4.0: PET/CBM 4000/8000 series (and late version PET 2001's)
    • disk operations: DLOAD,DSAVE,COPY,SCRATCH, etc (15 in all)
    • disk error-channel variables: DS,DS$
  • V4+ : CBM-II series (aka B, P range)
    • information to be added
  • V3.5: C16/116, Plus/4
    • sound and graphics commands
    • joystick input: JOY
    • hexadecimal conversion: DEC(),HEX$()
    • flexible DATA read: RESTORE [linenumber]
    • string search function: INSTR
    • formatted printing: PRINT USING,PUDEF
    • alternative branching: ELSE
    • structured looping: DO,LOOP,WHILE,UNTIL,EXIT
    • function key assignment: KEY (also direct mode)
    • program entry/editing: AUTO,DELETE,RENUMBER
    • dynamic error handling: TRAP,RESUME,ERR$()
    • debugging (tracing): TRON,TROFF
    • MLM entry command: MONITOR
    • C(1)16, Plus/4 Easter egg – enter SYS 52650
  • V7.0: C128
    • more sound and graphics commands, incl sprite handling
    • paddle, lightpen input: POT,PEN
    • exclusive or function: XOR
    • get variable address: POINTER
    • text mode windowing: WINDOW
    • controlled time delay: SLEEP
    • memory management: BANK,SWAP,FETCH,STASH
    • more disk operations: BOOT,BLOAD,BSAVE,DVERIFY,DCLEAR
    • CPU speed adjustment: FAST,SLOW (2 vs 1 MHz)
    • undocumented, working: RREG (read CPU registers after a SYS)
    • undocumented, non-w.: OFF,QUIT
    • C128 Easter egg – enter SYS 32800,123,45,6

Unreleased versions

  • V10 : Commodore 65 (unreleased prototype)
    • graphics/video commands: PALETTE,GENLOCK
    • mouse input: MOUSE,RMOUSE
    • text file (SEQ) utility: TYPE
    • program editing: FIND,CHANGE
    • memory management: DMA, FRE(<0>|<1>|<2>)
    • unimplemented commands: PAINT,LOCATE,SCALE,WIDTH,SET,VIEWPORT

Technical details

  • Like the original Microsoft BASIC interpreter, which it is based on, Commodore BASIC is known to be woefully slow compared to machine code. Test results have shown that copying 16 kilobytes of memory from ROM to RAM takes less than a second in machine code, but over 10 minutes in BASIC. To try to make up for the slowness of the interpreter, programmers started using various tricks to speed up execution. One idea was to store often-used integer values into variables rather than using them as literal values, as interpreting a variable name was faster than interpreting a literal number.
  • Despite what every BASIC textbook says, the order of execution of Commodore BASIC lines did not follow the line numbering. Instead it followed the order in which the lines were stored in memory. When entering code with the on-screen editor, the lines were automatically reordered to follow the line numbers, but by POKE-ing directly into the memory where the program was stored, you could mess up the line numbering, even give every line the same number! However, the same feature could also be used to renumber a program if so needed, e.g. to allow for inserting new lines between existing ones if the programmer had initially (by bad habit) used "increase by 1" line numbering.
  • Commodore BASIC tokens could be shortened by entering only the first letter, followed by a shifted version of the second letter (the shifted version appeared as a graphics symbol). The shortened token was equivalent to the full token and appeared as the full token when LIST-ing the program.
  • The native number format of Commodore BASIC, like that of its parent MS BASIC, was floating point. (All arithmetic was done using these floating point numbers; integer calculations were performed via conversion to and from floating point.) Most of the contemporary BASIC implementations used one byte for the characteristic (exponent) and three bytes for the mantissa. This led to problems in business applications since the accuracy of a floating point number using a three-byte mantissa is only about 6.5 decimal digits, and round-off error is common. Commodore, however, elected for a four-byte mantissa, which made their BASIC much more adapted for business than most other BASICs of the era.

Extensions of Commodore BASIC


  • Angerhausen (1983). The Anatomy of the Commodore 64. (For the full reference, see the C64 article.) (BASIC 2.0)
  • Jarvis, Dennis; Springer, Jim D. (1987). BASIC 7.0 Internals. Grand Rapids, Michigan: Abacus Software, Inc. ISBN 0-916439-71-2. (BASIC 7.0)de:Commodore BASIC

pl:Commodore BASIC


Academic Kids Menu

  • Art and Cultures
    • Art (
    • Architecture (
    • Cultures (
    • Music (
    • Musical Instruments (
  • Biographies (
  • Clipart (
  • Geography (
    • Countries of the World (
    • Maps (
    • Flags (
    • Continents (
  • History (
    • Ancient Civilizations (
    • Industrial Revolution (
    • Middle Ages (
    • Prehistory (
    • Renaissance (
    • Timelines (
    • United States (
    • Wars (
    • World History (
  • Human Body (
  • Mathematics (
  • Reference (
  • Science (
    • Animals (
    • Aviation (
    • Dinosaurs (
    • Earth (
    • Inventions (
    • Physical Science (
    • Plants (
    • Scientists (
  • Social Studies (
    • Anthropology (
    • Economics (
    • Government (
    • Religion (
    • Holidays (
  • Space and Astronomy
    • Solar System (
    • Planets (
  • Sports (
  • Timelines (
  • Weather (
  • US States (


  • Home Page (
  • Contact Us (

  • Clip Art (
Personal tools