Acorn System BASIC

Last updated
Acorn System BASIC
Developer Acorn Computers
First appeared1979;45 years ago (1979)
License Proprietary
Dialects
Atom BASIC
Influenced
BBC BASIC

Acorn System BASIC and Atom BASIC are two closely related dialects of the BASIC programming language developed by Acorn Computers for their early microcomputers like the Acorn System 3 and Acorn Atom. Developed in-house, they have a number of significant idiosyncrasies compared to most BASIC dialects of the home computer era.

Contents

In particular, the language lacked statements for many of the machine's internal functions and provided this using direct access and manipulation of memory locations using indirection operators instead of PEEK and POKE. Both also lacked floating-point support, although this could be added with an optional ROM which introduced further idiosyncrasies. System and Atom BASIC differ primarily in that Atom used the same indirection system to provide rudimentary string manipulation, which Standard lacked, and added a small number of new statements for computer graphics.

Most of these oddities were removed when the underlying system was greatly expanded to produce BBC BASIC on the Atom's successor, the BBC Micro. BBC BASIC ROMs were later offered to Atom users.

History

Hermann Hauser uses Atom BASIC at the BBC Micro 30th anniversary. Hermann Hauser using Acorn Atom 2012.jpg
Hermann Hauser uses Atom BASIC at the BBC Micro 30th anniversary.

Acorn Computers formed in 1978 and got its start making a series of kit-built and Eurocard-based systems starting with the Acorn System 1 in 1979. They developed Acorn System BASIC for these machines, [1] an integer-only dialect that required only 4 KB of memory in total. [2] The language had a number of implementation details that made it "highly non-standard." [3]

The Atom, introduced in 1980, was built from parts of the System 3 packaged onto a single board. Systems shipped standard with 2 KB of RAM and 8 KB of ROM, which included BASIC and a number of device drivers. Atom BASIC had only a few changes from the System version, adding support for string manipulation and a small number of graphics commands. The Atom was upgradable, with up to 12 KB of RAM in total and an additional 4 KB of ROM that added floating-point support. This used separate functions and operations that worked on them, indicated by the % symbol. [3] This choice of symbol was unfortunate, as Microsoft BASIC used the percent sign to indicate integers, not floating point. [4]

The Atom was on the market for only a short period before Acorn began development of its successor, the Proton. This was initially to be a two-processor unit. The design was still in its earliest stages when a series of events led to it being selected as the basis of the single-CPU BBC Micro. [1] At the time, there were comments that it should definitely not use Acorn's variety of BASIC, which "virtually no other microcomputer can understand" and that "If the new language were based on the Atom's form of BASIC, it would be a disaster." [5]

Ultimately, the BBC system did use those older Acorn-written BASIC variants, but heavily modified. The resulting BBC BASIC was much more similar to Microsoft BASIC and was later offered as an upgrade to the Atom. [6]

Description

As the two dialects are very similar, the following will refer to Atom BASIC primarily and point out differences where they exist.

Program editing

Like most BASICs of the era, Atom BASIC used a line-oriented editor with direct (immediate) and indirect modes. Typing in a statement without a line number performed the operation immediately. Adding a line number instead placed those statements in the stored program. One idiosyncrasy was that while it allowed multiple statements on a single line, the separator between statements was the semicolon [7] instead of the commonly used colon, thus requiring the user to convert that character when typing in programs for other computers.

Intended for use with computer terminals, Acorn BASIC did not support a full-screen editing mode. For contrast, in Commodore BASIC (and many other microcomputer dialects), one can use the cursor keys to move upward into a program listing, make changes on-screen, and then press Return to enter those changes. On the Atom, which had a full-screen display, one could move upward into a listing using the cursor keys, but to edit that text, the Copy key was pressed to copy it to the input area where it could be edited. [8]

Another difference on the Atom was the Break key, which performed a system reset, potentially clearing out the program from memory. To reset this if the key was pressed by mistake, Atom BASIC added the OLD command, which could also be used to reset an accidental NEW. A more minor change was that LIST used comma-separated to and from line numbers instead of the minus sign, LIST 20,40 prints out lines 20 to 40. [9]

The language also had the ability to use line labels instead of numbers for branching. Labels consisted of a single lower-case letter typed immediately after the line number. For instance: [10]

10s PRINT "*" 20 GOTO s

The advantage of this method is that the memory address of the statement is stored in s, meaning that the branch, a GOTO, can move directly to that line without having to search through every line in the program looking for the matching line number. [10] Acorn also allowed any expression to be used to produce the line number for branch targets, like GOSUB 500+(A*10). [11]

Statements

Acorn's primitives were similar to other BASICs of the era, and supported most of the elementary statements like CLEAR, DIM, END, FOR..TO..STEP..NEXT, GOSUB, GOTO, IF..THEN, INPUT, (optional) LET, LIST, LOAD, PRINT, REM, RETURN, RUN, SAVE, STOP. [12] There are a number of common statements that are missing, notably DATA, READ, RESTORE used to store data in a program, ON..GOSUB, ON..GOTO computed branches, and DEF FN for user-defined functions. [a]

To these basics, Acorn added DO..UNTIL for the construction of bottom-tested, expression-based loops. FOR loops are highly optimized by using a direct comparison between their index variable and a constant value that is set only once upon entry into the loop. Another optimization is that the address of the FOR is stored, not the line number, so when the matching NEXT is encountered the program can immediately branch back to the FOR. While FOR is suitable for many loops, when more control is needed, for instance when comparing against a more complex criterion, the IF statement may be used:

500 A=A+1 510 REM additional statements here 600 IF A>10 AND B>100 THEN 500

The downside to this style of loop is that the branch requires the program to be searched through for line 500, which, in a loop, normally happens many times. In large programs, this can introduce significant overhead. Using a DO for this purpose offers higher performance:

500 DO A=A+1 510 REM additional statements here 600 UNTIL A>10 AND B>100

In this case, like the FOR loop, the address of the DO is stored when the loop is entered, allowing the UNTIL to return to the top of the loop immediately without having to scan through the program. [14] Note the special case that the DO can be followed directly by another statement without the semicolon separator being required - the A=A+1 is not part of the DO, it is a separate statement. [15]

Among the more minor additions is the WAIT statement, which paused execution until the next clock tick, every 160 of a second. This does not wait for one entire tick, just until the next tick, which may happen immediately. [14] LINK calls a machine language routine, [16] the analog of CALL or SYS in most dialects. [17]

Math, operators and functions

Acorn used 32-bit signed integers for all math, [18] with no standard floating-point support. To handle division, which often returns a fractional part, they added the % operator to return the remainder. For instance, PRINT 7/3 will return 2, while PRINT 7%3 will return 1. [19]

Variable names can consist only of a single letter, A to Z. [20] All double-letter combinations are reserved as arrays, so E was a single value, while EE was an array. All arrays required a DIM statement, [21] it did not assume a dimension of 10 like Microsoft BASICs. At runtime, the only check performed on an array was that the index being passed in was a positive value, so one could read off into memory by passing in values larger than the dimension. [22] It did not support multi-dimensional arrays. [23]

Basic math operations included +, -, *, /, %. It also supported bitwise logic operators, with &, \, : used for AND, OR and XOR, respectively. These operators perform comparisons, so 1 & 0 returns 0. The use of the colon for OR [b] is why the statement separator had to use the semicolon. [24] Note that these are separate from the logical connections found in IF statements, like IF A=1 AND B=0 THEN..., which are also supported. [25]

There were only two math functions, ABS and RND. ABS works as in other BASICs, returning the absolute value of a given input. RND does not, it returns a value between the -ve and +ve maximum integer values. To use this in the conventional form to return a value between 0 and a given positive value, between 0 and 10 for example, one used ABS(RND)%11. [26]

Vectors

Most BASICs of the era used PEEK and POKE to access machine specific functionality that was not built into the language itself. Acorn did not have PEEK and POKE, and used new operators to provide this functionality in an easier-to-use system. The operators were ? and !, the former setting or returning the byte at a given location, and the latter setting or returning a 4-byte "word". [27] For instance, common examples of PEEK in most dialects, like PRINT PEEK(4000), could be accomplished with PRINT ?4000. [28] Most dialects lacked the equivalent of the !. [c] Moreover, the same syntax could be used to set the value in memory, like a POKE, for instance, ?4000=200. [28]

To aid in accessing data arranged in a continual form in memory, like arrays of numbers, the operators could be applied to the right-hand side of a variable. When used in this way, like A?, the system accessed the memory at the variable's location in memory. Any number following the operator was applied as an offset, so for instance, A?100 would return the value of the byte 100 locations after the location of A in memory. [28]

This was often used with another Acorn-only concept, the "vector". Confusingly, these were created using the same DIM commands as an array, but applied to single-letter variables. When the DIM was encountered the system would set aside that many locations at the top of memory, and then move the memory pointer up. This left a block of memory that could then be accessed with the indirection operators. For instance: [28]

10 DIM A(100) 20 PRINT A?10

Which will print the byte value at the 11th location in A (all accesses are zero-indexed). [28] Likewise, one could store values in memory using the same operator applied before the variable name:

!A=123456

This will convert the decimal value 123456 from ASCII into an integer and store it in the memory locations starting at the base location for A. [27]

To aid operation with vectors, Acorn added the pseudo-variable TOP. When the system first started up, it pointed to the first location past the end of the program. Any DIMs were then created at the current value of TOP, and TOP was then updated to the end of the new object. It was possible to create dynamic vectors by directly manipulating TOP. [30]

Strings

Atom BASIC added string support but did not support string variables nor did it have the concept of a string as an atomic type. Instead, the vector system was used to manipulate string data in memory, as ASCII values. [28] To aid this usage, the $ operator converted in-memory values to their ASCII values. This operator continued reading data from memory until it encountered a return, and when writing data to memory, always added a return at the end. [31] So while PRINT ?A would print the single value of the byte at A's location in memory as a number, PRINT $A would read the values starting at that location and print it as a string. [31] For instance:

10 DIM A(12) 20 $A="HELLO, WORLD" 30 PRINT $A

This code may appear very similar to the use of strings in other dialects, although the location of the $ relative to the variable name changes. It is especially similar to those dialects that required a DIM on all strings, like HP Time-Shared BASIC or Atari BASIC. Internally, the operation is very different. In those dialects, A and A$ are two different variables and the $ is, in effect, part of the name. In Acorn, A and $A they are the same variable, and the $ is applying a unary operation to that variable. This also means one can use arrays for strings, like $AA(10), which converts the value in AA(10) to a string. [3]

This concept allows individual characters to be accessed using vector notation. For instance, A?5 would return the ASCII value of the 5th character, 79 for O in this case, while PRINT $A?5 would output "O". [32] There is no way to extract a substring in a single operation, one has to loop over the characters and move them one-by-one. Concatenation is possible by assigning one variable to the end of another, for instance, $A+LEN(A)=$B copies the string B to the end of A. [33]

The language has only two string functions, LEN which looks for the trailing return character and returned the length, and CH to return the ASCII value of a character. CH has an odd format with no parens, so CH"A" would return 65. [32] It is otherwise similar to the more common ASC seen in other dialects. [34]

Another new operator was #, which converted a numeric value into a hexadecimal string. Like $, this could be used anywhere to perform the conversion. For instance, A=#4000 sets the value of A to the decimal value 16384, the location of the screen memory. This was often combined with the $ operator to allow strings to contain unprintable characters, like the "cursor up" character. [8]

Floating point

Floating-point support could be added with the additional 4 KB ROM expansion. This used an expanded 40-bit word size, 32 bits of signed mantissa followed by an 8-bit exponent. [35] This meant the system needed some way to distinguish the data when reading and writing from memory, which was handled in a fashion similar to the string operator, using the % prefix: [35]

 %A=123.45

As the code was contained in a separate 4 KB ROM, it did not modify existing statements like PRINT. Instead, an entirely new set of statements was introduced, including FDIM, FIF, FINPUT, FPRINT, FUNITL. This means, for instance, that one cannot IF A=B if the values are floating point, one must instead FIF A=B THEN.... An integer value can be converted to float using the FLT, and float to integer using the float operator, %. [27]

The ROM also included a much larger variety of math functions, including ABS, ACS, ASN, ATN, COS, DEG, EXP, FLT, HTN, LOG, PI, RAD, SGN, SIN, SQR, STR, TAN, VAL. [36] STR converted a floating-point number into a string, as was the case for STR$ in other dialects, but in this case, the string was written to memory and the function returned the address where it was stored. As the string required storage long enough to hold it, this was often accomplished using TOP. For instance:

 STR PI, TOP  PRINT $TOP  TOP=TOP-LEN(TOP)

This converts the value of the pseudo-variable PI to a string starting at memory location TOP, prints the string using $TOP, and then abandons that memory. [37]

Input/output

PRINT and INPUT mostly worked as in other dialects. One oddity came about because the colon and semicolon were already used for other purposes, leaving only the comma to separate fields. To print values with no spaces between them, the values were listed with a space character between them, like PRINT A B C, a format that was also allowed on many other dialects although rarely used. This alone would not cause numbers to be printed in compact format, because they are normally printed with spaces on the right to make each one 8 characters wide This could be adjusted by changing the value in the @ pseudo-variable. [38] A newline was printed with a single quote, PRINT "HELLO" ' "WORLD". [27] COUNT returns the cursor column, similar to POS in most dialects. [39]

The default storage device for the Atom was a compact cassette system. Each file was stored as a series of blocks, each of which contained a header with the filename. [40] Files saved with SAVE THISFILE could be read back in with LOAD THISFILE, whilst *CAT listed the names of the files on the cassette as it read past their headers. [41]

Arbitrary data could be opened for reading using FIN or writing with FOUT, both of which returned a numeric file handle. Files were closed with SHUT. Data was read or written in numeric format using GET, PUT, as single bytes with BGET, BPUT, and as strings using SGET, SPUT. The EXT returned the length of the file, while PTR returned or set the current pointer in the file, [16] the number of bytes read or written so far. [42] If the floating-point ROM was present, it added FGET, FPUT. [36]

For instance:

A=FOUT"AFILE" DO BPUT A,88; WAIT; WAIT; WAIT; WAIT; UNTIL 0

Will use the BPUT to write a series of bytes, 88s, until the user presses Escape to stop the program. They can then be read back in (after manually rewinding the tape) using: [43]

A=FIN"AFILE" DO PRINT $BGET A; UNTIL 0

The dollar sign tells the system to convert the incoming binary data to string format, so in this case, the output will be a series of X's, not 88's. [43] It might seem that SGET could be used instead of BGET, but this would attempt to continue reading from the file until it saw a return character, which in this example had not been written. [44]

Graphics support

The Atom had rudimentary bitmap graphics and Atom BASIC added a number of commands to support it. CLEAR cleared the screen, MOVE moved the graphical cursor to the given X,Y location, and DRAW drew a line from the current location to the provided X,Y. [45]

The floating-point ROM also included support for colour graphics with the addition of the COLOUR statement. Calling COLOUR with a parameter 0 through 3, sets the subsequent output to that colour. On a black-and-white display, the colours were shown as shades of grey. [46]

Notes

  1. A good source for what was already considered the standard for BASICs of the microcomputer era is the introduction to BASIC Computer Games , which introduces the statements it uses and speaks of exceptions to "normal BASIC". [13]
  2. Likely because it looks like a vertical bar, which is used in most math texts for OR.
  3. Various advanced dialects like Turbo-BASIC XL included commands like DPEEK for "double peek", returning a 16-bit value. These are similar in concept to !. [29]

Related Research Articles

Applesoft BASIC is a dialect of Microsoft BASIC, developed by Marc McDonald and Ric Weiland, supplied with Apple II computers. It supersedes Integer BASIC and is the BASIC in ROM in all Apple II series computers after the original Apple II model. It is also referred to as FP BASIC because of the Apple DOS command FP used to invoke it, instead of INT for Integer BASIC.

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

<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 Atari 8-bit 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.

<span class="mw-page-title-main">Acorn Atom</span> Acorn Computers home computer, 1980–1982

The Acorn Atom is a home computer made by Acorn Computers Ltd from 1980 to 1982, when it was replaced by the BBC Micro. The BBC Micro began life as an upgrade to the Atom, originally known as the Proton.

<span class="mw-page-title-main">PEEK and POKE</span> Commands in some high-level programming languages

In computing, PEEK and POKE are commands used in some high-level programming languages for accessing the contents of a specific memory cell referenced by its memory address. PEEK gets the byte located at the specified memory address. POKE sets the memory byte at the specified address. These commands originated with machine code monitors such as the DECsystem-10 monitor; these commands are particularly associated with the BASIC programming language, though some other languages such as Pascal and COMAL also have these commands. These commands are comparable in their roles to pointers in the C language and some other programming languages.

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.

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

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.

Color BASIC is the implementation of Microsoft BASIC that is included in the ROM of the Tandy/Radio Shack TRS-80 Color Computers manufactured between 1980 and 1991. BASIC is a high level language with simple syntax that makes it easy to write simple programs. Color BASIC is interpreted, that is, decoded as it is run.

<span class="mw-page-title-main">ZX Spectrum character set</span>

The ZX Spectrum character set is the variant of ASCII used in the ZX Spectrum family computers. It is based on ASCII-1967 but the characters ^, ` and DEL are replaced with ↑, £ and ©. It also differs in its use of the C0 control codes other than the common BS and CR, and it makes use of the 128 high-bit characters beyond the ASCII range. The ZX Spectrum's main set of printable characters and system font are also used by the Jupiter Ace computer.

Level I BASIC is a dialect of the BASIC programming language that shipped with the first TRS-80, the TRS-80 Model I.

SCELBAL, short for SCientific ELementary BAsic Language, is a version of the BASIC programming language released in 1976 for the SCELBI and other early Intel 8008 and 8080-based microcomputers like the Mark-8. Later add-ons to the language included an extended math package and string handling. The original version required 8 kB of RAM, while the additions demanded at least 12 kB.

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.

References

Citations

  1. 1 2 Gazzard 2016, p. 22.
  2. Oddy.
  3. 1 2 3 Lien 1981, p. 425.
  4. Lien 1981, p. 396.
  5. BBC 1981, p. 662.
  6. Fruits 1982, p. 11.
  7. Johnson Davies 1979, p. 14.
  8. 1 2 Johnson Davies 1979, p. 65.
  9. Johnson Davies 1979, p. 7.
  10. 1 2 Johnson Davies 1979, p. 25.
  11. Johnson Davies 1979, p. 26.
  12. Johnson Davies 1979, pp. 3–4.
  13. Ahl, David (1978). BASIC Computer Games. Workman. p. XII.
  14. 1 2 Johnson Davies 1979, p. 37.
  15. Johnson Davies 1979, p. 35.
  16. 1 2 Lien 1981, p. 427.
  17. Lien 1981, p. 43.
  18. Johnson Davies 1979, p. 67.
  19. Johnson Davies 1979, p. 11.
  20. Johnson Davies 1979, p. 12.
  21. Johnson Davies 1979, p. 45.
  22. Johnson Davies 1979, p. 50.
  23. Johnson Davies 1979, p. 51.
  24. Johnson Davies 1979, p. 15.
  25. Johnson Davies 1979, p. 30.
  26. Johnson Davies 1979, p. 24.
  27. 1 2 3 4 Lien 1981, p. 426.
  28. 1 2 3 4 5 6 Johnson Davies 1979, p. 53.
  29. Fetzer, Ron (1985). Expanded Turbo-BASIC XL Documentation (PDF).
  30. Johnson Davies 1979, p. 46.
  31. 1 2 Johnson Davies 1979, p. 58.
  32. 1 2 Johnson Davies 1979, p. 59.
  33. Johnson Davies 1979, p. 61.
  34. Lien 1981, p. 45.
  35. 1 2 Johnson Davies 1979, p. 162.
  36. 1 2 Johnson Davies 1979, p. 161.
  37. Johnson Davies 1979, p. 163.
  38. Johnson Davies 1979, p. 13.
  39. Lien 1981, p. 73.
  40. Johnson Davies 1979, p. 10.
  41. Johnson Davies 1979, p. 9.
  42. Johnson Davies 1979, p. 151.
  43. 1 2 Johnson Davies 1979, p. 8.
  44. Johnson Davies 1979, p. 152.
  45. Johnson Davies 1979, p. 28.
  46. Johnson Davies 1979, p. 167.

Bibliography