Applesoft BASIC: Difference between revisions

Content deleted Content added
m WikiCleaner 0.99 - Repairing link to disambiguation page - (You can help)
Line 42:
* There was a well-documented bug in Applesoft BASIC that could actually crash the interpreter if ONERR GOTO was in effect and numerous program errors occurred. Apple provided a short assembly-language routine which could be POKEd into RAM and CALLed to ameliorate the problem to an extent. Later it was discovered by an enterprising hacker that the required code was actually in the Applesoft ROM (though it was never executed) and could be called there instead: CALL -3288 or (equivalent) 62248.<ref>[http://www.txbobsc.com/scsc/scdocumentor/ Disassembled ROM]</ref>
* Applesoft could be extended by two means: the ampersand (&amp;) command and the USR() function. These were two functions that called machine-language functions stored in memory. Routines that needed to be as fast or required direct access to arbitrary functions or data in memory could thus be called from a higher-level interpreted BASIC program. Additionally, these lower-level functions could read the data immediately following the "&" or "USR" command, allowing a BASIC program to pass parameters to the functions.
* Both Integer BASIC and Applesoft used [[tokenizing]] to reduce the memory requirements of programs and to speed their interpretation. As code was entered, BASIC keywords would be converted to single-byte tokens; the process was reversed when the program was listed. Integer BASIC used characters with codes above 127 for normal text and codes below 128 for tokens; Applesoft used exactly the reverse. Unlike Integer BASIC, Applesoft did not tokenize literal numbers appearing in the code but stored them digit by digit. As a result of the tokenizing process, programmers could not use any variable name that had the name of one of the BASIC commands (e.g. a person could not use the name "SCORE" because the "[[Or|OR]]" would invoke a [[Boolean operator]], and "BACKGROUND" could similarly not be used because "GR" would invoke the low-resolution graphics system; both would create syntax errors).
* Applesoft, like Integer BASIC before it, did not come with any built-in commands for dealing with files or disks, other than a feature to save programs to, and load programs from, [[audiotape]]. The Apple II disk operating system, known simply as DOS, thus intercepted all input typed at the BASIC command prompt to determine whether it was a DOS command. Similarly, all output was scrutinized for a Control-D character (ASCII 4), which BASIC programs would send before seemingly PRINTing a disk command to get DOS's attention (the disk commands would not really get PRINTed but were intercepted by DOS and prevented from making it to the screen output).<ref>The DOS Manual for Apple II, Apple Computer, Inc., 1980, 1981</ref> [[Apple ProDOS|ProDOS]] followed this lead, although the BASIC command interpreter was placed in a separate program called BASIC.SYSTEM and the hook worked in a different manner.<ref>Apple II ProDOS Manual, Apple Computer, Inc.</ref>
 
== Notes ==