BASIC-PLUS

Last updated
BASIC-PLUS
Paradigm imperative
First appeared1970;53 years ago (1970)
OS RSTS/E
Influenced by
Dartmouth BASIC, Tymshare SUPER BASIC
Influenced
Microsoft BASIC

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.

Contents

BASIC-PLUS was based on BASIC-8 for the TSS/8, [1] itself based very closely on the original Dartmouth BASIC. BASIC-PLUS added a number of new structures, as well as features from JOSS concerning conditional statements and formatting. In turn, BASIC-PLUS was the version on which the original Microsoft BASIC was patterned. [2]

Notable among the additions made to BASIC-PLUS was the introduction of string functions like MID$ and LEFT$, in addition to Dartmouth's original all-purpose CHANGE command. In future versions of the language, notably Microsoft's, CHANGE was removed and BASIC-PLUS's string functions became the only ways to perform these sorts of operations. Most BASICs to this day follow this convention.

The language was later rewritten as a true compiler as BASIC-Plus-2, and was ported to the VAX-11 platform as that machine's native BASIC implementation. This version survived several platform changes, and is today known as VSI BASIC for OpenVMS.

Operation

Users would sit at a terminal and type in programming language statements. The statements could either be entered into the system's command interpreter directly, or entered into a text editor, saved to a file, and loaded into the command interpreter from the file. Errors in source code were reported to the user immediately after the line was typed.

As a smart terminal with cursor control could not be guaranteed, BASIC-PLUS used the common system of prefixing all source code with a line number. The code was edited by typing in the number and then changing the contents of the following code. A line of code could be removed by typing in its line number and nothing else, thereby setting it to an empty line.

The virtual address space of an RSTS/E user was limited to a little less than 64KB of space. Using BASIC-PLUS, about half of this virtual address space was used by the combined command interpreter and run-time library (named the Run Time System on RSTS/E). This limited user programs to about 32 kB of memory.

Large programs were broken into separate executable pieces by use of the CHAIN statement, and programs could chain to specific line numbers in a secondary program to indicate that a program should begin execution at a different point from its first line. This feature of chaining to a certain line number allowed programs to signal to each other that they were being called from another program. The use of a shared memory section called core common also allowed programs to pass data to each other as needed. Disk files could also be used but were slower.

To conserve memory, the system included a garbage collecting memory manager, used for both string data and byte-code.

A running program could be interrupted, have variables examined and modified, and then be resumed.

Syntax and features

BASIC-PLUS is patterned closely on later versions of Dartmouth BASIC, including its powerful MAT commands. On top of this, DEC added a number of unique flow-control structures.

Editing

Line numbers were positive integers from 1 to 32767. [3] Logical lines of code could be continued on multiple physical lines by using a line feed at the end of a line instead of the normal carriage return character. [4] For ease of external editing of the source file, later versions of BASIC-PLUS also allowed the & character as a line continuation character.

Multiple statements could be placed on a single line using : as the statement separator. [4] The system allowed tabs to be used as inline whitespace, and was used to make loops more clear, as in modern languages. [5] Comments used either the REM keyword or the ! character, [6] as opposed to MS BASICs, which used REM and '.

Standard statements

The PRINT command divided the screen into regions 14 spaces wide, and the comma was used to move between these locations; PRINT 1,2,3 would output 1, 2 and 3 in a spaced-out fashion, [7] while PRINT 1;2;3 would leave a single space and produce "1 2 3". [8] [lower-alpha 1] INPUT allowed a prompt string to be specified, but used the semicolon to separate it rather than the comma; INPUT"WHAT IS THE VALUE";A. [9]

Strings could be delimited by single or double quotes. [10] In addition to the CHR and ASCII functions that converted single characters to and from string format, [11] BASIC-PLUS also supported Dartmouth's CHANGE command. CHANGE iterated the string and returned each character's ASCII value as a slot in a numeric array. For instance, CHANGE 'HELLO' TO X would return an array with the five ASCII codes, 110, 105, 114, 114, 105, in elements 1 through 5, and the number 5, the length of the string, in element 0. [12] One could reverse the operation as well, CHANGE X TO A$ would read the individual numbers in the X array and convert it to a string. [13]

Statement modifiers

BASIC-PLUS added the concept of "statement modifiers", JOSS-like conditions that could be applied to any statement. For instance, PRINTIIFI<>10 is the equivalent of IFI<>10THENPRINTI [14] The opposite was also provided, PRINTIUNLESSI=10 was the equivalent of IFI<>10THENPRINTI. [15]

FOR loops worked as in other versions of BASIC, and the NEXT command could not be used in an expression to exit early. [16] Instead, the UNTIL and WHILE keywords could be used to control early exits. For instance, FORI=1UNTILI=10 continue looping until I=10, with the assumption that following code would set the value of I, [17] meaning it might not exit after 10 iterations but as soon as the code set I to 10. [18] Modifiers could also be used to build compact one-line loops, for instance, X=X+1WHILEX<100 would loop until X was 100. [19]

Variables, expressions and matrixes

Variable names in the early versions of BASIC-PLUS could be a single letter or a single letter followed by a single digit. [5] With the inclusion of "Extend mode" in later versions, variable names could be up to 29 characters long, and dot (.) was added as a permitted character. Every variable name still had to begin with a letter. [lower-alpha 2] As in most versions of BASIC, the LET keyword, for variable assignment, was optional. It could set multiple variables to a single value, like LETA,B,C=10. [20]

The language supported three data types; floating-point numbers, integers, and strings. Variables with no suffix were floating point (8 bytes, range 0.29×10−38 to 1.7×1038, up to 16 digits of precision). Integer variables (16-bit, range 32768 to +32767) were indicated with a % suffix, [21] string variables (variable length) were indicated with a $ suffix. [10]

The list of mathematical and logical operators was typical of most BASICs, with some extensions. For math, +, -, *, / and ^ were supported, along with ** as an alternate form of ^ for computer terminals that might not have that character. Standard logical comparisons were =, <, >, <=, >=, and <>. One interesting addition was the == operator, for "approximately equal". This would return true if the two numbers would be printed the same, that is, their six most significant digits were the same. [22] Logical operators included the typical NOT A, A AND B and A OR B, along with A XOR B, A EQV B which return true if both A and B are true or both are false, and A IMP B which is false if A is true and B is false and otherwise always true. [23]

The DIM statement could allocate one-dimensional and two-dimensional arrays of any of the three data types. The range of subscripts always began with 0 (but MAT statements did not set elements in row 0 or column 0). [24] [25]

The language also included a number of MAT commands to work with the entire array (or MATrix). The MAT READ command would fill the matrix with values in a DATA statement, [26] MAT INPUT would fill the array with user-typed values, and MAT PRINT would print out the elements in a 1D or 2D format. [27] MAT could also be used to set default values in a matrix using associated keywords, for instance, MAT A=ZER would fill the A array with zeros. [28] TRN would transpose an entire matrix, and INV would invert it. [29] Additionally, +, -, and * could be used on matrixes, performing the associated matrix operation. [30]

File processing

The DIM# "virtual DIM" statement could map "virtual data array(s)" or "virtual array(s)" to a disk file, which allowed arrays larger than the computer's available memory (or even its address space), and allowed use of array elements to read, write, and extend disk files (persistent storage). They called this arrangement "virtual data storage" and "virtual core", but it did not use the modern approach of allocating the arrays and a memory-mapped file. Instead, a single buffer was used to store 512 bytes of data at a time, and when an entry in the virtual array was accessed, the corresponding data was read, and old data written, as required. The CLOSE statement caused the buffer to be written back (if necessary) before closing the file. Because no additional sectors were cached, accessing data in the "wrong" order could multiply the number of disk accesses. Additional rules were imposed on virtual arrays, such that one datum could never span a record boundary: Each data type was aligned to a multiple of its size. Virtual strings were stored as fixed-length ASCIIZ data, with sizes restricted to 2, 4, 8, 16, 32, 64, 128, 256, or 512 bytes, and were accessed using LSET and RSET. [31]

Virtual machine

BASIC-PLUS was not an interpreter but a compile and go system: each line of BASIC was translated into "PPCODE" (Push-Pop Code) as it was entered, for subsequent fast execution on its virtual machine. These translations did not tokenize the BASIC lines but rewrote them for use on a stack machine; you could not translate these representations back to BASIC statements. This avoided the need to repeatedly decode the keywords as strings: once converted to PPCODE the keywords were numbers that pointed to routines to run that function. BASIC-PLUS included a COMPILE command, but this was not a true compiler; this simply saved the program's PPCODE representation so that it did not have to be recompiled when the BASIC program was next loaded into memory. The system stored a user's program in two formats. One was the editable source code in text format, created using the SAVE command and normally placed in a .BAS file. The other was the PPCODE version of the program created by the COMPILE command and saved to a .BAC file; .BAC files were smaller and loaded and ran faster, but could not be edited. [32]

BASIC Plus 2

A related product called Basic Plus 2 ("BP2" or BASIC-Plus-2), was later developed by DEC to add additional features and increased performance.

It used true compilation into threaded code and wrote its output to object files compatible with the machine code object files produced by the assembler and other language systems. These object files could be kept in libraries. A linker (the TKB, also known as the taskbuilder) then created executable files from object files and the libraries. TKB also supported overlays; this allowed individual routines to be swapped into the virtual address space as needed, overlaying routines not currently being used.

Additionally, BP2 programs ran under the RSX Run Time System; this RTS only occupied 8KB of the user's virtual address space, leaving 56KB for the user's program. [33] (RSTS/E version 9 introduced separate Instruction and Data space, and the "disappearing" RSX Run Time System, permitting up to 64KB of each of instruction code and data.) These two factors allowed individual BP2 programs to be much larger than BASIC-PLUS programs, often reducing the need for CHAINing among multiple programs.

Unlike BASIC-PLUS (which was only available on RSTS/E), BP2 was also available for the RSX-11 operating system. BP2 programs were also more compatible with the later VAX BASIC.

Comparison to MS BASIC

Microsoft BASIC was patterned very closely on BASIC-PLUS. [2] Earlier versions of MS BASIC, the 1.x series, lacked integer variables, but these were added in the 2.x series that was found on many machines, including the later models of the Commodore PET and Commodore 64. The ability to place logical and loop commands in-line, like I = I + 1 UNTIL I = 10 was not copied over and does not appear on any common version of microcomputer BASIC. MS BASIC also lacked the matrix commands.

See also

Notes

  1. The space in front of the numbers was left for a possible minus sign, this was the standard in almost all BASICs
  2. Before the introduction of Extend mode, white space was not required between variables and other language elements: FOR I=STOP would be interpreted as FORI=STOP.

Related Research Articles

<span class="mw-page-title-main">BASIC</span> Family of programming languages

BASIC is a family of general-purpose, high-level programming languages designed for ease of use. The original version was created by John G. Kemeny and Thomas E. Kurtz at Dartmouth College in 1963. They wanted to enable students in non-scientific fields to use computers. At the time, nearly all computers required writing custom software, which only scientists and mathematicians tended to learn.

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. 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.

Tiny BASIC is a family of dialects of the BASIC programming language that can fit into 4 or fewer KBs of memory. Tiny BASIC was designed in response to the open letter published by Bill Gates complaining about users pirating Altair BASIC, which sold for $150. Tiny BASIC was intended to be a completely free version of BASIC that would run on the same early microcomputers.

<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.

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.

<span class="mw-page-title-main">RSTS/E</span> Computer operating system

RSTS is a multi-user time-sharing operating system developed by Digital Equipment Corporation for the PDP-11 series of 16-bit minicomputers. The first version of RSTS was implemented in 1970 by DEC software engineers that developed the TSS-8 time-sharing operating system for the PDP-8. The last version of RSTS was released in September 1992. RSTS-11 and RSTS/E are usually referred to just as "RSTS" and this article will generally use the shorter form. RSTS-11 supports the BASIC programming language, an extended version called BASIC-PLUS, developed under contract by Evans Griffiths & Hart of Boston. Starting with RSTS/E version 5B, DEC added support for additional programming languages by emulating the execution environment of the RT-11 and RSX-11 operating systems.

Commodore BASIC, also known as PET BASIC or CBM-BASIC, is the dialect of the BASIC programming language used in Commodore International's 8-bit home computer line, stretching from the PET (1977) to the Commodore 128 (1985).

Dartmouth BASIC is the original version of the BASIC programming language. It was designed by two professors at Dartmouth College, John G. Kemeny and Thomas E. Kurtz. With the underlying Dartmouth Time Sharing System (DTSS), it offered an interactive programming environment to all undergraduates as well as the larger university community.

MBASIC is the Microsoft BASIC implementation of BASIC for the CP/M operating system. MBASIC is a descendant of the original Altair BASIC interpreters that were among Microsoft's first products. MBASIC was one of the two versions of BASIC bundled with the Osborne 1 computer. The name "MBASIC" is derived from the disk file name MBASIC.COM of the BASIC interpreter.

VSI BASIC for OpenVMS is the latest name for a dialect of the BASIC programming language created by Digital Equipment Corporation (DEC) and now owned by VMS Software Incorporated (VSI). It was originally developed as BASIC-PLUS in the 1970s for the RSTS-11 operating system on the PDP-11 minicomputer. It was later ported to OpenVMS, first on VAX, then Alpha, and most recently Integrity.

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.

IBM System/34 BASIC was an interpreter for the IBM System/34 midrange computer.

IBM System/36 BASIC was an interpreter for the IBM System/36 midrange computer.

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.

Data General Extended BASIC, also widely known as Nova Extended BASIC, was a BASIC programming language interpreter for the Data General Nova series minicomputers. It was based on the seminal Dartmouth BASIC, including the Fifth Edition's string variables and powerful MAT commands for matrix manipulation. In contrast to the compile-and-go Dartmouth BASIC, Extended BASIC was an interpreter.

SDS BASIC, also known as CP-V BASIC, Batch BASIC or Sigma BASIC depending on the version, is a BASIC programming language compiler for Scientific Data Systems's (SDS) Sigma series mainframe computers, originally released in 1967. Xerox purchased SDS in 1969 and began rebranding it as Xerox Data Systems, and finally just Xerox, at which time the language became known as Xerox BASIC.

<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.

Full BASIC, sometimes known as Standard BASIC or ANSI BASIC, is an international standard defining a dialect of the BASIC programming language. It was developed by the American National Standards Institute (ANSI) X3.60 group in partnership with the European ECMA. It describes an advanced version of BASIC with many features including structured programming, matrix math, input/output for file handling, and many other options.

CALL/360:BASIC was an IBM dialect of the BASIC programming language for the System/360 and later platforms. It was based on mid-1960s versions of Dartmouth BASIC but added a number of extensions. Most of these were related to file handling, which, at that time, Dartmouth lacked. It also added support for the mathematical symbols found on some IBM terminals, so that <= could be entered directly as . Differences are otherwise minor.

References

Citations

  1. Bell, C. Gordon; Mudge, J. Craig; McNamara, John N. (1978). Computer Engineering: A DEC View of Hardware Systems Design (PDF). Digital Press. ISBN   0-932376-00-2.
  2. 1 2 Manes, Stephen (1993). Gates. Doubleday. p. 61. ISBN   9780385420754.
  3. PLUS 1972, p. 2-1.
  4. 1 2 PLUS 1972, p. 2-3.
  5. 1 2 PLUS 1972, p. 2-6.
  6. PLUS 1972, p. 3-1.
  7. PLUS 1972, p. 3-7.
  8. PLUS 1972, p. 3-8.
  9. PLUS 1972, p. 3-10.
  10. 1 2 PLUS 1972, p. 5-2.
  11. PLUS 1972, p. 5-12.
  12. PLUS 1972, p. 5-5.
  13. PLUS 1972, p. 5-7.
  14. PLUS 1972, p. 8-17.
  15. PLUS 1972, p. 8-18.
  16. PLUS 1972, p. 3-19.
  17. PLUS 1972, p. 8-14.
  18. PLUS 1972, p. 8-15.
  19. PLUS 1972, p. 8-20.
  20. PLUS 1972, p. 3-3.
  21. PLUS 1972, p. 6-1, 6-2.
  22. PLUS 1972, p. 2-9.
  23. PLUS 1972, p. 2-10.
  24. PLUS 1972, p. 3-21.
  25. PLUS 1972, p. 5-3.
  26. PLUS 1972, p. 7-2.
  27. PLUS 1972, p. 7-3.
  28. PLUS 1972, p. 7-5.
  29. PLUS 1972, p. 7-7.
  30. PLUS 1972, p. A-1.
  31. PLUS 1972, p. 9-17.
  32. "BASIC-PLUS inline operators, do they actually make sense?" . Retrieved 2020-08-05.
  33. BASIC V2 Reference Manual (PDF). Maynard, Massachusetts: Digital Equipment Corporation. 1991.

Bibliography