Commodore BASIC: Difference between revisions

Content deleted Content added
Technical details: Abbreviating keywords did not affect the storage of programs in memory
Line 11:
It also had the capability of saving named files to any device, including the [[Compact Cassette|cassette]] – initially a popular storage device in the days of the [[Commodore PET|PET]]. Most systems of the era only supported filenames on [[diskette]], which made saving multiple files on other devices more difficult, requiring the operator to note the recorder's counter display at the ___location of the file, which was inaccurate and prone to error. Most non-Commodore users worked around the problem by only recording one file per tape. With the PET, when the user requested to load a file by name from the cassette, the device would read data sequentially, ignoring any non-matching filenames until the named file was located and read into memory. The file system was also supported by a powerful [[storage record|record structure]] that could be loaded or saved to files. Another difference between the cassette transfer implementations of the Commodore and other systems was that Commodore tapes were encoded digitally, where other manufacturers usually used a less expensive analog interface which enabled the use of a standard tape recorder, but was much less reliable.
 
Like the original [[Microsoft BASIC]] [[interpreter (programming)|interpreter]], on which it is based, Commodore BASIC is slower than native [[machine code]]. Test results have shown that copying 16 [[kilobytes]] from [[read-only memory|ROM]] to [[random-access memory|RAM]] takes less than a second in machine code, but over a minute in BASIC. To alleviateexecute thefaster slowness ofthan the interpreter, programmers started using various techniques to speed up execution. One was to store often-used integer values in variables rather than using literal values, as interpreting a variable name was faster than interpreting a literal number. Programmers alsoWhen oftenspeed wrotewas important, some programmers converted speed-critical sections of a programBASIC inprograms to [[MOS Technology 6502|6502]] assembly language and executed them from BASIC using the <code>SYS</code> command; at other times, when speed was too fast, programmers dropped back to BASIC, and polled various addresses in memory (such as $A6 for the C-64, or $D0 for the C-128, denoting size of the keyboard queue) before they could start executing again.
 
Commodore BASIC [[keyword (computer programming)|keyword]]s could be abbreviated by entering first an unshifted keypress, and then a shifted version of the next keypress. These two characters were then parsed according to a lookup table, and accepted as a substitute for typing the entire command out. However, as BASIC keywords were stored in memory as single byte tokens, this was an convenience for statement entry rather than an optimization.