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
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!
{{Infobox programming language | name = BASIC09 | year = {{Start date and age|1980}} | designer = [[Motorola]] | developer = [[Microware]] | latest release version = 1.1.0 | latest release date = {{Start date and age|2003|01|05}} | implementations = | influenced_by = | influenced = | typing = | dialects = | paradigm = | logo = | operating_system = | license = | website = | file_ext = }} '''BASIC09''' is a structured [[BASIC programming language]] dialect developed by [[Microware]] on behalf of [[Motorola]] for the then-new [[Motorola 6809]] [[central processing unit|CPU]] and released in February 1980.{{sfn|Manual|1984|p=1.2}} It is primarily used with the [[OS-9]] [[operating system]], released in 1979. Microware also released a version for OS-9/68k on the [[Motorola 68000|68000]] as '''Microware BASIC'''.<ref>{{cite web|url=http://geneslinuxbox.net:6309/gene/nitros9/3rdparty/packages/basic09/ReadMe.b09 |title=BASIC09 |website=Geneslinuxbox.net:6309 |access-date=2016-11-27}}</ref> In contrast to typical BASICs of the era, BASIC09 includes a multi-pass [[compiler]] that produces compact [[bytecode]] known as '''I-code'''. I-code replaces a number of data structures found in other BASICs with direct pointers to code and values, speeding performance. Users can further compile code using the <code>PACK</code> command, at which point it can be called directly by OS-9 and operated as native code. In the case of PACKed code, a cut-down version of the BASIC09 [[runtime system]] is used, '''Runb''', further improving [[memory footprint]] and load time. The language includes a number of [[structured programming]] additions, including [[local variable]]s, the ability to ignore line numbers in favor of named routines, user-defined structures, and several distinct base data types including 16-bit and 8-bit (byte) integers, in addition to floating point and strings. ==Syntax== ===Program organization=== A key difference between BASIC09 and conventional BASICs of the era, like the canonical [[Microsoft BASIC]], is the addition of the <code>PROCEDURE</code> structure which created separately executable blocks of code. Code in a <code>PROCEDURE</code> had more in common with complete programs in other BASICs, including the variables being [[local variable|local]] to the code, and their ability to be executed in a stand-alone fashion. <code>PROCEDURE</code>s were called by name using the <code>RUN</code> command, and could include variables for function-call semantics; for instance, <code>RUN add(4,7)</code> calls a procedure named <code>add</code> that takes two parameters. Parameters were imported into the procedure using the <code>PARAM</code> keyword, in this example <code>PARAM a,b</code>:{{sfn|Manual|1984|p=5.1}} PROCEDURE add PARAM a,b PRINT a+b A side-effect of the use of named procedures is that the resulting memory workspace is, in effect, its own namespace. In this respect, the BASIC09 system appears to the user to be a directory of callable programs. This contrasts with typical BASICs, where only one program is available at a given time and the construction of larger programs calling library-like code generally requires the [[source code]] to be copied and pasted between separate programs. In BASIC09, the user can <code>LOAD</code> procedures by name into the workspace and then call them from their own code to construct larger programs from the separately stored procedures.{{sfn|Manual|1984|p=3.5}}{{efn|The [[GRASS (programming language)|GRASS]] system was similar in that its BASIC-like language could be assembled from separate named procedures, but did so by leaving everything as untokenized source code, as opposed to pre-compiling as in BASIC09.}} In addition to code in the workspace, if the program invokes <code>RUN</code> with a procedure name that could not be found, it would then look for a disk file with the same name and load and run that file. This worked not only with BASIC09 code, but also any other executable program, including [[machine language]] files. This meant that BASIC09 could easily call system routines.{{sfn|Manual|1984|p=9.12}} In addition to <code>RUN</code>, other common BASIC commands likewise used names. For instance, <code>LIST bob</code> would print out the source code ("list") the procedure named "bob", while <code>LIST*</code> prints out all of the procedures currently in memory. The prettyprinted output from <code>LIST</code> could be redirected to a file or a printer with a shell-like notation, e.g. <code>LIST bob >/p</code>. One could also <code>SAVE</code> and <code>LOAD</code> procedures from storage.{{sfn|Manual|1984|p=2.9}} ===Structured programming=== In addition to the organizational properties of the <code>PROCEDURE</code>, BASIC09 also included a number of extensions to the [[flow control (data)|flow control]] statements found in BASIC to provide more structure. For instance, the <code>IF</code> statement could be used in the traditional <code>IF</code>...<code>THEN</code> format on a single line, or it could be used in a structured multi-line format:{{sfn|Manual|1984|p=9.4}} IF x>10 THEN PRINT "x is larger than 10" ELSE PRINT "x is smaller than 10" ENDIF <code>FOR/NEXT</code> loops naturally have a structured format as the <code>NEXT</code> can be placed on any line, but BASIC09 also added <code>WHILE/ENDWHILE</code> and <code>REPEAT/UNTIL</code> for additional clarity when working with non-indexed loops.{{sfn|Manual|1984|p=9.6-9.7}} It also included the center-exit <code>LOOP/ENDLOOP</code> which used the <code>EXITIF</code> statement for testing anywhere in the loop's body.{{sfn|Manual|1984|p=9.8}} ===Data types=== BASIC09 included several built-in data types. In addition to the traditional string (STRING) and 40-bit floating point (REAL) types found in most BASICs of the era, it also included the 16-bit signed INTEGER, the 8-bit unsigned BYTE, and the logical BOOLEAN type. The BOOLEAN types were not [[Data structure alignment|packed]] into bytes, a single BOOLEAN used an entire 8-bit byte to store a single value. The language provided separate bytewise [[boolean function|boolean operators]] for bitwise operations on BYTEs and INTEGERs.{{sfn|Manual|1984|pp=7.2-7.6}} In contrast to other BASICs that also operated different base types, BASIC09 did not "decorate" the variable name to indicate the type, and instead used the <code>DIM</code> for definitions; for instance, <code>DIM a,b:BOOLEAN</code> to declare two BOOLEAN variables, or <code>DIM c(5):INTEGER</code> for an array of five INTEGERs.{{sfn|Manual|1984|p=7.6}} Additionally, BASIC09 included the <code>TYPE</code> keyword, which allowed compound types to be defined, with each "element" listed on a single line separated by semicolons. For instance:{{sfn|Manual|1984|p=7.8}} TYPE employee_record=name:STRING;number(2):INTEGER;former:BOOLEAN defines an employee record type named <code>employee_record</code> with three elements, <code>name</code>, <code>number</code> and <code>former</code>. The employee_record type can now be used in a definition like any other type, for instance, <code>DIM employees(100):employee_record</code>, which defines an array of 100 employee_record's. The elements are accessed in code using dot notation, for instance, <code>employees(50).name="Bob"</code>.{{sfn|Manual|1984|p=7.8}} ==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}} ==Significant features== * reasonably structured control flow provisions (e.g., line numbers were mainly needed for computed <code>[[GOTO]]</code>, as BASIC09 did not have a switch/case statement, or computed <code>[[GOSUB]]</code>) * structure declaration (rare in any BASIC variant then; more common in later BASIC implementations) * intrinsic integer and [[Boolean data type]]s * more than two significant characters in variable names (some BASICs of the time allowed only one, many [[Microsoft BASIC]] variants allowed only two) * procedures with local variables (indeed, ''all'' variables in BASIC09 are local to procedures) and parameter passing by reference * a reasonable [[debug]]ger (its only significant drawback was that one could not examine the contents of fields in structures) * a way to interface to [[machine language]] code, which could be passed parameters using the BASIC09 calling sequence * automatic [[prettyprint]]ing of source, which enforced a standard layout and avoided the ghastly mess that was the usual appearance of a program of any size in the interpreted BASICs of the time. Programmers normally would cram as many lines together as possible to avoid line number memory overhead—not a problem in BASIC09<ref>[https://archive.org/stream/68micro-vol-09-num-04/V09N04_Apr1987#page/n15/mode/1up Basically OS-9], By Ron Voigts, 68 Micro Journal, Volume 09 Number 04, April 1984, Page 14, ''One of its strong features is its handling of formatted output. Other languages vary in how well they can handle the formatted output. But BASIC09 can do a very nice job of putting your lines into a form that you want''</ref> ==See also== * [[COMAL]] was another BASIC-like language with structured programming constructs ==Notes== {{notelist}} ==References== ===Citations=== {{Reflist|30em}} ===Bibliography=== * {{cite book |url=http://www.colorcomputerarchive.com/coco/Documents/Manuals/Programming/BASIC09%20Programming%20Language%20Reference%20Manual%20-%20Revision%20H%20(Microware%20System%20Corp).pdf |title=BASIC09 Programming Language Reference Manual |date=1984 |ref=CITEREFManual1984 }} * {{cite web |url=http://archive.worldofdragon.org/index.php?title=OS-9_Basic_09 |title=OS-9 Basic 09 - The Dragon Archive |website=Archive.worldofdragon.org |date=2016-05-07 |access-date=2016-11-27}} <ref>[https://archive.org/stream/68micro-vol-04-num-01/V04N01_Jan1982#page/n7/mode/1up Advert: BASIC09 has a dual personality.], 68 Micro Journal, Volume 04 Number 01, Published:January 1982</ref><ref>[http://aaronwolfe.com/coco/earlyos9/page4.html Early OS-9 History, select content from 68 Micro Journal], ''December 1980, Microware changes their 6809 ad slightly. Basic09 is now called "The Basic09 Programming Language System" by Microware rather than "Motorola Basic09".''</ref><ref>[https://groups.google.com/d/msg/comp.os.os9/sQhKg7XKf7A/nSvzSMqjkrEJ newsgroups: comp.os.os9, From: Colin McKay, Subject: Re: OS/2 vs. W95 and OS-9, Date: 1995/04/12, summary: Excerpts from Microware History in OS-9 Users Group Newsletter], ''MICROWARE NEW PRODUCT NEWSLETTER April 1979., Thank you for your inquiry about our line of 6800 family hardware and software products. We are in the process of introducing some new software so our 1979 catalog will not be ready for some time. In the interim we are presenting new product information in this newsletter. 6809 SOFTWARE. Motorola contracted Microware to produce the finest possible software for the 6809. The new software we have prepared for Motorola includes a new BASIC language system plus an operating system. This software will be available soon from Motorola and Microware.''</ref><ref>[http://www.ciphersbyritter.com/AUTHOR.HTM About the Author], ''Terry Ritter, ..Software...FORMERLY: Staff Engineer, Motorola MOS Division, Microcomputer Systems Design Group, Jul. 1976 - Jan. 1981. ... Architect of structured BASIC language for 6809. Software Engineer, 1979-81 .... Originator and Supervising Project Engineer -- BASIC09, 1978-80, A structured BASIC language project, with operating system OS9 and associated specifications.''</ref> ==External links== * [http://aaronwolfe.com/coco/earlyos9/page3.html Early OS-9 History, select content from 68 Micro Journal], September 1980, '''first review of OS-9 and Basic09, sent in by Tom Harmon of HHH Enterprises''' * [http://www.os9projects.com/Tutorials/OS9Books/Basic09TG.html The Official Basic09 Tour Guide], Dale L. Puckett, 1985, {{ISBN|0-918035-00-7}}, Cat No.: 26-3189 * [http://geneslinuxbox.net:6309/gene/nitros9/3rdparty/packages/basic09/ReadMe Package: Basic09 1.1.0 / Release Date: January 5, 2003] {{Webarchive|url=https://web.archive.org/web/20160304055421/http://geneslinuxbox.net:6309/gene/nitros9/3rdparty/packages/basic09/ReadMe |date=March 4, 2016 }}, ''This release of Basic09 for the Tandy Color Computer 1/2/3 represents the first community-based release since the discontinuation of the CoCo in the 1980s''. [[Category:TRS-80 Color Computer]] [[Category:BASIC interpreters]]
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)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Cite book
(
edit
)
Template:Cite web
(
edit
)
Template:Efn
(
edit
)
Template:ISBN
(
edit
)
Template:Infobox programming language
(
edit
)
Template:Notelist
(
edit
)
Template:Reflist
(
edit
)
Template:Sfn
(
edit
)
Template:Tt
(
edit
)
Template:Webarchive
(
edit
)