Commodore BASIC

from Wikipedia, the free encyclopedia
Typical office application in Commodore BASIC on the CBM 3032
Screenshot of the Commodore BASIC V2 on the C64

Commodore BASIC is a dialect of the BASIC programming language that was used in Commodore's 8-bit home computers - starting in 1977 with the PET 2001 up to the C128 in 1985. A version intended for the C65 was added later, but it was no longer completed. The BASIC was based on 6502 - Microsoft BASIC , which was licensed by Microsoft for a one-time payment. Some other BASICs for 6502 computers, such as Applesoft BASIC , are based on the same code base and are therefore very similar.

Special properties

A particular from the perspective of the time advantage of the ROM built-in Commodore BASIC interpreter was compared to those of other manufacturers of integrated, so-called full-screen editor ( "full screen editor"), of a comfortable editing programs or immediate execution of commands without awkward EDITcommands, copy cursor functions, ESCAPE key sequences or other detours made possible. The editor could also combine several screen lines into one program line; the maximum usable number of screen lines per program line was model-dependent. Program lines are partially compiled by pressing the Enter key ("Return") - the editor translates any keywords found into tokens of only one byte in length - and then stored in the linked list of lines in the working memory in the correct position based on the line number . When the program is output using LIST, these tokens are expanded again.

In the first versions the system was strongly cassette-oriented: The interpreter contained functions for controlling the "Commodore Datassette ".

Commodore BASIC works with line numbers in the range from 0 to 63999. Commands for structured programming were as good as nonexistent in the first versions. The program flow is controlled by the commands GOTO, GOSUB/ RETURN, IF... THEN(without ELSE) and ON... GOTO/ ON... GOSUB, which expect line numbers as jump destinations. Only the loop command FOR/ NEXTwas a semi-structured instruction.

Well-known data types are 40-bit floating point numbers , 16-bit integers and character strings with variable lengths of up to 255 characters. Simple variables do not have to be declared; they begin to exist when they are used. They are named with a letter or a letter followed by another letter or number; further alphanumeric characters can follow, but are ignored, so that for example LACH and LABER denote the same variable LA. Most programs therefore do not use variable names longer than two characters. The $ ( dollar sign ) and% ( percent sign ) suffixes turn a variable that would normally hold a floating point number into a character string and an integer, respectively. However, since all calculations are carried out in floating point format and all simple variables require the same amount of memory, the execution was not accelerated by integer variables, but actually slowed down, which is why they were rarely used. Arrays can be declared using the DIM statement; Integer variables are useful as arrays, since in this case they only occupy 40 percent of the memory that is required for an equally large floating point array. The interpreter stores character strings one after the other in the main memory. Deleted strings are not removed immediately. For lack of memory is a garbage collection (English garbage collection ) is started, which could take several minutes for excessive use of strings and the user was often suspect a system crash. Later versions from 4.0 onwards save back pointers with the character strings, which make unnecessary character strings immediately recognizable and allow the automatic garbage collection to run in fractions of a second.

The function PEEKand the commandPOKE enable direct reading or direct manipulation of the main memory; however, due to the different memory structure, this usage is not compatible between the different models. Especially with the early BASIC versions 1.0 and 2.0, various system-related functions for which there were no separate commands can only be used with these commands. The SYS command and the USR function are available for working with programs in machine language .

Versions (chronologically, with the respective new properties)

V1.0

Version V1.0 for PET 2001 with “Mickey Mouse” keyboard

  • Bug: Arrays were limited to 256 elements
  • Bug: The PEEK function does not work for addresses above $ C000 (should prevent reading of the ROMs)
  • Strange: In the text mode of the screen, the shift key works the other way round, unpressed results in uppercase letters, pressed down lowercase letters.

V2.0

Version V2.0 for PET 2001 with typewriter keyboard and ROM upgrade, CBM 3000 series , VC 20 , C64

  • Most bugs from V1.0 fixed
  • PET / CBM only: Integrated RAM monitor called TIM for displaying and manipulating the RAM
  • PET / CBM only: Easter Egg : If you enter WAIT 6502,x (insert any number for x), the word appears x times MICROSOFT!on the screen.
  • Keyboard function with respect to the shift key normalized compared to V1.0
  • IEEE-488 support
  • Improved garbage collection

V4.0

Version V4.0 for CBM 4000, 8000 series and later PET 2001

  • Disk commands: DLOAD, DSAVE, COPY, SCRATCH, etc. (15 in total)
  • System variables for diskette error channel: DS, DS$(DS contains the error number, DS $ the error message in plain text)
  • Since this version required more ROM memory, an additional ROM socket ($ Bxxx) was permanently occupied compared to the PET 2001, so that only two free sockets were available for expansion and the ROM capacity grew to 18 KB.

Version V4.0 + for CBM-II series (CBM 500, 6x0, 7x0)

  • Use of the extended address space by means of bank switching :BANK
  • Additional disk commands: BLOAD, BSAVE, DCLEAR
  • String search function: INSTR
  • Formatted printing: PRINT USING,PUDEF
  • Alternative command execution: ELSE
  • Function key assignment: KEY
  • Additional editor command: DELETE
  • Dynamic error handling: TRAP,DISPOSE,EL,ERR$(),RESUME

V3.5

Version V3.5 for Commodore 264 series ( C16 , C116 , Plus / 4 )

  • Sound and graphics commands
  • Joystick query:JOY
  • Hexadecimal conversion:DEC(),HEX$()
  • More flexible data reading: RESTORE [linenumber]
  • String search function: INSTR
  • Formatted printing: PRINT USING,PUDEF
  • Alternative command execution: ELSE
  • Additional loop commands: DO,LOOP,WHILE,UNTIL,EXIT
  • Function key assignment: KEY
  • Additional editor commands: AUTO,DELETE,RENUMBER
  • Dynamic error handling: TRAP,RESUME,ERR$()
  • Debugging :TRON,TROFF

V7.0

Version V7.0 for C128

  • Included the extensions of both version 4.0 and 3.5.
  • Multi-line IF: BEGIN, BEND
  • More sound and graphics commands, as well as sprite control
  • Paddle and light pen query:POT, PEN
  • Function for exclusive or :XOR
  • Determination of a variable address: POINTER
  • Text window: WINDOW
  • Pause command: SLEEP
  • Use of the two system speeds: SLOW, FAST
  • Switching to C64 mode: GO64
  • Use of the extended address space by means of bank switching :BANK
  • Using a memory extension ( REU ):STASH, FETCH, SWAP
  • Additional disk commands: BOOT, BLOAD, BSAVE, DVERIFY, DCLEAR
  • System commands: RREG(determines the content of the CPU register after a SYS)
  • Defined but not implemented commands: OFF, QUIT

V10

Version V10 for C65

  • Not finished, lots of bugs
  • Similar to version 7.0
  • Using the genlock function:GENLOCK
  • Mouse commands:MOUSE, RMOUSE
  • Displaying a SEQ file on the screen: TYPE
  • Search / replace in the source code: FIND/CHANGE
  • Memory management: extended FREfunction for determining the free memory
  • Color definition: PALETTE
  • Command for DMA operations:DMA
  • Defined but not implemented commands: PAINT, PASTE, CUT, LOCATE, SCALE, WIDTH, QUIT, OFF, SET, VIEWPORT

Individual evidence

  1. User's Reference Manual - Commodore BASIC Version 4.0. First Edition, Commodore Business Machines, Santa Clara July 1980, online at Commodore.ca, accessed on January 27, 2017 (PDF; 521 kB, English).
  2. Microsoft BASIC 6502 timeline. Timeline BASIC 1975–1982, online at Weihenstephan.org, accessed on January 27, 2017 (PDF; 37 kB, English).
  3. C128 System Guide: Section 3 .
  4. Bill Gates' Personal Easter Eggs in 8 Bit BASIC. pagetable.com, accessed March 4, 2014 .
  5. Commodore technical support bulletin