|
Article on other languages:
|
Commodore BASIC, also known as PET BASIC, is the dialect of the BASIC programming language used in Commodore International's 8-bit home computer line, stretching from the PET of 1977 to the C128 of 1985. The core was based on 6502 Microsoft BASIC, and as such it shares most of the core code with other 6502 BASICs of the time, such as Applesoft BASIC.
HistoryCommodore licensed the BASIC from the young, cash-strapped Microsoft on a "pay once, no royalties" basis. It remains unclear if Microsoft actually believed that Commodore would come back for new BASIC editions for their follow-on computer projects. Instead, Commodore took the source code of the flat-fee BASIC and developed it further internally for all their other 8-bit home computers. It wasn't until the Commodore 128 (with V7.0) that a Microsoft copyright notice was displayed. However, Microsoft had built an easter egg into the original Commodore Basic that proved its provenance: typing the (obscure) command Technical detailsA very convenient feature of Commodore's ROM-resident BASIC interpreter and KERNAL was the 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 Another interesting feature was its ability to save named files to any device, including the cassette, initially a popular storage device in the days of the PET. Most systems of the era only supported filenames on diskette, which made saving multiple files on other devices more difficult, requiring making note of the recorder's counter display at the location of the file, which was inaccurate and prone to error. Most non-Commodore users solved the problem by only recording one file per tape. With the PET, when one loaded a file by name from the cassette, the cassette would start to be read and the computer would examine the filenames as they came up, skipping over the ones the user was not looking for. The file system was also supported by a powerful 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 a minute 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. Programmers also often wrote speed-critical sections of a program in 6502 assembly language and executed them from BASIC using the Commodore BASIC keywords could be abbreviated by entering at least one letter, and then a shifted version of the next letter on. In the default text mode, this shifted character appeared as a graphics symbol; e.g. the A common misconception was that less memory was needed to store such abbreviated keywords, something only true in one, almost unrelated, situation; After a program line was entered, the line would be passed to the BASIC Kernel to be tokenized, whereby each keyword, abbreviated or not, would be converted into a token, one or two bytes long, in memory. By abbreviating keywords however, it was possible to squeeze more code into a program line (line lengths were usually limited to 2 or 4 screen lines, depending on the specific machine). This allowed for a slight saving on the overhead to store otherwise necessary extra program lines, but nothing more. When Commodore BASIC lines did not need any spaces except where omitting one would be ambiguous, and in fact most Commodore BASIC programs were written with no spaces, e.g., The order of execution of Commodore BASIC lines was not determined by line numbering; instead, it followed the order in which the lines were linked in memory: much like a modern singly linked list, each program line was stored in memory as a line number, a pointer, and then the tokenized code for the line. The pointer contained address in memory of the next program line. While a program was being entered, BASIC would constantly reorder program lines in memory so that the line numbers and pointers were all in ascending order. However after a program was entered, manually altering the line numbers and pointers with the POKE commands could allow for out-of-order execution or even give each line the same line number. Variable names were only significant to 2 characters; thus the variable names The native number format of Commodore BASIC, like that of its parent MS BASIC, was 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, used MS BASIC's four-byte mantissa, which made their BASIC much more adapted for business than most other BASICs of the era. Also akin to MS BASIC, 16-bit signed integers (i.e. in the range -32768 to 32767) were available by postfixing a variable name with a percent symbol, and string variables were represented by postfixing the variable name with a dollar sign. Despite the 2 character limit on variable names, the variables Many BASIC extensions were released for the Commodore 64, due to the relatively limited capabilities of its native BASIC 2.0. One of the most popular extensions was the DOS Wedge, due to its inclusion on the Commodore 1541 Test/Demo Disk. This 1 KB extension to BASIC added a number of disk-related commands, including the ability to read a disk directory without destroying the program in memory. Its features were subsequently incorporated in various third-party extensions, such as the popular Epyx FastLoad cartridge. Other BASIC extensions added additional keywords to make it easier to code sprites, sound, and high-resolution graphics. Versions and featuresA list of CBM BASIC versions in chronological order, with successively added features: Released versions
Unreleased versions
Notable extension packages
ReferencesBASIC 2.0:
BASIC 3.5:
BASIC 7.0:
|
This article is from Wikipedia. All text is available under the terms of the GNU Free Documentation License.
Mercedes Car
This site monitored by SitePinger.net