Advertisement

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.

Contents

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
      PASTE,CUT

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

References

  • Angerhausen et.al. (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

Navigation

Academic Kids Menu

  • Art and Cultures
    • Art (http://www.academickids.com/encyclopedia/index.php/Art)
    • Architecture (http://www.academickids.com/encyclopedia/index.php/Architecture)
    • Cultures (http://www.academickids.com/encyclopedia/index.php/Cultures)
    • Music (http://www.academickids.com/encyclopedia/index.php/Music)
    • Musical Instruments (http://academickids.com/encyclopedia/index.php/List_of_musical_instruments)
  • Biographies (http://www.academickids.com/encyclopedia/index.php/Biographies)
  • Clipart (http://www.academickids.com/encyclopedia/index.php/Clipart)
  • Geography (http://www.academickids.com/encyclopedia/index.php/Geography)
    • Countries of the World (http://www.academickids.com/encyclopedia/index.php/Countries)
    • Maps (http://www.academickids.com/encyclopedia/index.php/Maps)
    • Flags (http://www.academickids.com/encyclopedia/index.php/Flags)
    • Continents (http://www.academickids.com/encyclopedia/index.php/Continents)
  • History (http://www.academickids.com/encyclopedia/index.php/History)
    • Ancient Civilizations (http://www.academickids.com/encyclopedia/index.php/Ancient_Civilizations)
    • Industrial Revolution (http://www.academickids.com/encyclopedia/index.php/Industrial_Revolution)
    • Middle Ages (http://www.academickids.com/encyclopedia/index.php/Middle_Ages)
    • Prehistory (http://www.academickids.com/encyclopedia/index.php/Prehistory)
    • Renaissance (http://www.academickids.com/encyclopedia/index.php/Renaissance)
    • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
    • United States (http://www.academickids.com/encyclopedia/index.php/United_States)
    • Wars (http://www.academickids.com/encyclopedia/index.php/Wars)
    • World History (http://www.academickids.com/encyclopedia/index.php/History_of_the_world)
  • Human Body (http://www.academickids.com/encyclopedia/index.php/Human_Body)
  • Mathematics (http://www.academickids.com/encyclopedia/index.php/Mathematics)
  • Reference (http://www.academickids.com/encyclopedia/index.php/Reference)
  • Science (http://www.academickids.com/encyclopedia/index.php/Science)
    • Animals (http://www.academickids.com/encyclopedia/index.php/Animals)
    • Aviation (http://www.academickids.com/encyclopedia/index.php/Aviation)
    • Dinosaurs (http://www.academickids.com/encyclopedia/index.php/Dinosaurs)
    • Earth (http://www.academickids.com/encyclopedia/index.php/Earth)
    • Inventions (http://www.academickids.com/encyclopedia/index.php/Inventions)
    • Physical Science (http://www.academickids.com/encyclopedia/index.php/Physical_Science)
    • Plants (http://www.academickids.com/encyclopedia/index.php/Plants)
    • Scientists (http://www.academickids.com/encyclopedia/index.php/Scientists)
  • Social Studies (http://www.academickids.com/encyclopedia/index.php/Social_Studies)
    • Anthropology (http://www.academickids.com/encyclopedia/index.php/Anthropology)
    • Economics (http://www.academickids.com/encyclopedia/index.php/Economics)
    • Government (http://www.academickids.com/encyclopedia/index.php/Government)
    • Religion (http://www.academickids.com/encyclopedia/index.php/Religion)
    • Holidays (http://www.academickids.com/encyclopedia/index.php/Holidays)
  • Space and Astronomy
    • Solar System (http://www.academickids.com/encyclopedia/index.php/Solar_System)
    • Planets (http://www.academickids.com/encyclopedia/index.php/Planets)
  • Sports (http://www.academickids.com/encyclopedia/index.php/Sports)
  • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
  • Weather (http://www.academickids.com/encyclopedia/index.php/Weather)
  • US States (http://www.academickids.com/encyclopedia/index.php/US_States)

Information

  • Home Page (http://academickids.com/encyclopedia/index.php)
  • Contact Us (http://www.academickids.com/encyclopedia/index.php/Contactus)

  • Clip Art (http://classroomclipart.com)
Toolbox
Personal tools