BASIC09

Last updated
BASIC09
Designed by Motorola
Developer Microware
First appeared1980;43 years ago (1980)
Stable release
1.1.0 / January 5, 2003;20 years ago (2003-01-05)

BASIC09 is a structured BASIC programming language dialect developed by Microware on behalf of Motorola for the then-new Motorola 6809 CPU and released in February 1980. [1] It is primarily used with the OS-9 operating system, released in 1979. Microware also released a version for OS-9/68k on the 68000 as Microware BASIC. [2]

Contents

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 PACK 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 variables, 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 PROCEDURE structure which created separately executable blocks of code. Code in a PROCEDURE had more in common with complete programs in other BASICs, including the variables being local to the code, and their ability to be executed in a stand-alone fashion. PROCEDUREs were called by name using the RUN command, and could include variables for function-call semantics; for instance, RUN add(4,7) calls a procedure named add that takes two parameters. Parameters were imported into the procedure using the PARAM keyword, in this example PARAM a,b: [3]

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 LOAD procedures by name into the workspace and then call them from their own code to construct larger programs from the separately stored procedures. [4] [lower-alpha 1]

In addition to code in the workspace, if the program invokes RUN 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. [5]

In addition to RUN, other common BASIC commands likewise used names. For instance, LIST bob would print out the source code ("list") the procedure named "bob", while LIST* prints out all of the procedures currently in memory. The prettyprinted output from LIST could be redirected to a file or a printer with a shell-like notation, e.g. LIST bob >/p. One could also SAVE and LOAD procedures from storage. [6]

Structured programming

In addition to the organizational properties of the PROCEDURE, BASIC09 also included a number of extensions to the flow control statements found in BASIC to provide more structure. For instance, the IF statement could be used in the traditional IF...THEN format on a single line, or it could be used in a structured multi-line format: [7]

IF x>10 THEN   PRINT "x is larger than 10" ELSE  PRINT "x is smaller than 10" ENDIF

FOR/NEXT loops naturally have a structured format as the NEXT can be placed on any line, but BASIC09 also added WHILE/ENDWHILE and REPEAT/UNTIL for additional clarity when working with non-indexed loops. [8] It also included the center-exit LOOP/ENDLOOP which used the EXITIF statement for testing anywhere in the loop's body. [9]

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 packed into bytes, a single BOOLEAN used an entire 8-bit byte to store a single value. The language provided separate bytewise boolean operators for bitwise operations on BYTEs and INTEGERs. [10] 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 DIM for definitions; for instance, DIM a,b:BOOLEAN to declare two BOOLEAN variables, or DIM c(5):INTEGER for an array of five INTEGERs. [11]

Additionally, BASIC09 included the TYPE keyword, which allowed compound types to be defined, with each "element" listed on a single line separated by semicolons. For instance: [12]

TYPE employee_record=name:STRING;number(2):INTEGER;former:BOOLEAN

defines an employee record type named employee_record with three elements, name, number and former. The employee_record type can now be used in a definition like any other type, for instance, DIM employees(100):employee_record, which defines an array of 100 employee_record's. The elements are accessed in code using dot notation, for instance, employees(50).name="Bob". [12]

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 GOTO or GOSUB, 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 + and - 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. [13]

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 LISTed. [14] BASIC09 allowed multiple statements on a single line of code, but used the \ as a separator instead of the : used in most dialects. [15] [lower-alpha 2] This is because it used the colon in the := assignment operator, which was in addition to the normal =. := was identical in effect to =, but made the difference between assignments and comparisons more obvious. [16]

Compiler

The internal multipass compiler converts BASIC09 source code into a tokenized, optimized, bytecode, called I-code. [17] 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. [18]

For instance, in MS-based interpreters, a variable reference in code is left in string format; the variable VAR 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. [17]

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. [17] Other optimizations include a separate FOR/NEXT routine used when the index variable is an INTEGER, and separate INTEGER and REAL math libraries. [18] [lower-alpha 3]

For added performance, BASIC09 also included the PACK 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, PACK would recognize that LET x=x+SQR(100)/2 contains only constants on the right, and replaces it with the code x=x+5, which requires only a single operation at runtime, the addition, removing the division and square root. PACK reduced the memory footprint of the procedure and improved performance by about 10 to 30%. [19]

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. [20]

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. [20]

Significant features

See also

Notes

  1. The 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.
  2. The colon was being used for the data type in the DIM statements.
  3. 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.

Related Research Articles

<span class="mw-page-title-main">Motorola 6809</span> 8-bit microprocessor

The Motorola 6809 ("sixty-eight-oh-nine") is an 8-bit microprocessor with some 16-bit features. It was designed by Motorola's Terry Ritter and Joel Boney and introduced in 1978. Although source compatible with the earlier Motorola 6800, the 6809 offered significant improvements over it and 8-bit contemporaries like the MOS Technology 6502, including a hardware multiplication instruction, 16-bit arithmetic, system and user stack registers allowing re-entrant code, improved interrupts, position-independent code and an orthogonal instruction set architecture with a comprehensive set of addressing modes.

Pascal is an imperative and procedural programming language, designed by Niklaus Wirth as a small, efficient language intended to encourage good programming practices using structured programming and data structuring. It is named after French mathematician, philosopher and physicist Blaise Pascal.

OS-9 is a family of real-time, process-based, multitasking, multi-user operating systems, developed in the 1980s, originally by Microware Systems Corporation for the Motorola 6809 microprocessor. It was purchased by Radisys Corp in 2001, and was purchased again in 2013 by its current owner Microware LP.

Microware Systems Corporation was an American software company based in Clive, Iowa, that produced the OS-9 real-time operating system.

<span class="mw-page-title-main">Atari BASIC</span> Dialect of the BASIC programming language

Atari BASIC is an interpreter for the BASIC programming language that shipped with the Atari 8-bit family of 6502-based home computers. Unlike most American BASICs of the home computer era, Atari BASIC is not a derivative of Microsoft BASIC and differs in significant ways. It includes keywords for Atari-specific features and lacks support for string arrays, for example.

Microsoft BASIC is the foundation software product of the Microsoft company and evolved into a line of BASIC interpreters and compiler(s) adapted for many different microcomputers. It first appeared in 1975 as Altair BASIC, which was the first version of BASIC published by Microsoft as well as the first high-level programming language available for the Altair 8800 microcomputer.

Integer BASIC is a BASIC interpreter written by Steve Wozniak for the Apple I and Apple II computers. Originally available on cassette for the Apple I in 1976, then included in ROM on the Apple II from its release in 1977, it was the first version of BASIC used by many early home computer owners.

Sinclair BASIC is a dialect of the programming language BASIC used in the 8-bit home computers from Sinclair Research, Timex Sinclair and Amstrad. The Sinclair BASIC interpreter was written by Nine Tiles Networks Ltd.

BASIC-PLUS is an extended dialect of the BASIC programming language that was developed by Digital Equipment Corporation (DEC) for use on its RSTS/E time-sharing operating system for the PDP-11 series of 16-bit minicomputers in the early 1970s through the 1980s.

<span class="mw-page-title-main">Vilnius BASIC</span> Dialect of the BASIC programming language

Vilnius BASIC, sometimes known as BK BASIC, is a dialect of the BASIC programming language running on the Elektronika BK-0010-01/BK-0011M and UKNC computers. It was developed at Vilnius University, located in Lithuania which was a republic of the Soviet Union at the time.

<span class="mw-page-title-main">CMS-2</span>

CMS-2 is an embedded systems programming language used by the United States Navy. It was an early attempt to develop a standardized high-level computer programming language intended to improve code portability and reusability. CMS-2 was developed primarily for the US Navy’s tactical data systems (NTDS).

HP Time-Shared BASIC is a BASIC programming language interpreter for Hewlett-Packard's HP 2000 line of minicomputer-based time-sharing computer systems. TSB is historically notable as the platform that released the first public versions of the game Star Trek.

The computer programming languages C and Pascal have similar times of origin, influences, and purposes. Both were used to design their own compilers early in their lifetimes. The original Pascal definition appeared in 1969 and a first compiler in 1970. The first version of C appeared in 1972.

thinBasic is a BASIC-like computer programming language interpreter with a central core engine architecture surrounded by many specialized modules. Although originally designed mainly for computer automation, thanks to its modular structure it can be used for wide range of tasks.

Systems Programming Language, often shortened to SPL but sometimes known as SPL/3000, was a procedurally-oriented programming language written by Hewlett-Packard for the HP 3000 minicomputer line and first introduced in 1972. SPL was used to write the HP 3000's primary operating system, Multi-Programming Executive (MPE). Similar languages on other platforms were generically referred to as system programming languages, confusing matters.

Charm is a computer programming language devised in the early 1990s with similarities to the RTL/2, Pascal and C languages in addition to containing some unique features of its own. The Charm language is defined by a context-free grammar amenable to being processed by recursive descent parser as described in seminal books on compiler design.

SUPER BASIC, sometimes SBASIC for short, is an advanced dialect of the BASIC programming language offered on Tymshare's SDS 940 systems starting in 1968 and available well into the 1970s.

<span class="mw-page-title-main">BASIC interpreter</span> Interpreter that enables users to enter and run programs in the BASIC language

A BASIC interpreter is an interpreter that enables users to enter and run programs in the BASIC language and was, for the first part of the microcomputer era, the default application that computers would launch. Users were expected to use the BASIC interpreter to type in programs or to load programs from storage.

Wang BASIC is a series of BASIC programming languages for computers from Wang Laboratories. The term can be used to refer to the BASIC on any Wang machine, but is mostly associated with the versions on the Wang 2200 minicomputer series of the early 1970s. When these machines were updated to the VP series in 1976, BASIC-2 was introduced and remained the pattern for future machines in the 2200 series. A planned BASIC-3 was never released.

BASIC-8, is a BASIC programming language for the Digital Equipment (DEC) PDP-8 series minicomputers. It was the first BASIC dialect released by the company, and its success led DEC to produce new BASICs for its future machines, notably BASIC-PLUS for the PDP-11 series. DEC's adoption of BASIC cemented the use of the language as the standard educational and utility programming language of its era, which combined with its small system requirements, made BASIC the major language during the launch of microcomputers in the mid-1970s.

References

Citations

  1. Manual 1984, p. 1.2.
  2. "BASIC09". Geneslinuxbox.net:6309. Retrieved 2016-11-27.
  3. Manual 1984, p. 5.1.
  4. Manual 1984, p. 3.5.
  5. Manual 1984, p. 9.12.
  6. Manual 1984, p. 2.9.
  7. Manual 1984, p. 9.4.
  8. Manual 1984, p. 9.6-9.7.
  9. Manual 1984, p. 9.8.
  10. Manual 1984, pp. 7.2–7.6.
  11. Manual 1984, p. 7.6.
  12. 1 2 Manual 1984, p. 7.8.
  13. Manual 1984, p. 2.3.
  14. Manual 1984, p. 2.5.
  15. Manual 1984, p. 9.1.
  16. Manual 1984, p. 9.2.
  17. 1 2 3 Manual 1984, p. 11.1.
  18. 1 2 Manual 1984, p. 11.2.
  19. Manual 1984, p. 11.3.
  20. 1 2 Manual 1984, p. D.1.
  21. 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

Bibliography

[1] [2] [3] [4]

  1. Advert: BASIC09 has a dual personality., 68 Micro Journal, Volume 04 Number 01, Published:January 1982
  2. 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".
  3. 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.
  4. 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.