Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
BASIC09
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Compiler=== The internal multipass compiler converts BASIC09 [[source code]] into a [[Lexical analysis|token]]ized, optimized, [[bytecode]], called I-code.{{sfn|Manual|1984|p=11.1}} I-code differs from the more traditional tokenizing approach found in most BASICs in that a number of items were placed directly in memory instead of using references that then had to be looked up.{{sfn|Manual|1984|p=11.2}} For instance, in MS-based interpreters, a variable reference in code is left in string format; the variable <code>VAR</code> would be represented in memory by the three [[ASCII]] characters "VAR". During execution, when this variable is encountered in the code the interpreter has to look up that string in a table of variables, find the associated storage address in memory, and then finally read the value stored in that location. The table is usually constructed so that the value follows the name, to save time during the final lookup.{{sfn|Manual|1984|p=11.1}} In contrast, in I-code the address of the variable is determined in advance and the reference in code is replaced by that address. This avoids a runtime search through the variable table.{{sfn|Manual|1984|p=11.1}} Other optimizations include a separate <code>FOR/NEXT</code> routine used when the index variable is an INTEGER, and separate INTEGER and REAL math libraries.{{sfn|Manual|1984|p=11.2}}{{efn|Atari BASIC also worked in this way, the source code was compiled to tokens when the line was entered and any variable references replaced by a pointer to storage.}} For added performance, BASIC09 also included the <code>PACK</code> command which took a procedure name and returned an optimized version. Some of these optimizations included removing non-coding instructions like code comments and the replacement of constant expressions to a single value. For instance, <code>PACK</code> would recognize that <code>LET x=x+SQR(100)/2</code> contains only constants on the right, and replaces it with the code <code>x=x+5</code>, which requires only a single operation at runtime, the addition, removing the division and square root. <code>PACK</code> reduced the memory footprint of the procedure and improved performance by about 10 to 30%.{{sfn|Manual|1984|p=11.3}}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)