Hubbry Logo
Sinclair BASICSinclair BASICMain
Open search
Sinclair BASIC
Community hub
Sinclair BASIC
logo
7 pages, 0 posts
0 subscribers
Be the first to start a discussion here.
Be the first to start a discussion here.
Sinclair BASIC
Sinclair BASIC
from Wikipedia

Sinclair BASIC
ParadigmImperative
Designed byJohn Grant, Steve Vickers
DeveloperNine Tiles Networks,
Sinclair Research
First appeared1980; 46 years ago (1980)
PlatformZX80, ZX81, ZX Spectrum, +, 128, +2, +3, T/S 2068, TC 3256
LicenseProprietary

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

Designed to run in only 1 KB of RAM, the system makes a number of decisions to lower memory usage. This led to one of Sinclair BASIC's most notable features, that the keywords were entered using single keystrokes; each of the possible keywords was mapped to a key on the keyboard, when pressed, the token would be placed into memory while the entire keyword was printed out on-screen. This made code entry easier whilst simplifying the parser.

The original ZX80 version supported only integer mathematics, which partially made up for some of the memory-saving design notes which had negative impact on performance. When the system was ported to the ZX81 in 1981, a full floating point implementation was added. This version was very slow, among the slowest BASICs on the market at the time, but given the limited capabilities of the machine, this was not a serious concern. The low speed was not mainly due to an inefficient interpreter though, it was an effect of the fact that 70-80% of the machine cycles were consumed by the video hardware. So the Z80 in the ZX81 clocked at 3.25 MHz was "in effect" running at well below 1 MHz from the perspective of the BASIC system.

Performance became a more serious issue with the release of the ZX Spectrum in 1982, which ran too slowly to make full use of the machine's new features. This led to an entirely new BASIC for the following Sinclair QL, as well as a number of 3rd-party BASICs for the Spectrum and its various clones. The original version continued to be modified and ported in the post-Sinclair era.

History

[edit]

Clive Sinclair initially met with John Grant, the owner of Nine Tiles, in April 1979 to discuss a BASIC for Sinclair's new computer concept.[2] Sinclair was inspired to make a new machine after watching his son enjoy their TRS-80, but that machine's £500 price tag appeared to be a serious limit on its popularity. He wanted a new kit that would expand on their previous MK14 and feature a built-in BASIC at the target price of £79.95. To meet this price point, the machine would ship with only 1 KB of RAM and 4 KB of ROM. Grant suggested using the Forth language instead, but the budget precluded this. Grant wrote the BASIC interpreter between June and July 1979, but the code initially came in at 5 KB and he spent the next month trimming it down. It was initially an incomplete implementation of the 1978 American National Standards Institute (ANSI) Minimal BASIC standard with integer arithmetic only, termed 4K BASIC.[3]

Even before the ZX80 was introduced in February 1980, the constant downward price-pressure in the industry was allowing the already inexpensive design to be further reduced in complexity and cost. In particular, many of the separate circuits in the ZX80 were re-implemented in a single uncommitted logic array from Ferranti, which allowed the price to be reduced to only £49.95 while increasing the size of the ROM to 8 KB. This work was assigned to Steve Vickers, who joined Nine Tiles in January 1980. Whilst Grant worked on the code interfacing with hardware, Vickers used the larger space to introduce floating-point arithmetic and a suite of trig functions, which were expected of any BASIC from that era, producing 8K BASIC.[4] The initial version did not support the ZX Printer and had a bug in its square root function. Nine Tiles provided a new version to address these, but Sinclair was slow to include the new version in the ROMs. The new ROMs were eventually offered to owners of the earlier ZX80 as well.[5]

When Sinclair lost the contest to build the BBC Computer, he moved ahead with plans to produce a low-cost colour-capable machine that emerged as the ZX Spectrum of April 1982. ROM space would once again be increased, this time to 16 KB. In keeping with his philosophy of making systems for the lowest possible expenditure, Sinclair wanted the absolute minimum changes to the existing 8K BASIC. Although Nine Tiles felt that something much better would be needed for the new machine, the schedule would not allow it, and yet another expansion of the original code was produced. Due to the RAM also being increased, to 48 KB, this version was known as 48K BASIC and eventually 48 BASIC with the introduction of the ZX Spectrum 128 at which time the 16 KB Spectrum was no longer sold and most existing ones in use had been upgraded to 48 KB.[6][7] The new version was available near the end of 1981, but it was "depressingly slow" and "snail like". Additionally, as no prototypes were available until the end of the year, it lacked support for the new line of peripherals Sinclair was planning.[8]

In February 1982, Nine Tiles began to have disagreements with Sinclair over owed royalties for the various manuals that Nine Tiles had produced. Around the same time, Vickers and his Sinclair counterpart, Richard Altwasser, left their respective companies to start the Jupiter Ace project.[9] When the Spectrum was launched the ROM was still not complete, and although Nine Tiles continued working on it until April 1982, by that point 75,000 Spectrums had already been sold and the project was cancelled. The missing functionality was later added by additional code in the ZX Interface 1. After Nine Tiles and Sinclair went their own ways, several new versions of 48 BASIC were created.

In 1983, as part of introducing the Spectrum to the US market as the TS2068, Timex modified it as T/S 2000 BASIC. The new version was incapable of running many Spectrum programs due to the memory location of machine's functions moving. A similar, but somewhat more compatible version, was introduced as part of the Spanish Spectrum 128 of 1985, 128 BASIC.[7]

Amstrad purchased Sinclair Research in 1986. As Sinclair had never owned the copyright to the language, Amstrad had to arrange a new license with Nine Tiles. Several other versions also appeared in this period as various extensions and clones of the Spectrum were introduced. These included +3 BASIC, BASIC64 and Timex Extended Basic.[7][6]

As of 2015, interpreters exist for modern operating systems,[10] and older systems,[11] that allow Sinclair Basic to be used easily.

Description

[edit]

Program editing

[edit]

Like most home-computer BASICs, Sinclair BASIC is anchored around its line editor. When the machine is booted, it runs BASIC and displays an inverse video "K" at the bottom of the screen to indicate the entry point. When a line is entered and the NEW LINE key is pressed, it either runs immediately if it does not have a line number prefix, or clears the screen and performs the equivalent of a LIST command, placing a ">" cursor after the line number in the most recently entered line.

In contrast to most machines of the era, the editor does not allow freeform editing at any point on the screen. Instead, when the user presses EDIT, the current line of code is copied back to the bottom of the screen. The user can move horizontally through this line using the cursor keys and commits their changes by pressing NEW LINE again. In contrast, on machines like the Commodore 64 or Atari 8-bit computers, the up and down keys can be used to move among the lines in the program and edit them in-place.

The most notable feature of the editor is that keywords are entered using single keystrokes. For instance, on the ZX81, the P key on the keyboard would cause the entire keyword PRINT to be entered into the currently editing line. Once a keyword has been entered, the cursor changes to an "L" to indicate what follows will be interpreted as normal text. For instance, pressing P again at this point would enter a single letter "P".

Keys generally had two separate keywords assigned to them – one above it and one below. Pressing the key in "K" mode would enter the keyword above the key, like PRINT for P. If the system was in "L" mode, one could return to "K" by pressing the shift key – the systems did not initially support lowercase text, so the shift was not otherwise needed. The keywords below the keys required a second keystroke, ⇧ Shift+NEW LINE, which put the editor into "function mode", changing the cursor to an "F". Entering common code often resulted in a significant number of keystrokes.

The system has the advantage of representing all multi-character keywords as a single character in memory, which was a significant savings in the early machines that shipped with only 1 KB of RAM. This single-character representation included multi-character items like <>. This has the added advantages of simplifying the runtime, as it can immediately determine whether a character in the source code is a keyword or text, and also means that keywords are never entered directly, meaning that one can, for instance, have a variable named "PRINT", as the system can determine that it is not the same as the keyword.

As the systems evolved and added new keywords, the entry system became increasingly difficult to use. 48 BASIC in the Spectrum required every key to host up to four keywords. Entering keywords was a time-consuming process of looking over the relatively small type on the keyboard for the appropriate key, and then correctly entering the multiple keystrokes needed to enter it properly. For instance, entering BEEP required one to type CAPS SHIFT+SYMBOL SHIFT to access extended mode (later models include a separate EXTENDED MODE key), keeping SYMBOL SHIFT held down, and then and pressing Z. To improve the complex entry on the Spectrum, the keywords were colour-coded to indicate the required mode:[12]

  • White: key only
  • Red on the key itself: SYMBOL SHIFT plus the key
  • Green above the key: EXTENDED MODE followed by the key
  • Red below the key: EXTENDED MODE followed by SYMBOL SHIFT plus the key

This concept had run its course, and later machines running 128 BASIC (ZX Spectrum 128, +2, +3, +2A, and +2B) featured a more traditional editor where the user typed-in the keyword as individual characters, similar to other home computers of the era. This required a new tokenizer to convert the line into a similar internal format.

The resulting in-memory storage of the program was otherwise similar to Microsoft BASIC, in that only the keywords are presented as tokens, while non-keywords – like string and numeric constants and variable names – are left in their original typed-in format. However, that typed-in format was not ASCII, but an internal character code that contains both printable characters and the keyword tokens. Although portions of the table, the capital letters A to Z, for instance, are in the same order as in ASCII, their characters correspond to different numeric values, i.e. their code points' offset from zero is different from ASCII's offset of 65. Other characters, like punctuation, may have been moved about even more. The ZX Spectrum character set is the most prominent example of such a character code. Related computers running Sinclair BASIC used similar variants, e.g. the ZX80 or ZX81 character sets. All of these different but related character sets included Sinclair BASIC tokens.

Data types

[edit]

One uncommon feature of Sinclair BASIC is the way it stores variables in memory. Typically, interpreters use a fixed-size entry to hold data, making it easy to scan the variable table. Due to the extremely limited memory of the ZX series, any wasted space had to be avoided, and this led to the use of a variable-length format. The data types included numbers stored in a 5-byte values, strings with a length and then the characters, and arrays of both of those types. The data was stored in the table itself, which contrasts with most BASICs of the era, where strings and array entries were stored in a separate heap.

The first byte for a variable entry always held the type in the first three bits, and the first character of the name in the next five bits. As was the case in most microcomputer dialects, A, A$, A() and A$() were all different variables and could store different values. Most variables could only have a single-character name; the exception are numeric variables (not arrays), where an alternate format held the first character of the name in those same five bits, but was then followed by additional characters ending with one with its high-bit set. Long variable names were whitespace-independent, and case-insensitive in later versions, so LET Number Of Apples = 5 is the same as LET numberofapples = 5 referred to the same variable.

The downside to this approach is that scanning the table to look up the value of a variable reference is more complex. In addition to testing whether the name matches using the subset of the first byte, if the entry is not the one that is being looked for, the type has to be read from the upper three bits and then the next location of a variable in storage calculated using the type. For instance, if the program encounters the variable "A" and the table starts with the entry for "B$", it fails to match A with B, then reads the type to see it is a string, and then has to read the following length byte and skip forward by that amount of bytes to find the next entry in the table. To make this somewhat easier, arrays also stored a two-byte length, so the entire structure could be skipped over more easily.

A unique feature was the "short float", or integer type. Any numeric variable could store either type, the storage itself did not change and used 5 bytes in either case. Integers were indicated by setting the exponent byte to zero, while floating-point values were stored with an excess-128 format exponent. This meant that it could not store zero as a float and lost one possible exponent magnitude. It also did not use any less memory, as the values were still 5-byte in memory. The advantage to this format is performance; the math library included tests to look for the zero exponent, and if it was seen, it would not attempt to perform various operations on the remaining 3 bytes under certain conditions.

Keyword details

[edit]

The ZX81 8K BASIC used the shorter forms GOTO, GOSUB, CONT and RAND, whereas the Spectrum 48 BASIC used the longer forms GO TO, GO SUB, CONTINUE and RANDOMIZE. The ZX80 4K BASIC also used these longer forms but differed by using the spelling RANDOMISE. The ZX81 8K BASIC was the only version to use FAST, SCROLL, SLOW and UNPLOT. The ZX80 4K BASIC had the exclusive function TL$(); it was equivalent to the string operator (2 TO ) in later versions.

Unique code points are assigned in the ZX80 character set, ZX81 character set and ZX Spectrum character set for each keyword or multi-character operator, i.e. <=, >=, <>, "" (tokenized on the ZX81 only), ** (replaced with on the Spectrum). These are expanded by referencing a token table in ROM. Thus, a keyword uses one byte of memory only, a significant saving over traditional letter-by-letter storage. This also meant that the BASIC interpreter could quickly determine any command or function by evaluating one byte, and that the keywords need not be reserved words like in other BASIC dialects or other programming languages, e.g., it is allowed to define a variable named PRINT and output its value with PRINT PRINT. This is also related to the syntax requirement that every line start with a command keyword, and pressing the one keypress for that command at the start of a line changes the editor from command mode to letter mode. Thus, variable assignment requires LET (i.e., LET A=1 not only A=1). This practice is also different from other BASIC dialects. Further, it meant that unlike other BASIC dialects, the interpreter needed no parentheses to identify functions; SIN x was sufficient, no SIN(x) needed (though the latter was allowed). The 4K BASIC ROM of the ZX80 had a short list of exceptions to this: the functions CHR$(), STR$(), TL$(), PEEK(), CODE(), RND(), USR() and ABS() did not have one-byte tokens but were typed in letter-by-letter and required the parentheses. They were listed as the INTEGRAL FUNCTIONS on a label above and to the right of the keyboard.[13]

128 BASIC, present on ZX Spectrum 128, +2, +3, +2A, and +2B, stored keywords internally in one-byte code points, but used a conventional letter-by-letter BASIC input system. It also introduced two new commands:

  • PLAY, which operated the 128k models' General Instrument AY-3-8910 music chip
  • SPECTRUM, which switched the 128k Spectrum into a 48k Spectrum compatibility mode

The original Spanish ZX Spectrum 128 included four additional BASIC editor commands in Spanish,[14][15] one of which was undocumented:

  • EDITAR (to edit a line number or invoke the full screen string editor)
  • NUMERO (to renumber the program lines)
  • BORRAR (to delete program lines)
  • ANCHO (to set the column width of the RS-232 device, but undocumented as the code was broken)

Unlike the LEFT$(), MID$() and RIGHT$() functions used in the ubiquitous Microsoft BASIC dialects for home computers, parts of strings in Sinclair BASIC are accessed by numeric range. For example, A$(5 TO 10) gives a substring starting with the 5th and ending with the 10th character of the variable a$. Thus, it is possible to replace the LEFT$() and RIGHT$() commands by simply omitting the left or right array position respectively; for example a$( TO 5) is equivalent to LEFT$(A$,5). Further, a$(5) alone is enough to replace MID$(A$,5,1).

Syntax

[edit]

Keywords

[edit]

On the 16K/48K ZX Spectrum (48 BASIC), there are 88 keywords in Sinclair BASIC, denoting commands (of which there are 50), functions and logical operators (31), and other keywords (16, including 9 which are also commands or functions):

Keyword Parameters[note 1] Entered using[note 2] Type Summary
ABS number EXTENDED MODE then G Function Returns the absolute value of number[16]
ACS number EXTENDED MODE then SYMBOL SHIFT+W Function Returns the arccosine of number[17]
AND SYMBOL SHIFT+Y Logical operator Returns true if both conditions on either side of the AND keyword are true, else returns false[note 3][18]
ASN number EXTENDED MODE then SYMBOL SHIFT+Q Function Returns the arcsine of number[19]
AT line, column; SYMBOL SHIFT+I Other Used in a PRINT statement to print at the line and column specified;[20] for example, PRINT AT 5,10;"*" puts a star in column 10 of line 5.
ATN number EXTENDED MODE then SYMBOL SHIFT+E Function Returns the arctangent of number[17]
ATTR (line, column) EXTENDED MODE then SYMBOL SHIFT+L Function Returns a byte containing information on the colours of the text cell on the screen, corresponding to the specified line and column; note that, unlike most Sinclair BASIC keywords, the parentheses are required; the first three bits indicate the ink (foreground) colour, the fourth, fifth and sixth bits the paper (background) colour, the seventh bit whether the colours are bright or not, and the eight, whether they are flashing[21]
BEEP duration, pitch EXTENDED MODE then SYMBOL SHIFT+Z Command Produces sound from the computer's speaker; duration is in seconds, pitch is in semitones above (positive value) or below (negative value) middle C[22]
BIN number EXTENDED MODE then B Other Indicates number is in binary notation[23]
BORDER number B Command Sets the border of the screen to the colour specified by the number[note 4][24]
BRIGHT number EXTENDED MODE then SYMBOL SHIFT+B Command/other Makes all following colours brighter if number is 1, or its normal shade if 0[note 5][25]
CAT number EXTENDED MODE then SYMBOL SHIFT+9 Command Displays contents of ZX Microdrive specified by number[note 6][26]
CHR$ number EXTENDED MODE then U Function Returns the character corresponding to the decimal number in the computer's character set[27]
CIRCLE x, y, r EXTENDED MODE then SYMBOL SHIFT+H Command Draws a circle with its centre at coordinates (x,y) and radius r[28]
CLEAR address X Command Clears the screen,[29] all variables and the GO SUB stack,[30] and optionally sets the maximum RAM address to be used by BASIC[31]
CLOSE # number EXTENDED MODE then SYMBOL SHIFT+5 Command Closes the specified stream number for access[note 6]
CLS V Command Clears all text and graphics from the screen[29]
CODE string EXTENDED MODE then I Function/other Returns the number corresponding to the first character in string in the computer's character set;[27] also used to save arbitrary chunks memory to tape, disk, etc. and load them back in – see LOAD, SAVE and VERIFY for details
CONTINUE C Command Restarts a program after it has stopped due to an error or the user pressing the CAPS SHIFT+SPACE or BREAK keys[32]
COPY Z Command Sends the currently displayed screen to the printer[33]
COS number EXTENDED MODE then W Function Returns the cosine of number[34]
DATA comma-separated values EXTENDED MODE then D Command/other Provides numbers and/or strings to use with the READ command[35] and allows saving the contents of an array to tape when used with the SAVE command[36] (as SAVE filename DATA array name())
DEF FN name(variable) = operation EXTENDED MODE then 1 Command Defines a custom function that can be used with the FN command;function definitions must be of the form f(x)=operations, for example f(x)=x*2 and the function name may not consist of more than one letter, plus a $-symbol if the function returns a string[37]
DIM variable(dimensions) D Command Declares an array with the specified dimensions, which may be multi-dimensional (for example, DIM a(10,10); if used with strings, the last dimension indicates the length of each of the strings (thus, DIM A$(2,5) is an array of two strings each of five characters long, and DIM B$(5) is one string of five characters)[38]
DRAW x, y [, r] W Command Draws a line in the current INK colour to coordinates (x,y) from the coordinates used by the previous PLOT or DRAW command; if the optional r is supplied, it indicates the radius of the circle segment to be drawn, in radians[39]
ERASE drive;"filename" EXTENDED MODE then SYMBOL SHIFT+7 Command Deletes the specified file from a ZX Microdrive[note 6][40]
EXP number EXTENDED MODE then X Function Returns e to the power number[41]
FLASH number EXTENDED MODE then SYMBOL SHIFT+V Command/other Makes all following text alternate its foreground (INK) and background (PAPER) colours[note 5]
FN function(value) EXTENDED MODE then SYMBOL SHIFT+2 Function Calls the function defined earlier in the program using DEF FN[37]
FORMAT drive;"name" EXTENDED MODE then SYMBOL SHIFT+0 Command Formats the cartridge in the indicated Microdrive and assigns it the identifier name[note 6][42]
FOR variable = start TO end F Command Starts a FOR-NEXT loop;[43] the variable name may only be one character long[44]
GO SUB number H Command Makes the program jump to the BASIC line specified by number; when the program encounters the command RETURN, it will jump back to the statement after the GO SUB[45]
GO TO number G Command Makes the program jump to the BASIC line specified by number
IF condition THEN U Command Evaluates the condition, and if true, executes the statement that follows the keyword THEN that must come after the condition,[46] for example IF A=1 THEN LET B=2[note 7]
IN address EXTENDED MODE then SYMBOL SHIFT+I Function Returns a byte read from the hardware input/output port corresponding to the address[47]
INK number EXTENDED MODE then SYMBOL SHIFT+X Command/other Sets the foreground colour for text and graphics[note 4][note 5][48]
INKEY$ EXTENDED MODE then SYMBOL SHIFT+Z Function Returns a string representing the key being pressed on the keyboard at the moment the function is called, or an empty string if none is,[49] but does not wait for a keypress
INPUT [prompt,] variable I Command Halts program execution until the user types in something on the keyboard and presses the Enter key, then stores the entered value in the specified variable; if the optional prompt is supplied, this will be shown on the screen[50]
INT number EXTENDED MODE then R Function Returns the integer value of number, rounding down to the nearest whole number[16] (thus, INT -1.1 returns −2, not −1)
INVERSE number EXTENDED MODE then SYMBOL SHIFT+M Command/other Reverses the colours on all following text if number is 1, so that it uses the current ink colour for the background and the current paper colour for the text, or sets them back to normal if number is 0[note 5][51]
LEN string EXTENDED MODE then K Function Returns the number of characters (bytes) in string[52]
LET variable=value L Command Assigns value to the named variable[53]
LINE EXTENDED MODE then SYMBOL SHIFT+3 Other
  • When used in an INPUT statement before a string variable, will not put quotation marks ("") around its prompt,[20] for example INPUT "Name: "; LINE n$
  • When used in a SAVE statement so that when the BASIC program being saved is loaded again, it starts automatically at the line number indicated[54]
LIST [number] K Command Outputs the current BASIC program to the screen; if the optional number is provided, it omits all lines with a lower number[55]
LLIST [number] EXTENDED MODE then SYMBOL SHIFT+V Command As LIST except the listing is output to the printer[33]
LN number EXTENDED MODE then SYMBOL SHIFT+Z Function Returns the natural logarithm of number[56]
LOAD "filename" DATA variable() | [CODE [start[, length]]] | SCREEN$ J Command Loads from tape or another storage device, with the filename specified, or the first file found if an empty string ("") is provided.
  • By default, loads a BASIC program, erasing any BASIC program and variables already in memory.[50]
  • If DATA is used, loads the data into the array named variable().[36]
  • With CODE, loads the data into the memory address from which it was saved, or the specified memory location (length is intended as a safety, to try and load the right program in case there are multiple on the tape with the right name but of different lengths).
  • SCREEN$ is equivalent to CODE 16384,6912, in order to load an image onto the screen.
LPRINT text EXTENDED MODE then SYMBOL SHIFT+C Command As PRINT except output is sent to the printer[33]
MERGE "[filename]" EXTENDED MODE then SYMBOL SHIFT+T Command As LOAD, except it does not delete the current program and variables; if a line number exists in both, that of the newly loaded program overwrites the existing one. Using MERGE prevents a program saved using LINE from auto-running once loaded[57]
MOVE stream1 TO stream2 EXTENDED MODE then SYMBOL SHIFT+6 Command Moves data from one stream (keyboard, screen, file, printer, network, etc.) to another[note 6][58]
NEW A Command Erases the current BASIC program and all variables[50]
NEXT variable N Command Closes a FOR-NEXT loop; the variable must match that of the corresponding FOR command[59] – "empty" NEXTs to refer to the immediately preceding FOR in the program are not allowed
NOT condition SYMBOL SHIFT+S Logical operator Returns true if the condition is false, else returns false[note 3][18]
OPEN # stream EXTENDED MODE then SYMBOL SHIFT+4 Command Opens a stream for reading from and/or writing to[note 6][60]
OR SYMBOL SHIFT+Y Logical operator Returns true if either of the conditions on either side of the OR keyword are true, else returns false[note 3][18]
OUT address, value EXTENDED MODE then SYMBOL SHIFT+O Command Sends the value (a byte) to the hardware input/output port corresponding to the address.[47]
OVER number EXTENDED MODE then SYMBOL SHIFT+N Command/other Will make following text overprint with an XOR operation what is already on the screen if number is 1, instead of erasing it, or erase it if number is 0[note 5][51]
PAPER number EXTENDED MODE then SYMBOL SHIFT+C Command/other Sets the background colour for text and graphics[note 4][note 5][48]
PAUSE delay M Command Halts program execution for the specified delay, in of a second in Europe or in North America[61] (thus, PAUSE 50 halts for one second in Europe). Also continues after a key press.
PEEK address EXTENDED MODE then O Function Returns a byte representing the contents of the memory location pointed to by address[62]
PI EXTENDED MODE then M Function Returns the value of pi[56]
PLOT x, y Q Command Draws a pixel in the current INK colour on the screen at the coordinates (x,y)[63]
POINT (x,y) EXTENDED MODE then SYMBOL SHIFT+8 Function Returns 1 if the pixel pointed at graphical coordinates (x,y) is currently in the ink (foreground) colour, else returns 0[28]
POKE address, value O Command Sets the contents of address in RAM to value[64]
PRINT [AT x,y;] text P Command Prints text (which must be one or more strings or numbers separated with semicolons) to the screen.[53] If used with #0 or #1, it prints in the bottom two (input) lines of the screen; if used with AT, it prints at the specified text coordinates; otherwise, it prints either immediately following the output of any previous PRINT statement (if the previous statement ended in a semicolon), or in the first column of the line below the previous PRINT output,[20] defaulting to 0,0.
RANDOMIZE [number] T Command Initializes the random number generator; if used without a number (or with 0), it does this based on the computer's internal clock, else it uses the number supplied, which must be in the range [1,65535][65]
READ variable EXTENDED MODE then A Command Takes a value from a DATA statement and stores it in the named variable: the first time READ is used, it gets the first value after the first DATA, the second time it gets the next one, and so on[35]
REM text E Command Begins a comment in the source code, meaning that everything after the REM statement is ignored, until the end of the line[50] – note this includes everything after a colon, which normally begins a new segment: 10 REM Nothing to see here: PRINT "Unprintable" will not produce any output, for example.
RESTORE [number] EXTENDED MODE then S Command Resets where READ commands look for values in DATA statements: if used without a number, the next READ will use the first DATA in the program, with a number it will use the first DATA on or after the line whose number is indicated[66]
RETURN Y Command Returns execution to the first statement following the last GO SUB command that was executed[45]
RND EXTENDED MODE then T Function Returns a pseudo-random number with eight significant figures in the range [0,1)[67]
RUN [number] R Command Starts the current BASIC program, from its first line if no number is specified, else from the line with that number (or the first one after, if it does not exist)[68]
SAVE "filename" [DATA variable() | LINE number | CODE start, length | SCREEN$] S Command Saves to tape or another storage device, with the filename specified.
  • By default, saves the current BASIC program. If the optional LINE followed by a line number is used, then the program will start automatically at the indicated line number when it is LOADed back in.
  • If DATA is used, saves the contents of the array named by the variable.[36]
  • With CODE, saves the specified range of bytes from the memory.
  • SCREEN$ is equivalent to CODE 16384,6912, in order to save a screen dump.
SCREEN$ [(line, column)] EXTENDED MODE then SYMBOL SHIFT+ Function/other As a function, identifies the character at the specified line and column on the screen.[20] Used after the filename in a LOAD or SAVE command, indicates that the contents of the display memory should be loaded or saved; this essentially makes it a shortcut for CODE 16384,6912[note 8] but does not work with VERIFY because the contents of the display memory will be different by the time that command reads back the saved data;[69]
SGN number EXTENDED MODE then F Function Returns 1 if number is positive, 0 if it is 0, and −1 if it is negative[16]
SIN number EXTENDED MODE then Q Function Returns the sine of number[34]
STEP number SYMBOL SHIFT+D Other Indicates the interval used by a FOR statement,[44] for example FOR n=2 TO 6 STEP 2 will skip n=3 and n=5 in the loop
STOP SYMBOL SHIFT+A Command Ends execution of the current program, exiting to the BASIC editor; can also be given when the computer is waiting for input using the INPUT command;[68] once the program is stopped, it can be resumed with CONTINUE
SQR number EXTENDED MODE then H Function Returns the square root of number[37]
STR$ number EXTENDED MODE then Y Function Converts a number to string.
TAB column EXTENDED MODE then P Other In a PRINT statement, makes sure that the text to be output begins in the column specified, wrapping to the next line as necessary, but never more than one line[29]
TAN number EXTENDED MODE then E Function Returns the tangent of number[70]
THEN statement SYMBOL SHIFT+G Other Follows the condition in an IF statement to indicate what should happen when the condition evaluates to true[note 7][46]
TO SYMBOL SHIFT+F Other Indicates a range from the number to the left of TO to the number of the right of it, inclusive;[71] when used with FOR both numbers must be supplied, while if used to slice strings, either may be left off to indicate the start or end of the string
USR string or address EXTENDED MODE then L Function When called with a single-character string, this returns the memory address at which the glyph for the user-defined graphic character corresponding to that character is defined.[23] If called with an address, it starts machine code execution at that address (thus making it one of the few Sinclair BASIC functions to have a Side effect) and returns the contents of the Z80’s BC register pair.[72]
VAL string EXTENDED MODE then J Function Evaluates the string as a number and returns the result;[73] this can perform calculations: VAL "1+2" returns 3, for example, and also evaluates variables and even other VAL statements: LET A=1: VAL "A+VAL ""2"""[note 9] also returns 3
VAL$ string EXTENDED MODE then SYMBOL SHIFT+J Function Similar to VAL but evaluates the string as a string[16]
VERIFY "[filename]" EXTENDED MODE then SYMBOL SHIFT+R Command Reads a program or data from tape or other storage, much like LOAD, but instead of loading it into memory, compares it with the program or data that is already in memory. This is intended to be used immediately after a SAVE command, to make sure the program or data has been saved without corruption.[74]
ZX Spectrum
ZX Spectrum+

Official versions

[edit]

4K BASIC

[edit]

4K BASIC for ZX80[75] (so named for residing in 4 KiB read-only memory (ROM)), was developed by John Grant of Nine Tiles for the ZX80. It has integer-only arithmetic.

  • System commands: NEW RUN LIST LOAD SAVE
  • Control statements: GOTO IF THEN GOSUB STOP RETURN FOR TO NEXT CONTINUE
  • Input/output statements: PRINT INPUT
  • Assignment statement: LET
  • Other statements: CLEAR CLS DIM REM RANDOMIZE POKE
  • Functions: ABS CHR$ CODEPEEK RND STR$ TL$ USR

8K BASIC

[edit]

8K BASIC is the ZX81 BASIC (also available as an upgrade for the ZX80[5]), updated with floating-point arithmetic by Steve Vickers, so named for residing in 8 KiB ROM.

  • Statements: PRINT RAND LET CLEAR RUN LIST GOTO CONT INPUT NEW REM PRINT STOP BREAK IF STOP FOR NEXT TO STEP SLOW FAST GOSUB RETURN SAVE LOAD CLS SCROLL PLOT UNPLOT PAUSE LPRINT LLIST COPY DIM POKE NEW
  • Functions: ABS SGN SIN COS TAN ASN ACS ATN LN EXP SQR INT PI RND FUNCTION LEN VALSTR$ NOT CODE CHR$ INKEY$ AT TAB INKEY$ PEEK USR

48 BASIC

[edit]

48 BASIC is the BASIC for the original 16/48 KB RAM ZX Spectrum (and clones), with colour and more peripherals added by Steve Vickers and John Grant. It resides in 16 KB ROM and began to be called 48 BASIC with the introduction of the ZX Spectrum 128 at which time the 16 KB Spectrum was no longer sold and most existing ones in use had been upgraded to 48 KB.[6]

128 BASIC

[edit]

128 BASIC is the BASIC for the ZX Spectrum 128.[7] It offers extra commands and uses letter-by-letter input.

  • New commands: LOAD ! SAVE ! MERGE ! ERASE ! PLAY SPECTRUM

+3 BASIC

[edit]

+3 BASIC is the BASIC with disk support for the ZX Spectrum +3 and +2A.[6]

  • New commands: FORMAT COPY

T/S 2000 BASIC

[edit]

T/S 2000 BASIC is used on the Spectrum-compatible Timex Sinclair 2068 (T/S 2068) and adds the following six new keywords:

  • DELETE deletes BASIC program line ranges.
  • FREE is a function that gives the amount of free RAM. PRINT FREE will show how much RAM is free.
  • ON ERR is an error-handling function mostly used as ON ERR GO TO or ON ERR CONT.
  • RESET can be used to reset the behaviour of ON ERR. It was also intended to reset peripherals.
  • SOUND controls the AY-3-8192 sound chip.
  • STICK is a function that gives the position of the internal joystick (Timex Sinclair 2090).

BASIC64

[edit]

BASIC64 by Timex of Portugal, is a software extension[76] to allow better Basic programming with the 512×192 and dual display areas graphic modes available only on Timex Sinclair computers. This extension adds commands and does a complete memory remap to avoid the system overwriting the extended screen memory area. Two versions exist due to different memory maps – a version for TC 2048 and a version for T/S 2068 and TC 2068.

  • PRINT # prints to a specific output channel.
  • LIST # lists the program to a specific output channel.
  • CLS* clears both display areas.
  • INK* sets ink colour for both display areas
  • PAPER* sets paper colour both display areas
  • SCREEN$ selects the high / normal resolution modes.
  • PLOT* plots a pixel and updates the drawing position.
  • LINE draws a line from the previous PLOT position, supporting arc drawing
  • CIRCLE* draws a circle or oval, depending on screen mode.

Timex Extended Basic

[edit]

Timex Extended Basic by Timex of Portugal is used on the Timex Computer 3256, adding TEC – Timex Extended Commands commands supporting the AY-3-8912 sound chip, RS-232 network and the 512x192 pixel high resolution graphic mode.[77][78]

  • RAM drive commands: LOAD! SAVE! CAT! MERGE! ERASE! CLEAR!
  • RS-232 commands: FORMAT! LPRINT LLIST
  • AY-3-8912 commands: BEEP!
  • 512 x 192 resolution commands: SCREEN$ DRAW! PLOT! CIRCLE!

Other versions, extensions, derivatives and successors

[edit]

Interpreters for the ZX Spectrum family

[edit]

Several ZX Spectrum interpreters exist.[79]

  • Beta BASIC by Dr. Andy Wright, was originally a BASIC extension, but became a full interpreter.[80]
  • YS MegaBasic by Mike Leaman.[79][81]
  • ZebraOS by Zebra Systems in New York, a cartridge version of T/S 2000 BASIC that used the 512×192 screen mode.[82]
  • Sea Change ROM by Steve Vickers and Ian Logan, modified by Geoff Wearmouth, a replacement ROM with an enhanced Sinclair BASIC.[83]
  • Gosh Wonderful by Geoff Wearmouth, a replacement ROM that fixes bugs and adds a tokenizer, stream lister, delete and renumber commands.[79][84]
  • OpenSE BASIC (formerly SE BASIC) by Andrew Owen, a replacement ROM with bug fixes and many enhancements including ULAplus[85] support, published as open source in 2011[86][87][88]

Compilers for the ZX Spectrum family

[edit]

Several ZX Spectrum compilers exist.[79]

Derivatives and successors for other computers

[edit]
  • SuperBASIC, a much more advanced BASIC dialect introduced with the Sinclair QL personal computer, with some similarities to the earlier Sinclair BASICs[102]
  • SAM Basic, the BASIC on the SAM Coupé, generally considered a ZX Spectrum clone[103]
  • ROMU6 by Cesar and Juan Hernandez – MSX[79]
  • Spectrum 48 by Whitby Computers – Commodore 64[79]
  • Sparky eSinclair BASIC by Richard Kelsh, an operating system loosely based on ZX Spectrum BASIC – Zilog eZ80[104]
  • Sinbas by Pavel Napravnik – MS-DOS[79]
  • Basic[105] (and CheckBasic[106]) by Philip Kendall – Unix
  • BINSIC[107] by Adrian McMenamin, a reimplementation in Groovy closely modelled on ZX81 BASIC – Java
  • BASin[108] by Paul Dunn, a complete Sinclair BASIC integrated development environment (IDE) based on a ZX Spectrum emulator[79] – Windows
  • SpecBAS[109] (a.k.a. SpecOS) by Paul Dunn, an integrated development environment (IDE) providing an enhanced superset of Sinclair BASIC – Windows, Linux, Pandora, and Raspberry Pi
  • ZX-Basic[110] – Backwardly compatible, but enhanced compiler of Sinclair BASIC programs the ZX Spectrum, written in Python, freely available for Windows, Linux and Mac OS
  • ZX-Basicus[111] by Juan-Antonio Fernández-Madrigal, a synthesizer, analyzer, optimizer, interpreter and debugger of Sinclair BASIC 48K for PCs, freely downloadable for Linux and Windows.

See also

[edit]

Notes

[edit]

References

[edit]

Bibliography

[edit]
[edit]
Revisions and contributorsEdit on WikipediaRead on Wikipedia
from Grokipedia
Sinclair BASIC is a compact of the programming language, specifically designed for the low-memory constraints of Sinclair Research's early 8-bit home computers, such as the (1980), (1981), and (1982). Developed by Nine Tiles Networks Ltd. in , , it prioritized simplicity and efficiency to fit within limited ROM sizes—starting at 4 KB for the ZX80's integer-based interpreter and expanding to 8 KB for the ZX81's floating-point version, then 16 KB for the Spectrum's enhanced implementation with support for color graphics and sound. The language's development began in 1979 when contracted Nine Tiles, led by John Grant, to create a for the , the world's first mass-market kit priced at £79.99. Grant's team, later joined by , optimized the parser and runtime to operate with as little as 1 KB of RAM, using techniques like immediate-mode execution and tokenized storage to enable beginners to write programs directly upon powering on the machine. For the , Vickers enhanced the syntax to include functions like trigonometric operations (, COS) and logarithmic calculations (LN), while introducing features such as user-defined (UDG) and a fast/slow display mode to manage the ZX81's character-based video output. By the ZX Spectrum's launch, Sinclair BASIC incorporated commands for its 256×192 pixel resolution and 15-color palette, such as PLOT, DRAW, and BEEP, making it a cornerstone for the era's burgeoning and gaming scene. Notable for its role in democratizing programming, Sinclair BASIC powered millions of units sold worldwide—over 300,000 ZX81s by early 1982 alone—and fostered a vibrant software ecosystem, including educational tools, utilities, and iconic games like . Its syntax, while quirky (e.g., one-letter variable names and no lowercase support until later models), emphasized accessibility, with immediate feedback via the TV screen, and allowed seamless integration of via the USR function for performance-critical tasks. Following Sinclair's acquisition by in 1986, variants persisted in models like the +3, maintaining while adding disk support. Today, emulators and modern recreations preserve its legacy, underscoring its influence on personal computing history.

History

Origins and Development

was established in 1979 by under the initial name Science of Cambridge Ltd., with a primary goal of producing low-cost personal computers to democratize access to computing for home users. This initiative was spurred by Sinclair's observation of his son's engagement with the , prompting a drive to create an even more affordable alternative in the burgeoning market dominated by higher-priced systems like the and . The company's emphasis on cost reduction extended to hardware and software design, aiming to deliver functional computing under £100. The development of Sinclair BASIC began with the computer, launched in January 1980, where it served as the built-in programming language to enable immediate user interaction without additional peripherals. Designed as a direct response to competitors such as the , the ZX80's BASIC implementation prioritized extreme minimalism to fit within a 4 KB ROM, supporting only 1 KB of RAM and integer arithmetic to minimize hardware demands and production costs. This constrained approach allowed the ZX80 to be sold as a kit for £79.95 or assembled for £99.95, marking it as the first computer under £100 in the UK market. John Grant of Nine Tiles Network was the primary designer of the initial 4K integer BASIC for the , contracted by Sinclair in April 1979 to create a compact interpreter adhering to the ANSI X3.60-1978 minimal BASIC standard. This choice avoided the licensing fees associated with , which was prevalent but costly for many microcomputers, while adapting the language for the ZX80's limitations by excluding floating-point operations and focusing on essential commands for basic programming tasks. Steven Vickers, who joined Nine Tiles in January 1980, played a crucial role in refining the system, particularly by introducing tokenization—where keywords were represented as single bytes—to further compress code and save precious memory in the resource-scarce environment. For the , released in 1981, Sinclair BASIC evolved into an 8K version that addressed key shortcomings of the , including the addition of for more versatile numerical computations and improved error handling to enhance usability. led these enhancements, expanding the language while maintaining compatibility and efficiency for the 's 8 KB RAM configuration, sold at an even lower kit price of £49.95. This iteration built directly on Grant's foundational work, solidifying Sinclair BASIC as a hallmark of constrained yet innovative . The BASIC was later expanded to a 16 KB ROM version for the in 1982, incorporating color and sound capabilities.

Key Milestones and Evolution

Sinclair BASIC was further expanded for the ZX Spectrum's launch on April 23, 1982, implemented in a 16 KB ROM that built upon the core keyword set from earlier ZX models like the while adding dedicated support for via commands such as , , and , as well as basic sound generation through the BEEP keyword using the internal speaker. This integration allowed programmers to create colorful 256×192 displays with an 8-color palette (plus bright and flashing variants) and simple tonal audio, marking a significant advancement in accessible programming for home users. Subsequent hardware revisions in 1984 to the 48K ZX Spectrum focused on minor bug fixes and component improvements, including an uprated buzzer for enhanced BEEP output, without introducing major alterations to the BASIC interpreter itself. The ZX Spectrum 128K, released in 1985, advanced BASIC with extensions for paging into the expanded 128 KB RAM—treated as a virtual RAM disk via new commands like those accessing drive M:—and compatibility with the onboard RS232 serial port for external device communication. The follow-on +2 model in 1986 incorporated these RAM access features into its BASIC implementation, further refining editor usability with full-screen input. In 1987, the ZX Spectrum +3 introduced +3 BASIC, which embedded +3DOS commands directly into the language for seamless disk handling on its built-in 3-inch floppy drive, enabling operations like FORMAT "A:", CAT for cataloging, and extended SAVE/LOAD syntax for 180 KB disks while maintaining backward compatibility with prior Spectrum software. Timex variants, including the TC2048 launched in 1984, offered minor enhancements to Sinclair BASIC such as the BASIC 64 extension, which adapted graphics commands like PRINT, , and DRAW for a higher 64-column/512×192 resolution mode on the otherwise compatible hardware. Sinclair BASIC's evolution underpinned the ZX Spectrum's central role in the 1980s home computing boom, where the affordable machine sold over 5 million units worldwide by the 1990s, fostering a generation of amateur programmers and sparking the British through accessible coding of titles like . The line's decline accelerated after Amstrad's acquisition of on April 7, 1986, which shifted focus to integrated peripherals like the +3's disk drive but culminated in the end of official support by 1990 amid rising competition from PC compatibles.

Core Features

Program Editing and Interface

Sinclair BASIC provided an interactive, text-based interface optimized for the constrained hardware of early 1980s home computers like the , where users entered programs directly via a divided into a 5x8 grid of keys, each capable of producing multiple characters or keywords in different modes (e.g., K-mode for keywords, L-mode for lowercase letters). The interface displayed output in the upper portion of the 32-column by 22-row screen, reserving the bottom two lines for input and status messages, with the system automatically switching between display and edit modes as needed. Programs were entered line by line using mandatory integer line numbers ranging from 1 to 9999, which determined execution order and allowed for insertions by leaving gaps (e.g., numbering lines 10, 20, and 30 to insert at 15 later). Upon pressing ENTER, the system automatically tokenized keywords—such as PRINT or GO TO—into single-byte representations for compact storage in the machine's limited RAM, typically 16 KB for the ZX Spectrum 48K, enabling efficient program management despite small memory footprints. Without a line number, entries executed immediately in direct mode; with one, they were stored in program mode for later execution via the RUN command. Editing relied on basic commands integrated with the keyboard layout: LIST displayed the program from the top (or from a specified line, e.g., LIST 100), with the current line highlighted by an inverse-video marker; EDIT (accessed via CAPS SHIFT + 1) copied the target line to the bottom of the screen for modification, where users navigated using cursor keys (e.g., CAPS SHIFT + 5 for left, +8 for right) and deleted characters with the (CAPS SHIFT + 0), then pressed ENTER to update it. removed an entire line by entering its number and ENTER, while cursor up/down keys (5 and 7) scrolled through lines for selection, though EDIT would pull the next line if positioned between them. These operations occurred in a single-line context at the screen bottom, with no support for multi-line selection, search, or replace functions. The error reporting system displayed numeric codes and descriptive messages at the screen bottom upon runtime issues, such as "0 OK" for successful execution, "1 NEXT without FOR" for mismatched loops, or "B Integer out of range" for overflow, often including the affected line and statement position (e.g., "4 Out of memory in line 50"). Users could resume with CONTINUE after non-fatal errors, jumping to the next statement, but breaks like "L BREAK into program" required manual intervention. Input handling distinguished between direct commands for one-off execution and program-stored INPUT statements, which prompted users with a flashing "?" cursor if no custom message was provided (e.g., INPUT A for a numeric value), or displayed a quoted string prompt otherwise. In program mode, INPUT paused execution for keyboard entry, assigning values to variables, while direct mode allowed immediate testing of expressions or commands. Key limitations stemmed from the hardware: the 1 KB video RAM constrained line display to about 32 characters before wrapping or scrolling, preventing easy editing of long lines without multiple EDIT cycles, and the absence of advanced features like multi-line editing or automated renumbering forced manual management, often leading to fragmented line numbering over iterative development. The interface's simplicity, while efficient for memory, prioritized single-statement interactions over modern IDE capabilities.

Data Types and Variables

Sinclair BASIC primarily supports numeric, string, and array data types, designed for memory efficiency on the limited RAM of Sinclair computers. Numeric values are stored in a 40-bit floating-point format, comprising an 8-bit biased exponent and a 32-bit mantissa, which allows for approximately 9 digits of precision and a from about 4×10394 \times 10^{-39} to 103810^{38}. Integers within a suitable range (such as -32768 to 32767) are represented exactly using this floating-point format. Variables in Sinclair BASIC do not require explicit declaration and are created upon first assignment. Numeric variables can have names of arbitrary length, starting with a letter followed by letters or digits (case-insensitive, ignoring spaces and control codes), such as score or total42. String variables, however, are limited to single-letter names suffixed with $, like A$ or message$. Arrays, declared with the DIM statement, use a single-letter base name (numeric or with $ for strings) followed by parentheses enclosing dimensions, with subscripts starting at 0; for example, DIM A(10) creates a numeric array with elements A(0) to A(10), and DIM B$(5,3,20) creates a string array with fixed length 20 per element. Numeric arrays initialize to 0, while string arrays initialize to zero length (empty strings). Memory for variables and arrays is allocated dynamically in the RAM area dedicated to BASIC data, starting at address 23734 (5CBEh) in the 48K model after executing CLEAR. The CLEAR command (optionally CLEAR n to reserve n bytes at the top of RAM) undefines all simple variables and arrays, resetting the variables pointer (VARS system variable at 23606) and freeing the string heap to prevent "" errors during program execution. Sinclair BASIC lacks type-specific declaration commands like DEFINT; all numerics are treated uniformly under the floating-point system. Strings are stored in a dynamic heap with a 16-bit field (little-endian), supporting up to characters, followed by the character data in ASCII (with double quotes for embedding quotes). Key functions for string manipulation include LEN(string) to return the , VAL(string) to convert a numeric string to a floating-point value (truncating non-digits), and STR$(numeric) to convert a number to its string representation. There is no native type; instead, 0 evaluates as false and any non-zero numeric (commonly -1) as true in conditional statements. The language imposes limitations such as no support for user-defined structures, records, or objects, keeping the design simple for the hardware constraints. Type coercion between numerics and strings occurs explicitly via functions like STR$ and VAL, with automatic handling in operations like PRINT where numerics are implicitly string-converted. These features emphasize efficient use of the available 16 KB or 48 KB RAM, prioritizing basic operations over advanced typing.

Keywords and Commands

Sinclair BASIC employs a tokenized system where keywords, functions, and operators are represented by single-byte codes to optimize usage and execution speed on resource-constrained hardware. This approach stores programs compactly, with each keyword replaced by a unique token value ranging from 0xA5 to 0xFF in , entered via the keyboard's keyword mode for rapid input. For instance, the PRINT keyword is tokenized as 0xF5. The core set of keywords in the ZX Spectrum 48K version totals approximately 86, encompassing statements, functions, and operators categorized by function. Input/output keywords include PRINT (0xF5) for screen or printer output, INPUT (0xEE) for user data entry, and CLS (0xFB) to clear the display. Mathematical functions feature ABS (0xBD) for absolute value, INT (0xBA) for integer truncation, and RND (0xA5) for pseudo-random numbers between 0 and 1. String manipulation relies on functions such as LEFT(a(a, n) to extract the first n characters from string a,RIGHT, RIGHT(a,n)forthelastncharacters,andCHR, n) for the last n characters, and CHR(code) to convert a numeric code to a character. Unique implementations distinguish Sinclair BASIC from contemporaries. Both "GO TO" (0xEC) and "GOTO" are accepted for unconditional jumps, accommodating varied typing styles. The REM (0xEA) statement enables comments, ignoring all subsequent content on the line with no further statements permitted after it. Direct hardware access is provided by POKE (0xF4), which writes a byte to a , and PEEK (0xBE), which reads a byte from , allowing low-level manipulations like screen graphics alterations. DIM (0xE9) declares arrays with specified dimensions and performs bounds checking to prevent out-of-range access errors. Notably, the IF (0xFA) statement lacks an ELSE clause, requiring workarounds like nested IFs or for alternative execution paths. Multiple statements can be chained on a single line using the colon (:), facilitating compact . Tape and storage operations include RUN (0xF7) to execute a loaded program, LOAD (0xEF) to retrieve , , or screen from cassette, and SAVE (0xF8) to store them, essential for the era's primary media. Later variants, such as the 128K, expand the keyword set with additions like INKEY$ (0xA6) for non-blocking input and PLAY for sound sequences, increasing the total beyond the 48K baseline.
CategoryExamples (Token in Hex)
I/OPRINT (0xF5), INPUT (0xEE), LIST (0xF0)
MathABS (0xBD), INT (0xBA), RND (0xA5), SIN (0xB2)
StringLEFT,RIGHT, RIGHT, CHR$ (0xC2), LEN (0xB1)
ControlIF (0xFA), FOR (0xEB), NEXT (0xF3), REM (0xEA)
MemoryPOKE (0xF4), PEEK (0xBE), DIM (0xE9)
StorageLOAD (0xEF), SAVE (0xF8), RUN (0xF7)

Syntax and Programming Model

Statement Structure

Sinclair BASIC programs are structured as a series of numbered lines, each starting with an integer line number between 1 and 65535, which dictates the sequential execution order from lowest to highest number. These numbers are stored in big-endian 16-bit format within the program's memory layout, allowing the full range while practical limits in editing often cap visible lines at lower values. When entering a new line without specifying a number, the interpreter automatically assigns the next available number, defaulting to an increment of 10 from the previous line to facilitate insertions and edits. Unnumbered lines, entered directly at the prompt, are executed immediately as commands and are not incorporated into the stored program; for example, typing PRINT "Hello" without a line number displays the message on-screen without saving it. Individual statements follow a simple format: a keyword (such as PRINT or INPUT) is followed by any required arguments, and the line is concluded by pressing ENTER to commit it to memory. Multiple statements can reside on the same line, delimited by colons (:), enabling compact code like 10 PRINT "Start": LET A=1: GO SUB 100, which executes each part in sequence. This colon-separated structure supports efficient use of limited line space, though excessive length may strain the editor's display capabilities in earlier models like the ZX81. Expressions embedded in statements, such as those in assignments or conditions, are parsed according to a defined operator precedence to ensure unambiguous evaluation. Parentheses () have the highest priority for grouping, followed by ^, then * and division / (evaluated left-to-right), and finally + and - (also left-to-right). For instance, the expression 2 + 3 * 4 resolves to 14, as multiplication precedes addition, but (2 + 3) * 4 yields 20 due to parentheses overriding the default order. Assignments assign the result of an expression to a variable using the optional LET keyword, as in LET X = 5 + 3 or simply X = 8; omitting LET is standard for brevity. Numeric variables not explicitly assigned default to 0 upon first reference, while string variables default to an "". The interpreter performs syntax validation immediately upon line entry, scanning for errors like malformed keywords or unbalanced elements before storing the line. Invalid input triggers a "" report with the offending line number, accompanied by a flashing cursor; during prolonged input, the (B on the keyboard) can interrupt the process to abort the entry. This real-time checking helps prevent runtime issues but requires careful entry to avoid frequent corrections.

Control Flow and Expressions

Sinclair BASIC provides essential control flow mechanisms for conditional execution, looping, and subroutine calls, enabling structured program logic within its line-numbered, interpreted environment. These features, inherited from earlier dialects like those in the ZX80 and ZX81, emphasize simplicity and direct integration with the BASIC interpreter's tokenization system, though they impose limitations such as single-line conditionals in core versions. Expressions form the foundation, evaluating numerically with relational and logical operators to drive decisions. The IF...THEN statement handles conditional execution in a single-line format, where the condition is a numeric expression evaluated as true if non-zero and false if zero. Syntax follows IF expression THEN statement, with the statement typically a command like PRINT or GOTO; multi-line blocks are not supported until later extensions. For example, 10 IF A > 0 THEN PRINT "Positive" executes the PRINT only if A exceeds zero, otherwise skipping to the next line. This design avoids complex nesting but relies on GOTO for broader branching, as direct jumps from IF to line numbers require explicit GOTO inclusion. Unconditional jumps use line_number, transferring execution to the specified line or the subsequent one if it does not exist, facilitating basic program flow redirection. For multi-way branching, ON expression GOSUB achieves selection among subroutines, where the integer value of the expression (rounded down) indexes a comma-separated list of line numbers, executing the corresponding GOSUB or defaulting to the last if out of range. An example is 10 ON B GOSUB 100,200,300, which calls line 100 if B=1, 200 if B=2, and 300 otherwise. Looping primarily employs FOR...NEXT, initializing a single-letter control variable to a start value, iterating until exceeding a limit with an optional STEP increment (defaulting to 1). The syntax is FOR variable=start TO limit [STEP step]: statements: NEXT variable, where the loop body executes as long as the variable remains within bounds, considering the step's sign for direction. For instance, 10 FOR I=1 TO 10: PRINT I: NEXT I outputs numbers 1 through 10. Jumping into or out of loops disrupts variable tracking, potentially causing errors. In the ZX Spectrum 128K and later variants, WHILE...WEND introduces condition-based looping, repeating statements while a non-zero expression holds true: WHILE expression: statements: WEND, offering flexibility beyond fixed iterations. Subroutines utilize GOSUB line_number to push the current position onto a stack and jump to the target line, returning via RETURN to resume after the call. Nesting is limited by available for the stack; exceeding available space triggers an out-of-memory error. Example usage: 10 GOSUB 100: 20 PRINT "Main": STOP paired with 100 PRINT "Subroutine": RETURN. Improper balancing, such as RETURN without GOSUB, generates an error. Expressions in Sinclair BASIC are numeric by default, using with relational operators (=, <>, <, >, <=, >=) yielding 1 (true) or 0 (false). Logical operators AND, OR, and NOT combine these, with AND true only if both operands are non-zero, OR true if at least one is, and NOT inverts the logical value, returning 1 if the input is 0 and 0 if non-zero, consistent in and versions. Operator precedence prioritizes relations, then NOT, AND, and OR last, allowing constructs like IF (A > 5 AND B < 10) OR NOT C=0 THEN [GOTO](/page/Goto) 50. In early implementations such as /, AND and OR exhibit bitwise behavior on integer parts, but versions treat them logically for consistency. Booleans integrate seamlessly as numerics, non-zero denoting true.

Graphics and Sound Integration

Sinclair BASIC provides direct access to the ZX Spectrum's graphics hardware through a set of dedicated commands that enable -level manipulation and attribute control, allowing programmers to create visual output without resorting to for basic operations. The screen resolution is 256 wide by 192 high, divided into 32 columns and 24 rows of 8×8 character cells, supporting eight colors numbered 0 to 7 (black, blue, red, magenta, green, cyan, yellow, white). The core graphics commands include PLOT x, y, which sets a single pixel at coordinates (x, y) using the current ink color, where x ranges from 0 to 255 (left to right) and y from 0 (bottom) to 191 (top); and DRAW x, y, which draws a straight line from the current position by x pixels horizontally and y pixels vertically. For example, the sequence PLOT 100, 100: DRAW 50, 0 would plot a point and then draw a horizontal line 50 pixels to the right. Additional commands like CIRCLE x, y, r draw a circle centered at (x, y) with radius r, and POINT(x, y) returns 1 if the pixel is inked or 0 if paper, facilitating or status checks. Attribute commands control color and display modes across entire character cells, as the hardware applies colors in 8×8 blocks rather than per pixel. INK n sets the foreground color, PAPER n the background, and BORDER n the screen border, all using values 0-7. Modes such as FLASH 1 cause attributes to alternate between ink and paper colors, BRIGHT 1 enables high-intensity colors (4-7), and INVERSE 1 swaps ink and paper for text or pixels; these can be combined for effects like INK 2: PAPER 7: BRIGHT 1. The CLS command clears the screen to the current paper color and resets the plot position to (0,0). User Defined Graphics (UDGs) allow customization of 21 characters (A to U), each an 8×8 pattern defined by poking binary values into memory addresses obtained via USR "letter", enabling reusable sprites like icons or game elements; for instance, a program might use FOR n=0 TO 7: POKE USR "A" + n, BIN 01111110: NEXT n to create a simple block shape. Sound integration in the 48K relies on the simple BEEP duration, pitch command, which generates a square wave through the built-in piezoelectric speaker for a specified duration in seconds and pitch in semitones relative to middle C (0), producing monophonic tones suitable for basic effects or melodies but limited to one note at a time. An example is BEEP 0.5, 12 for a half-second note one above middle C. In the 128K model, the AY-3-8912 adds via the PLAY "string1"[, "string2"[, "string3"]] command, where each string specifies notes, octaves, tempo, and durations for up to three channels (e.g., PLAY "OT2L4CDEF", PLAY "O5L2G", PLAY "O3L8C" for a basic tune), leveraging the chip's three tone generators, channel, and control for more complex music. These features, while innovative for a low-cost , impose limitations: graphics operations in are slow due to interpreted execution, often requiring for smooth ; there are no hardware sprites, so all visuals rely on software plotting; and color occurs within 8×8 cells, restricting attribute changes without visual artifacts. This encouraged hybrid programming, integrating BASIC for setup with assembly for performance-critical and routines.

Official Versions

ZX80 and ZX81 Implementations

The ZX80, launched in 1980, incorporated a compact 4K ROM-based interpreter for Sinclair BASIC, limited to integer arithmetic without support for floating-point operations or sound generation. This version featured approximately 22 keywords, enabling basic programming constructs such as PRINT, INPUT, FOR-NEXT loops, and GOTO statements, but constrained users to 16-bit integer values for calculations. The display system was notably slow, refreshing only during pauses for user input, which resulted in a blinking cursor and blank screen during program execution to conserve the machine's 1K RAM. Programs were stored and retrieved exclusively via audio cassette tapes connected through the EAR and MIC ports, with no built-in support for lowercase characters, relying instead on an uppercase-only character set. In 1981, the ZX81 introduced an enhanced 8K ROM implementation of Sinclair BASIC, expanding capabilities with floating-point arithmetic offering about 9-10 digits of precision, string manipulation, and a total of around 64 keywords including advanced functions like SIN, COS, LEN, and STR$. This allowed for more versatile programs handling real numbers up to approximately 10^38 and dynamic string operations, such as concatenation and length checks. A key innovation was the addition of FAST and SLOW modes to optimize video RAM usage: SLOW mode enabled simultaneous program execution and stable screen display by dedicating CPU cycles to video generation, while FAST mode prioritized computation speed (up to four times faster) but suspended the display during runs, causing flicker until interrupted. Like its predecessor, the ZX81's interpreter was embedded in ROM, with SAVE and LOAD commands facilitating cassette-based storage, and it maintained the absence of lowercase support. Unique quirks in these implementations included the lack of a TAB function within PRINT statements, requiring manual spacing via repeated spaces or commas for alignment, and frequent encounters with out-of-memory errors ( 4) on the base 1K RAM configuration, often triggered by even modest programs or display file expansion. These early versions prioritized to fit resource-constrained hardware, making them suitable primarily for simple educational and hobbyist applications. Their affordability and accessibility significantly influenced computing education in schools during the early , introducing thousands to programming concepts.

ZX Spectrum 48K BASIC

The 48K BASIC implementation resides in a 16 KB ROM, providing the core interpreter and system monitor for the original 1982 model with 48 KB of total RAM, of which 32 KB is fully addressable for user programs and data. This version introduces a full system using a 5-byte format (one byte for the exponent and four for the mantissa), enabling precise handling of numbers beyond the range of - to +, including support for and transcendental functions like , COS, and EXP computed via Chebyshev approximations. The BASIC dialect features approximately 85 keywords, encompassing commands, functions, and relational operators, all tokenized during input to optimize storage and execution efficiency in the constrained memory environment. Key enhancements over prior Sinclair models include integrated color support through keywords like INK and PAPER, which set foreground and background colors for characters using a 1-bit attribute system per 8x8 pixel block, allowing 8 colors each with options for bright, flash, inverse, and overprint effects via BRIGHT, FLASH, INVERSE, and OVER. Sound generation is enabled by the BEEP command, which produces tones by toggling the speaker via the Z80's EAR port at specified durations and pitches, such as BEEP 2,0 for a simple beep. Cassette tape operations are expanded with LOAD, SAVE, MERGE, and VERIFY, where VERIFY compares loaded data against the original program to detect loading errors, facilitating reliable program storage and retrieval on audio cassettes at speeds up to 1500 baud. The memory layout allocates the display file (screen memory) to addresses 16384–22527, storing 6144 bytes of pixel data in a 256x192 resolution bitmap followed by 768 bytes of color attributes, while BASIC variables occupy 23734–65535, with the system variables table at 23552–23734 providing flags and pointers for runtime state. Programs themselves reside in RAM starting from address 23755 upward, dynamically expanding as needed until limited by available . This fixed mapping ensures consistent access but requires careful management to avoid overwriting the screen or variables during runtime. Performance is governed by the Z80 microprocessor clocked at 3.5 MHz, with the interpreter executing tokenized statements directly from RAM; however, video contention—where the ULA arbitrates access between the CPU and display refresh—effectively reduces RAM access speed to about half, impacting loop-intensive code. Tokenization compresses keywords into single bytes (e.g., PRINT as token 0xAC), minimizing parse time during the initial scanning phase and allowing faster repeated executions compared to text-based s. Programmers often extended functionality using the POKE command to directly modify , accessing hidden features such as fullscreen display modes by altering attributes (e.g., POKE 23624,0 to set permanent black ) or screen timing flags in the system variables, bypassing the standard 1-pixel for edge-to-edge graphics in custom applications. This served as the foundational for subsequent ZX Spectrum variants, including the 128K model.

ZX Spectrum 128K, +2, +3, and +2A/B Variants

The ZX Spectrum 128K, released in 1985, featured a 32 KB ROM that doubled the size of the original 48K model's ROM to accommodate enhanced BASIC functionality and hardware support for the expanded 128 KB RAM. This version of Sinclair BASIC, often referred to as 128 BASIC, required users to type keywords fully letter-by-letter rather than using the abbreviated keyword keys from the 48K model, promoting a more standard editing interface while maintaining compatibility with existing programs. A key addition was the SPECTRUM command, which allowed seamless switching to the original 48K BASIC mode for running software incompatible with the new features, effectively paging in the 48K ROM routines and limiting RAM access to 48 KB. Additionally, array dimensions were expanded to support up to 128 KB of RAM, enabling larger data structures without the constraints of the earlier model. Sound capabilities were significantly improved with the introduction of the PLAY command, which interfaced directly with the new AY-3-8912 three-channel , allowing up to three simultaneous notes defined by string variables for pitch, duration, and (e.g., PLAY "T180 O6 C D E"). This supplemented the existing BEEP command from 48K , providing MIDI-compatible control for more complex melodies without requiring . The interface also included minor UI enhancements, such as an options menu accessed via EDIT or CMND keys for commands like RENUMBER and SCREEN, which optimized program editing and display management. Compatibility with 48K software was further ensured by a *RESET sequence that rebooted into 48K mode, preserving the core syntax while integrating the new . The +2 (grey model, 1986) retained the 32 KB ROM structure of the 128K but introduced subtle interface tweaks, including a built-in tape counter for easier cassette management and refined handling for command entry. Its BASIC implementation was functionally identical to the 128K version, supporting the same command for mode switching and PLAY for , with no major keyword additions but improved stability in RAM paging routines. File handling on the internal "silicon disc" (a RAM-based storage emulation) used commands like CAT ! and ERASE ! to list and delete files, extending tape-based operations to the expanded memory. The +3 (1987) advanced disk support with the integration of a +D floppy drive, prompting expansions to for . New keywords included to catalog files on disk or drive (e.g., CAT #1 for drive 1), ERASE to remove files with confirmation (e.g., ERASE "filename"), FORMAT to initialize disks (e.g., FORMAT #1, erasing all contents), and MOVE to rename or transfer files (e.g., MOVE "old" TO "new"). These commands built on Interface 1 precedents but adapted for the +D system, with offering options like EXP to show hidden files and sorted output. The 32 KB ROM (version 2) maintained 128K RAM access and the PLAY command, while compatibility modes via or *RESET allowed fallback to 48K for legacy tapes. The later +2A and +2B models (1987–1988), produced by Amstrad, used a revised 32 KB ROM (version 3) that reverted closer to the 48K BASIC structure in its core routines for better compatibility, while retaining 128K access through the SPECTRUM command. This version included bug fixes for I/O operations, such as improved printer handling via an enhanced COPY command (e.g., COPY CHR$ TO LPRINT) and stabilized port access with OUT, reducing crashes in peripheral interactions compared to earlier 128K ROMs (versions 0–1). Although lacking the +3's floppy drive, the BASIC retained disk-related keywords like CAT, ERASE, FORMAT, and MOVE, which functioned on emulated storage or Microdrives but prompted errors without hardware; array limits remained at 128 KB, and sound integration via PLAY was unchanged. The *RESET sequence continued to enable 48K mode, ensuring broad software support across the variant lineup.

Other Sinclair and Timex Releases

The Timex Sinclair TS 1000, released in 1982 as a licensed adaptation of the Sinclair ZX81 for the North American market, featured an 8 KB ROM containing a variant of Sinclair BASIC optimized for the machine's hardware. This implementation retained the core syntax and commands of the ZX81 BASIC, including one-key entry for keywords, but incorporated US QWERTY keyboard mappings to align with American typing conventions while preserving the original function assignments. No significant new BASIC commands were added, though the system supported external peripherals like the TS 1510 memory expansion for joystick input via POKE operations rather than dedicated BASIC syntax. In 1983, Timex introduced the TS 1500, an upgraded model with 16 KB of built-in RAM and the same 8 KB ROM-based as the TS 1000, ensuring full compatibility with existing ZX81/TS 1000 software. Minor software adjustments addressed hardware differences, such as refined printer output handling, but the dialect remained unchanged in structure and capabilities, emphasizing the machine's focus on affordability over expanded programming features. The Timex Computer 2068 (TS 2068 in the ), launched in late 1983, utilized a 24 KB ROM operating system that included a 16 KB BASIC interpreter known as BASIC64, extending the Sinclair Spectrum's BASIC with support for enhanced hardware. BASIC64 introduced high-resolution graphics modes, including a 512 × 192 mode with two colors accessible via commands like PLOT* x,y for plotting with specified and INK* n or PAPER* n for color selection, alongside the standard 256 × 192 mode supporting 16 colors through attribute-based rendering. Additional graphics commands such as LINE x1,y1,x2,y2 and CIRCLE* x,y,r enabled more advanced drawing, while ATTR# allowed attribute manipulation in extended modes, all without altering core BASIC syntax. Timex Extended BASIC, integral to the TS 2068, added peripheral support including serial communication via OPEN# n and PRINT #n for device channels, as well as disk operations like SAVE * and LOAD * for the FDD3000 floppy system. It maintained compatibility with Spectrum BASIC programs but introduced extra display modes, such as 64-column text output on and variable-width text up to 85 columns on channel #5, enhancing usability for text-heavy applications. Keyboard function keys were supported through hardware scanning rather than a dedicated FKEY command, allowing programmable shortcuts via INKEY$ or similar functions. These variants were produced exclusively for the US market under a licensing agreement between Timex Corporation and Sinclair Research, with distribution limited by Timex's withdrawal from home computing in early 1984 amid competitive pressures. Overall, the implementations introduced no major syntactic departures from their Sinclair origins, prioritizing hardware-specific extensions like graphics and I/O over fundamental language redesign.

Extensions, Derivatives, and Modern Implementations

Third-Party Interpreters and Compilers

Third-party developers created several interpreters and compilers to extend and optimize Sinclair BASIC for the , addressing limitations in speed, structure, and functionality while maintaining compatibility with the core 48K dialect. These tools were particularly popular in the mid-1980s among hobbyists and professional programmers seeking to produce more efficient software without fully switching to . One prominent interpreter was Beta BASIC, released in 1983 by Betasoft and authored by Andrew Wright. It expanded Sinclair BASIC with over 100 new commands and functions, including support for through named procedures defined via DEF PROC, which allowed parameter passing (by value or reference using REF), optional parameters with default values, and . Local variables could be declared with LOCAL within procedures to scope them and avoid global conflicts, enabling more modular code. Additional features included multiline IF...THEN...ELSE constructs, DO...LOOP with conditional EXIT, enhanced graphics commands like FILL and GET, and Microdrive compatibility. Beta BASIC improved execution speed for certain operations, such as FOR-NEXT loops up to 17 times faster, and offered syntax checking on entry for easier editing. It retained full compatibility with existing Spectrum BASIC programs, though it required 16K RAM and added some interpretive overhead compared to native code. Compilers provided even greater performance gains by translating BASIC to Z80 machine code. The BLAST compiler, released in 1985 by Oxford Computer Systems, was designed for maximum compatibility and optimization, supporting all standard Sinclair BASIC commands including strings, DATA statements, and floating-point arithmetic. It produced executable code that ran up to hundreds of times faster than interpreted BASIC, depending on the program, while preserving features like error trapping and break-in support. BLAST emphasized ease of use with automatic optimization passes to minimize code size and maximize speed, making it suitable for professional applications such as and utilities. However, like many compilers of the era, it lacked support for advanced extensions in third-party BASICs and could increase program size due to inline expansions. Another influential compiler was HiSoft BASIC, introduced in 1986 by HiSoft, which targeted the 48K, 128K, and Plus 2 models. It compiled nearly all of Sinclair BASIC—including user-defined functions, floating-point math, and string handling—into efficient , achieving speeds significantly higher than the interpreter (e.g., up to 100 times for loops). The tool integrated well with existing programs via a simple compilation process and supported mixed BASIC-assembly development. HiSoft BASIC was valued for its reliability in producing commercial-grade software, though it imposed limitations like no multi-dimensional arrays in some modes and required careful management of memory for larger programs. These compilers and interpreters were widely adopted for creating polished demos and games, demonstrating Sinclair BASIC's versatility despite its original constraints.

Ports and Successors on Other Platforms

Locomotive BASIC, the built-in interpreter for the series released in 1984, introduced significant extensions tailored to the CPC's hardware capabilities. Unlike Sinclair BASIC's use of +1 for true values, Locomotive BASIC employed -1, which facilitated partial compatibility for ported programs but required adjustments during translation. Key additions included the MODE command for switching between resolutions (e.g., MODE 0 for 160x200 pixels with 16 colors) and enhanced sound commands like for three-channel output, expanding beyond Sinclair BASIC's rudimentary BEEP. MSX-BASIC, standardized for the platform in 1983, utilized a token-based system reminiscent of 's compact keyword encoding but was fundamentally derived from 1.0, with extensions for MSX-specific hardware. It supported cartridge-based enhancements, allowing ROM add-ons to extend functionality such as sprite handling (up to 32 sprites across four planes) and advanced graphics via DRAW strings for vector plotting. While sharing Sinclair-like efficiency in tokenized program storage, MSX-BASIC emphasized cross-compatibility across manufacturers, incorporating commands like PLAY for not present in the original Sinclair dialect. The , positioned as an advanced successor to the and released in 1989, featured SAM BASIC, a heavily based on the Spectrum's Beta BASIC extension of Sinclair BASIC. It retained core elements like the command-line editor and string/ handling but added and light-pen support through ports 248 and 504 for coordinate input, enabling interactive commands such as CIRCLE and FILL. used five-byte representation for extended range and precision, similar to Sinclair's 40-bit format but with improved memory management for up to 217K programs on 256K systems; procedures via DEFPROC/ENDPROC introduced local variables and , marking a shift toward . In modern implementations, the ZX-Uno FPGA board from the 2010s recreates Sinclair BASIC through accurate ZX Spectrum 48K and 128K cores, supporting original ROMs or alternatives like SE Basic IV. It incorporates USB for power and FPGA programming, alongside PS/2 mouse compatibility via protocol and SD card access for loading TAP/Z80 files, enhancing portability without altering the BASIC dialect. Similarly, Pico-based emulations like PicoZX, introduced in 2024, run Sinclair BASIC within a full Spectrum environment, outputting to VGA or LCD while adding USB support as virtual /Sinclair interfaces. These ports maintain the original keyword set—such as PLOT and PRINT—for conceptual fidelity but leverage modern peripherals for renewed accessibility.

Contemporary Emulation and Revivals

Contemporary emulation efforts have preserved Sinclair BASIC's functionality through highly accurate software recreations of the original hardware environments. The Fuse emulator, initiated in 1999 and actively developed since, provides faithful interpretation of Sinclair BASIC across various ZX Spectrum models, including support for 48K, 128K, and clone variants, enabling users to run original programs with precise timing and peripheral emulation. Spectaculator, a cross-platform emulator available for Windows, Android, and iOS since the early 2000s, offers an authentic Sinclair BASIC experience with additional tools such as snapshot loading, tape emulation, and built-in debugging capabilities for inspecting program execution and memory states. Software revivals have extended Sinclair BASIC's reach to modern development workflows. The ZX BASIC compiler, developed by Boriel starting in the late 2000s, allows programmers to write enhanced BASIC code on PCs and compile it directly to Z80 compatible with emulators or hardware, incorporating modern syntax extensions while maintaining compatibility with original commands. Online interpreters from the , such as JSSpeccy, enable browser-based execution of Sinclair BASIC programs without local installation, supporting instant loading of tapes and snapshots for educational and nostalgic use. Hardware revivals include the Next, an FPGA-based recreation launched via in 2017 and entering production thereafter, which layers advanced extensions onto the original Sinclair BASIC implementation. These enhancements, powered by the TBBlue FPGA core, introduce commands for multilayer sprites, hardware scrolling, and expanded color palettes, allowing developers to create more complex programs while preserving with 48K BASIC listings. As of November 2025, ongoing developments include a third campaign launched in July 2025 for Issue 3, firmware version 24.11, and roadmap presentations at Crash Live 2025. The World of Spectrum archive, maintained from the 1980s through the 2020s until its official sunset in 2023, has been instrumental in community preservation by hosting thousands of Sinclair BASIC source codes, manuals, and utilities, facilitating their accessibility via emulators and modern tools. This has supported ongoing creative output, including modern games like remakes of classics such as , reimplemented in Sinclair BASIC using compilers and emulators to leverage the language's simplicity for and maze navigation. Post-Amstrad's closure of its division in the early , open-source initiatives have addressed key limitations in Sinclair BASIC emulation and extensions, such as integrating support for mapping the original 32x8 pixel character set to contemporary text encoding, enabling better in preserved programs. Efforts like the ZX BASIC also provide faster compilation times compared to interpretive execution, reducing development cycles for hobbyists while filling preservation gaps through freely available repositories on platforms like .

References

Add your contribution
Related Hubs
User Avatar
No comments yet.