History
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 difference was that while it allowed multiple statements on a single line, the separator between statements was the semicolon, thus requiring the user to convert that character when typing in programs for other computers. Originally intended for use with computer terminals, the system 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 to enter those changes. On the Atom, one could move upward into a listing using the cursor keys, but to edit that text, the key was pressed to copy it to the input area where it could be edited. Another difference on the Atom was the 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 command, which could also be used to reset an accidental . A more minor change was that used comma-separated to and from line numbers instead of the minus sign, prints out lines 20 to 40. 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: 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. Acorn also allowed any expression to be used to produce the line number for branch targets, like .Statements
Acorn's primitives were similar to other BASICs of the era, and supported most of the elementary statements like . There are a number of common statements that are missing, notably used to store data in a program, computed branches, and for user-defined functions. To these basics, Acorn added 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. Note the special case that the DO can be followed directly by another statement without the semicolon separator being required. Among the more minor additions is the statement, which paused execution until the next clock tick, every of a second. This does not wait for one entire tick, just until the ''next'' tick, which may happen immediately. calls a machine language routine, the analog of or in most dialects.Math, operators and functions
Acorn used 32-bit signed integers for all math, 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, will return 2, while will return 1. Variable names can consist only of a single letter, A to Z. 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, 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 larger values. It did not support multi-dimensional arrays. Basic math operations included . It also supported bitwise logic operators, with used for AND, OR and XOR, respectively. These operators perform comparisons, so returns 0. The use of the colon for OR is why the statement separator had to use the semicolon. Note that these are separate from the logical connections found in IF statements, like , which are also supported. There were only two math functions and . 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 .Vectors
Most BASICs of the era usedStrings
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. 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. So while would print the single value of the byte at A's location in memory as a number, would read the values starting at that location and print it as a string. 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, in Acorn they are the same, and the $ is applying an operation to that variable. This also means one can use arrays for strings, like , which converts the value in AA(10) to a string. This concept allows individual characters to be accessed using vector notation. For instance, would return the ASCII value of the 5th character, 79 for O in this case, while would output "O". There was no way to extract a substring in a single operation, one had to loop over the characters and move them one-by-one. Concatenation was possible by assigning one variable to the end of another, for instance, would copy the string B to the end of A. The language had only two string functions, which looked for the trailing return character and returned the length, and to return the ASCII value of a character. CH had an odd format with no parens, so would return 65. It is otherwise similar to the more common seen in other dialects. Another new operator was , which converted a numeric value into aFloating 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. 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: %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 . This means, for instance, that one cannot if the values are floating point, one must instead . An integer value can be converted to float using the , and float to integer using the float operator, %. The ROM also included a much larger variety of math functions, including . converted a floating point number into a string, as was the case for 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.Input/output
and 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 , 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. A newline was printed with a single quote, . returns the cursor column, similar to in most dialects. The default storage device for the Atom was aGraphics support
The Atom had rudimentary bitmap graphics and Atom BASIC added a number of commands to support it. cleared the screen, moved the graphical cursor to the given X,Y location, and drew a line from the current location to the provided X,Y. The floating point ROM also included support for colour graphics with the addition of the 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.Notes
References
Citations
Bibliography
* * * * * * {{DEFAULTSORT:Atom Basic Acorn Computers BASIC interpreters BASIC programming language family