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!
==Runtime== ===Editing=== Line numbers were used in most BASIC dialects primarily as a way to support the editor. Users would edit particular lines of code by typing a number, with the text following either adding to or replacing the lines already in memory. As every line of code had a number, this also made them suitable for indicating the target of a <code>GOTO</code> or <code>GOSUB</code>, compared to other languages like [[FORTRAN]] where a separate "line label" was used for this purpose. BASIC09 did not normally use line numbers, so its editor had to be modified to allow the user to edit lines without referring to them by number. However, BASIC09 did not assume any sort of full-screen capability, so using [[cursor keys]] was not an option. Instead, the system had a separate editor prompt and allowed the user to move about using the {{tt|+}} and {{tt|-}} keys, moving forward or backward one line at a time. To insert a new line of code without a line number, the user left a blank at the start of the statement.{{sfn|Manual|1984|p=2.3}} Note that the language is [[case sensitive]] for user-provided values like procedure and variable names, but not for keywords. Keywords typed into the editor in lower case will be shown in upper case when the program is <code>LIST</code>ed.{{sfn|Manual|1984|p=2.5}} BASIC09 allowed multiple statements on a single line of code, but used the {{tt|\}} as a separator instead of the {{tt|:}} used in most dialects.{{sfn|Manual|1984|p=9.1}}{{efn|The colon was being used for the data type in the <code>DIM</code> statements.}} This is because it used the colon in the <code>:=</code> assignment operator, which was in addition to the normal <code>=</code>. <code>:=</code> was identical in effect to <code>=</code>, but made the difference between assignments and comparisons more obvious.{{sfn|Manual|1984|p=9.2}} ===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}} ===Lightweight runtime=== Although it was common to run programs within the BASIC09 environment, as it was in other BASICs, BASIC09 also shipped with a separate run-only version of the code known as Runb. Runb removed the editing and debugging features of the system, and was about half the size of the full BASIC09 as a result.{{sfn|Manual|1984|p=D.1}} The purpose of Runb was primarily to run PACKed modules when called from other programs. This meant that if the user typed in the name of a BASIC09 module in the OS/9 command line, and that module has been marked as PACKed, it is opened and run by Runb instead of the BASIC09. This reduces memory footprint and improves load time.{{sfn|Manual|1984|p=D.1}}
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)