Jump to content

Sinclair BASIC: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Clarify print positioning.
Official versions: default image size
 
(47 intermediate revisions by 20 users not shown)
Line 3: Line 3:
{{short description|Dialect of the programming language BASIC}}
{{short description|Dialect of the programming language BASIC}}
{{Use British English|date=November 2018}}
{{Use British English|date=November 2018}}
{{multiple issues|
{{manual|date=October 2012}}
{{more citations needed|date=October 2012}}
}}


{{Infobox programming language
{{Infobox programming language
Line 28: Line 24:
| influenced =
| influenced =
| programming language =
| programming language =
| platform = [[ZX80]], [[ZX81]], [[ZX Spectrum|ZX Spectrum, +, 128, +2, +3]], [[Timex Sinclair 2068|T/S 2068]], [[Timex Computer 3256|TC 3256]]
| platform = [[ZX80]], [[ZX81]], [[ZX Spectrum|ZX Spectrum, +, 128, +2, +3]], [[Timex Sinclair 2068|T/S 2068]], [[Timex Computer 3256|TC 3256]]
| operating system =
| operating system =
| license = [[Proprietary software|Proprietary]]
| license = [[Proprietary software|Proprietary]]
Line 35: Line 31:
}}
}}


'''Sinclair BASIC''' is a [[dialect (computing)|dialect]] of the programming language [[BASIC]] used in the [[8-bit]] [[home computer]]s from [[Sinclair Research]] and [[Timex Sinclair]]. The Sinclair BASIC [[interpreter (computing)|interpreter]] was made by Nine Tiles Networks Ltd.<ref name="Garfield"/>
'''Sinclair BASIC''' is a [[dialect (computing)|dialect]] of the programming language [[BASIC]] used in the [[8-bit]] [[home computer]]s from [[Sinclair Research]], [[Timex Sinclair]] and [[Amstrad]]. The Sinclair BASIC [[interpreter (computing)|interpreter]] was written by Nine Tiles Networks Ltd.<ref name="Garfield"/>

Designed to run in only 1&nbsp;KB of [[dynamic random access memory|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 [[Parsing|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 arithmetic|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.

Performance became a more serious issue with the release of the [[ZX&nbsp;Spectrum]] in 1983, 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&nbsp;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==
==History==
[[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.{{sfn|Adamson|Kennedy|p=63}} 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&nbsp;KB of RAM and 4&nbsp;KB of ROM. Grant suggested using the [[Forth (programming language)|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&nbsp;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'''.{{sfn|Adamson|Kennedy|1986|p=64}}
Sinclair BASIC was originally developed in 1979 for the [[ZX80]] by Nine Tiles. The programmers were John Grant, the owner of Nine Tiles, and [[Steve Vickers (computer scientist)|Steve Vickers]].


It was initially an incomplete implementation of the 1978 [[American National Standards Institute]] (ANSI) minimal BASIC standard with integer arithmetic only, termed '''4K BASIC''' (for its ROM size) for the ZX80. It evolved through the floating-point '''8K BASIC''' for the [[Sinclair ZX81|ZX81]] and [[Timex Sinclair 1000|T/S 1000]] (which was also available as an upgrade for the ZX80<ref name=8Kupgrade>{{Cite web|url=http://www.fruitcake.plus.com/Sinclair/ZX80/ROMUpgrade/ZX80_ROMUpgrade.htm|title=ZX80 - 8K BASIC ROM Upgrade|website=www.fruitcake.plus.com}}</ref>), and became an almost complete version in the 16&nbsp;KB ROM [[ZX Spectrum]] (known as '''48K BASIC''').
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&nbsp;KB. This work was assigned to [[Steve Vickers (computer scientist)|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 [[trigonometry|trig]] functions, which were expected of any BASIC from that era, producing '''8K BASIC'''.{{sfn|Adamson|Kennedy|1986|p=70}} 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.<ref name=8Kupgrade>{{Cite web|url=http://www.fruitcake.plus.com/Sinclair/ZX80/ROMUpgrade/ZX80_ROMUpgrade.htm|title=ZX80 8K BASIC ROM Upgrade|website=www.fruitcake.plus.com}}</ref>


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&nbsp;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&nbsp;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&nbsp;KB Spectrum was no longer sold and most existing ones in use had been upgraded to 48&nbsp;KB.<ref name="worldofspectrum.org" /><ref name=":0" /> 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.<ref name=reg>{{cite magazine |first=Tony |last=Smith |title=Happy 30th Birthday, Sinclair ZX Spectrum |date=23 April 2012 |magazine=The Register |url=https://www.theregister.com/2012/04/23/retro_week_sinclair_zx_spectrum_at_30?page=2}}</ref>
It is present in all ZX Spectrum compatibles and [[List of ZX Spectrum clones|clones]], with more advanced systems also offering expanded versions like '''128K BASIC''', '''+3 BASIC''', '''T/S 2000 BASIC''', '''BASIC64''' or '''Timex Extended Basic'''.

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.{{sfn|Adamson|Kennedy|1986|p=88}} 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 Sinclair|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'''.<ref name=":0" />

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 [[List of ZX Spectrum clones|clones]] of the Spectrum were introduced. These included '''+3 BASIC''', '''BASIC64''' and '''Timex Extended Basic'''.<ref name=":0" /><ref name="worldofspectrum.org" />

As of 2015, interpreters exist for modern [[operating system]]s,<ref>{{Citation |last=Dunn |first=Paul |title=SpecBAS |date=2022-12-07 |url=https://github.com/ZXDunny/SpecBAS |access-date=2022-12-12}}</ref> and older systems,<ref>{{Cite web |title=CSDb |url=https://csdb.dk/search/?seinsel=releases&search=spectrum+emulator&all=1 |access-date=2022-12-12 |website=Commodore 64 Scene Database}}</ref> that allow Sinclair Basic to be used easily.

==Description==
===Program editing===
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 {{keypress|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 {{code|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 {{key press|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 key]]s and commits their changes by pressing {{key press|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 {{key press|P}} key on the keyboard would cause the entire keyword {{code|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 {{key press|P}} again at this point would enter a single letter "P".

Keys generally had two separate keywords assigned to them{{snd}} one above it and one below. Pressing the key in "K" mode would enter the keyword above the key, like {{code|PRINT}} for {{key|P}}. If the system was in "L" mode, one could return to "K" by pressing the [[shift key]]{{snd}} the systems did not initially support [[lowercase]] text, so the shift was not otherwise needed. The keywords below the keys required a second keystroke, {{key press|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&nbsp;KB of RAM. This single-character representation included multi-character items like {{code|<>}}. 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&nbsp;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 {{code|BEEP}} required one to type {{keypress|CAPS SHIFT|SYMBOL SHIFT}} to access extended mode (later models include a separate {{keypress|EXTENDED MODE}} key), keeping {{keypress|SYMBOL SHIFT}} held down, and then and pressing {{keypress|Z}}. To improve the complex entry on the Spectrum, the keywords were colour-coded to indicate the required mode:{{sfn|Vickers|1983|p=7–8}}
* {{font color|white|gray|White}}: key only
* {{font color|red|gray|Red}} on the key itself: {{keypress|SYMBOL SHIFT}} plus the key
* {{font color|green|black|Green}} above the key: {{keypress|EXTENDED MODE}} followed by the key
* {{font color|red|black|Red}} below the key: {{keypress|EXTENDED MODE}} followed by {{keypress|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{{snd}} like string and numeric constants and variable names{{snd}} 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 point]]s' offset from zero is different from ASCII's offset of 65. Other characters, like punctuation, may have been moved about even more. The [[ZX&nbsp;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 character set|ZX80]] or [[ZX81 character set]]s. All of these different but related character sets included Sinclair BASIC tokens.

===Data types===
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 (data structure)|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, <code>A</code>, <code>A$</code>, <code>A()</code> and <code>A$()</code> 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 <syntaxhighlight lang="basic" inline>LET Number Of Apples = 5</syntaxhighlight> is the same as <syntaxhighlight lang="basic" inline>LET numberofapples = 5</syntaxhighlight> 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&nbsp;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&nbsp;bytes under certain conditions.

===Keyword details===
The ZX81 '''8K BASIC''' used the shorter forms <code>GOTO</code>, <code>GOSUB</code>, <code>CONT</code> and <code>RAND</code>, whereas the Spectrum '''48 BASIC''' used the longer forms <code>GO&nbsp;TO</code>, <code>GO&nbsp;SUB</code>, <code>CONTINUE</code> and <code>RANDOMIZE</code>. The ZX80 '''4K BASIC''' also used these longer forms but differed by using the spelling <code>RANDOMISE</code>. The ZX81 '''8K BASIC''' was the only version to use <code>FAST</code>, <code>SCROLL</code>, <code>SLOW</code> and <code>UNPLOT</code>. The ZX80 '''4K BASIC''' had the exclusive function <code>TL$()</code>; it was equivalent to the string operator {{nowrap|<code>(2 TO )</code>}} 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. <code>&lt;=</code>, <code> &gt;=</code>, <code>&lt;&gt;</code>, <code>""</code> (tokenized on the ZX81 only), <code>**</code> (replaced with <code>↑</code> 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 <code>PRINT</code> and output its value with <code>PRINT PRINT</code>. 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 <syntaxhighlight lang="basic" inline>LET</syntaxhighlight> (i.e., <syntaxhighlight lang="basic" inline>LET a=1</syntaxhighlight> not only <syntaxhighlight lang="basic" inline>a=1</syntaxhighlight>). 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; <code>SIN x</code> was sufficient, no <code>SIN(x)</code> needed (though the latter was allowed). The 4K BASIC ROM of the ZX80 had a short list of exceptions to this: the functions <code>CHR$()</code>, <code>STR$()</code>, <code>TL$()</code>, <code>PEEK()</code>, <code>CODE()</code>, <code>RND()</code>, <code>USR()</code> and <code>ABS()</code> 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.<ref>{{Cite web|url=https:/upwiki/wikipedia/commons/5/54/Sinclair_ZX80_%281980%29_-_Computer_History_Museum.jpg|title=Picture of ZX80}}</ref>

'''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:

* <code>PLAY</code>, which operated the 128k models' [[General Instrument AY-3-8910]] music chip
* <code>SPECTRUM</code>, 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,<ref name="Disassembly"/><ref>{{Cite book |last=Sinclair |url=http://archive.org/details/128_20220808_202208 |title=ZX Spectrum 128 Introducción y Guía de Funcionamiento |publisher=Sinclair Research Ltd and Investronica, S. A. |year=1985 |pages=9}}</ref> one of which was undocumented:

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


Unlike the <code>LEFT$()</code>, <code>MID$()</code> and <code>RIGHT$()</code> functions used in the ubiquitous Microsoft BASIC dialects for home computers, parts of strings in Sinclair BASIC are accessed by numeric range. For example, {{nowrap|<code>a$(5 TO 10)</code>}} gives a substring starting with the 5th and ending with the 10th character of the variable <code>a$</code>. Thus, it is possible to replace the <code>LEFT$()</code> and <code>RIGHT$()</code> commands by simply omitting the left or right array position respectively; for example {{nowrap|<code>a$( TO 5)</code>}} is equivalent to <code>LEFT$(a$,5)</code>. Further, <code>a$(5)</code> alone is enough to replace <code>MID$(a$,5,1)</code>.
As of 2015, interpreters exist for modern operating systems,<ref>{{Citation |last=Dunn |first=Paul |title=SpecBAS |date=2022-12-07 |url=https://github.com/ZXDunny/SpecBAS |access-date=2022-12-12}}</ref> and older systems,<ref>{{Cite web |title=CSDb |url=https://csdb.dk/search/?seinsel=releases&search=spectrum+emulator&all=1 |access-date=2022-12-12 |website=Commodore 64 Scene Database}}</ref> that allow Sinclair Basic to be used easily.


==Syntax==
==Syntax==
===Keywords===
===Keywords===
On the 16K/48K ZX Spectrum ('''48K 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):
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):


{| class="wikitable sortable"
{| class="wikitable sortable"
Line 187: Line 245:
|{{keypress|EXTENDED MODE}} then {{keypress|D}}
|{{keypress|EXTENDED MODE}} then {{keypress|D}}
|Command/other
|Command/other
|Provides numbers and/or strings to use with the <code>READ</code> command{{sfn|Vickers|1983|p=41}} and allows saving the contents of an array to tape when used with the <code>SAVE</code> command{{sfn|Vickers|1983|p=142}} (as <code>SAVE filename DATA array name()</code>
|Provides numbers and/or strings to use with the <code>READ</code> command{{sfn|Vickers|1983|p=41}} and allows saving the contents of an array to tape when used with the <code>SAVE</code> command{{sfn|Vickers|1983|p=142}} (as <code>SAVE filename DATA array name()</code>)
|-
|-
|<code>DEF&nbsp;FN</code>
|<code>DEF&nbsp;FN</code>
Line 259: Line 317:
|{{keypress|U}}
|{{keypress|U}}
|Command
|Command
|Evaluates the <code>condition</code>, and if true, executes the statement that follows the keyword <code>THEN</code> that must come after the condition,{{sfn|Vickers|1983|p=25}} for example <code>IF a=1 THEN LET b=2</code><ref group="note" name="if-else"/>
|Evaluates the <code>condition</code>, and if true, executes the statement that follows the keyword <code>THEN</code> that must come after the condition,{{sfn|Vickers|1983|p=25}} for example {{Code|1=IF a=1 THEN LET b=2|2=basic}}<ref group="note" name="if-else"/>
|-
|-
|<code>IN</code>
|<code>IN</code>
Line 314: Line 372:
|Other
|Other
|
|
* When used in an <code>INPUT</code> statement before a string variable, will not put quotation marks (&quot;&quot;) around its prompt,{{sfn|Vickers|1983|p=101}} for example <code>INPUT &quot;Name: &quot;; LINE n$</code>
* When used in an <code>INPUT</code> statement before a string variable, will not put quotation marks (&quot;&quot;) around its prompt,{{sfn|Vickers|1983|p=101}} for example {{Code|INPUT "Name: "; LINE n$|basic}}
* When used in a <code>SAVE</code> statement so that when the BASIC program being saved is loaded again, it starts automatically at the line number indicated{{sfn|Vickers|1983|p=144}}
* When used in a <code>SAVE</code> statement so that when the BASIC program being saved is loaded again, it starts automatically at the line number indicated{{sfn|Vickers|1983|p=144}}
|-
|-
Line 411: Line 469:
|{{keypress|M}}
|{{keypress|M}}
|Command
|Command
|Halts program execution for the specified delay, in <math>\frac {1}{50}</math> of a second in Europe or <math>\frac {1}{60}</math> in North America{{sfn|Vickers|1983|p=129}} (thus, <code>PAUSE 50</code> halts for one second in Europe)
|Halts program execution for the specified delay, in <math>\tfrac {1}{50}</math> of a second in Europe or <math>\tfrac {1}{60}</math> in North America{{sfn|Vickers|1983|p=129}} (thus, <code>PAUSE 50</code> halts for one second in Europe)
|-
|-
|<code>PEEK</code>
|<code>PEEK</code>
Line 447: Line 505:
|{{keypress|P}}
|{{keypress|P}}
|Command
|Command
|Prints <code>text</code> (which must be one or more strings or numbers separated with semicolons) to the screen{{sfn|Vickers|1983|p=13}}. If used with #0 or #1, it prints in the bottom two (input) lines of the screen; if used with <code>AT</code>, it prints at the specified text coordinates; otherwise, it prints either immediately following the output of any previous <code>PRINT</code> statement (if the previous statement ended in a semicolon), or in the first column of the line below the previous <code>PRINT</code> output{{sfn|Vickers|1983|p=101}}, defaulting to 0,0.
|Prints <code>text</code> (which must be one or more strings or numbers separated with semicolons) to the screen.{{sfn|Vickers|1983|p=13}} If used with #0 or #1, it prints in the bottom two (input) lines of the screen; if used with <code>AT</code>, it prints at the specified text coordinates; otherwise, it prints either immediately following the output of any previous <code>PRINT</code> statement (if the previous statement ended in a semicolon), or in the first column of the line below the previous <code>PRINT</code> output,{{sfn|Vickers|1983|p=101}} defaulting to 0,0.
|-
|-
|<code>RANDOMIZE</code>
|<code>RANDOMIZE</code>
Line 465: Line 523:
|{{keypress|E}}
|{{keypress|E}}
|Command
|Command
|Begins a comment in the source code, meaning that everything after the <code>REM</code> statement is ignored, until the end of the line{{sfn|Vickers|1983|p=16}} — note this includes everything after a colon, which normally begins a new segment: <code>10 REM Nothing to see here : PRINT &quot;Unprintable&quot;</code> will not produce any output, for example
|Begins a comment in the source code, meaning that everything after the <code>REM</code> statement is ignored, until the end of the line{{sfn|Vickers|1983|p=16}} — note this includes everything after a colon, which normally begins a new segment: {{Code|10 REM Nothing to see here : PRINT "Unprintable"|basic}} will not produce any output, for example
|-
|-
|<code>RESTORE</code>
|<code>RESTORE</code>
Line 519: Line 577:
|{{keypress|SYMBOL SHIFT|D}}
|{{keypress|SYMBOL SHIFT|D}}
|Other
|Other
|Indicates the interval used by a <code>FOR</code> statement,{{sfn|Vickers|1983|p=32}} for example <code>FOR n=2 TO 6 STEP 2</code> will skip <code>n=3</code> and <code>n=5</code> in the loop
|Indicates the interval used by a <code>FOR</code> statement,{{sfn|Vickers|1983|p=32}} for example {{Code|1=FOR n=2 TO 6 STEP 2|2=basic}} will skip <code>n=3</code> and <code>n=5</code> in the loop
|-
|-
|<code>STOP</code>
|<code>STOP</code>
Line 537: Line 595:
|{{keypress|EXTENDED MODE}} then {{keypress|Y}}
|{{keypress|EXTENDED MODE}} then {{keypress|Y}}
|Function
|Function
|Converts a number to string.
|Returns the character from the [[ZX Spectrum character set|computer's character set]] corresponding to <code>number</code>{{sfn|Vickers|1983|p=58}}
|-
|-
|<code>TAB</code>
|<code>TAB</code>
Line 567: Line 625:
|{{keypress|EXTENDED MODE}} then {{keypress|L}}
|{{keypress|EXTENDED MODE}} then {{keypress|L}}
|Function
|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.{{sfn|Vickers|1983|p=93}} 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 (computer science)|Side effect]]) and returns the contents of the [[Zylog Z80|Z80]]’s BC [[Processor register|register]] pair.{{sfn|Vickers|1983|p=180}}
|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.{{sfn|Vickers|1983|p=93}} 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 (computer science)|Side effect]]) and returns the contents of the [[Zilog Z80|Z80]]’s BC [[Processor register|register]] pair.{{sfn|Vickers|1983|p=180}}
|-
|-
|<code>VAL</code>
|<code>VAL</code>
Line 573: Line 631:
|{{keypress|EXTENDED MODE}} then {{keypress|J}}
|{{keypress|EXTENDED MODE}} then {{keypress|J}}
|Function
|Function
|Evaluates the <code>string</code> as a number and returns the result;{{sfn|Vickers|1983|p=}} this can perform calculations: <code>VAL &quot;1+2&quot;</code> returns 3, for example, and also evaluates variables and even other <code>VAL</code> statements: <code>LET a=1: VAL &quot;a+VAL &quot;&quot;2&quot;&quot;&quot;</code><ref group="note">A string inside a string must have its quotes doubled in Sinclair BASIC</ref> also returns 3
|Evaluates the <code>string</code> as a number and returns the result;{{sfn|Vickers|1983|p=}} this can perform calculations: <code>VAL &quot;1+2&quot;</code> returns 3, for example, and also evaluates variables and even other <code>VAL</code> statements: {{Code|1=LET a=1: VAL "a+VAL ""2"""|2=basic}}<ref group="note">A string inside a string must have its quotes doubled in Sinclair BASIC</ref> also returns 3
|-
|-
|<code>VAL$</code>
|<code>VAL$</code>
Line 588: Line 646:
|}
|}
{{multiple image
{{multiple image
|width = 400
| width =
|direction = vertical
| direction = vertical
|image1=Sinclair ZX Spectrum.jpg|caption1=ZX Spectrum
| image1 = Sinclair ZX Spectrum.jpg
| caption1 = ZX Spectrum
|image2=ZX Spectrum+.jpg|caption2=ZX Spectrum+
| image2 = ZX Spectrum+.jpg
| caption2 = ZX Spectrum+
}}
}}

===Keyword entry===
In 48K models and older, the keywords are entered via Sinclair's unique keyword entry system, as indicated on the table. The most common commands need one keystroke only; for example, pressing only {{keypress|P}} at the start of a line on a Spectrum produces the full command <code>PRINT</code>. Less frequent commands require more complex key sequences: <code>BEEP</code> (for example) is keyed by pressing {{keypress|CAPS SHIFT}} plus {{keypress|SYMBOL SHIFT}} to access extended mode (later models include an {{keypress|EXTENDED MODE}} key), keeping {{keypress|SYMBOL SHIFT}} held down and pressing {{keypress|Z}}. Keywords are colour-coded on the original Spectrum keyboard to indicate which mode is required:{{sfn|Vickers|1983|p=7–8}}

* {{font color|white|gray|White}}: key only
* {{font color|red|gray|Red}} on the key itself: {{keypress|SYMBOL SHIFT}} plus the key
* {{font color|green|black|Green}} above the key: {{keypress|EXTENDED MODE}} followed by the key
* {{font color|red|black|Red}} below the key: {{keypress|EXTENDED MODE}} followed by {{keypress|SYMBOL SHIFT}} plus the key

The ZX81 '''8K BASIC''' used the shorter forms <code>GOTO</code>, <code>GOSUB</code>, <code>CONT</code> and <code>RAND</code>, whereas the Spectrum '''48K BASIC''' used the longer forms <code>GO&nbsp;TO</code>, <code>GO&nbsp;SUB</code>, <code>CONTINUE</code> and <code>RANDOMIZE</code>. The ZX80 '''4K BASIC''' also used these longer forms but differed by using the spelling <code>RANDOMISE</code>. The ZX81 '''8K BASIC''' was the only version to use <code>FAST</code>, <code>SCROLL</code>, <code>SLOW</code> and <code>UNPLOT</code>. The ZX80 '''4K BASIC''' had the exclusive function <code>TL$()</code>; it was equivalent to the string operator {{nowrap|<code>(2 TO )</code>}} 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. <code>&lt;=</code>, <code> &gt;=</code>, <code>&lt;&gt;</code>, <code>""</code> (tokenized on the ZX81 only), <code>**</code> (replaced with <code>↑</code> 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 <code>PRINT</code> and output its value with <code>PRINT PRINT</code>. 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 <syntaxhighlight lang="basic" inline>LET</syntaxhighlight> (i.e., <syntaxhighlight lang="basic" inline>LET a=1</syntaxhighlight> not only <syntaxhighlight lang="basic" inline>a=1</syntaxhighlight>). 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; <code>SIN x</code> was sufficient, no <code>SIN(x)</code> needed (though the latter was allowed). The 4K BASIC ROM of the ZX80 had a short list of exceptions to this: the functions <code>CHR$()</code>, <code>STR$()</code>, <code>TL$()</code>, <code>PEEK()</code>, <code>CODE()</code>, <code>RND()</code>, <code>USR()</code> and <code>ABS()</code> 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.<ref>{{Cite web|url=https:/upwiki/wikipedia/commons/5/54/Sinclair_ZX80_%281980%29_-_Computer_History_Museum.jpg|title=Picture of ZX80}}</ref>

'''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:

* <code>PLAY</code>, which operated the 128k models' [[General Instrument AY-3-8910]] music chip
* <code>SPECTRUM</code>, 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,<ref name="Disassembly"/><ref>{{Cite book |last=Sinclair |url=http://archive.org/details/128_20220808_202208 |title=ZX Spectrum 128 Introducción y Guía de Funcionamiento |publisher=Sinclair Research Ltd and Investronica, S. A. |year=1985 |pages=9}}</ref> one of which was undocumented:

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

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

===Variable names===
Variables holding numeric values may be any length, while [[String (computer science)|string]] and array variable names must consist of only one alphabetical character. Thus, <syntaxhighlight lang="basic" inline>LET a=5</syntaxhighlight>, <syntaxhighlight lang="basic" inline>LET Apples=5</syntaxhighlight>, <syntaxhighlight lang="basic" inline>LET a$="Hello"</syntaxhighlight>, <syntaxhighlight lang="basic" inline>DIM a(10)</syntaxhighlight> and <syntaxhighlight lang="basic" inline>DIM a$(10)</syntaxhighlight> are all good, while <syntaxhighlight lang="basic" inline>LET Apples$="Fruit"</syntaxhighlight>, <syntaxhighlight lang="basic" inline>DIM Apples(10)</syntaxhighlight> and <syntaxhighlight lang="basic" inline>DIM Apples$(10)</syntaxhighlight> are not.

The long variable names allowed for numeric variables can include alphanumeric characters after the first character, so <syntaxhighlight lang="basic" inline>LET a0=5</syntaxhighlight> is allowed but not <syntaxhighlight lang="basic" inline>LET 0a=5</syntaxhighlight>. The long variable names can also include spaces, which are ignored, so <syntaxhighlight lang="basic" inline>LET number of apples = 5</syntaxhighlight> is the same as <syntaxhighlight lang="basic" inline>LET numberofapples = 5</syntaxhighlight>


==Official versions==
==Official versions==
===4K BASIC===
===4K BASIC===
* ''4K BASIC'' for ZX80<ref>{{Cite web|url=https://www.petervis.com/Sinclair/Sinclair_ZX80_Manual/4k-basic.html|title = Sinclair ZX80 User Manual 4K Basic for ZX80}}</ref> (so named for residing in 4&nbsp;[[kibibyte|KiB]] [[read-only memory]] (ROM)), was developed by John Grant of Nine Tiles for the ZX80. It has integer-only arithmetic.
''4K BASIC'' for ZX80<ref>{{Cite web|url=https://www.petervis.com/Sinclair/Sinclair_ZX80_Manual/4k-basic.html|title = Sinclair ZX80 User Manual 4K Basic for ZX80}}</ref> (so named for residing in 4&nbsp;[[kibibyte|KiB]] [[read-only memory]] (ROM)), was developed by John Grant of Nine Tiles for the ZX80. It has integer-only arithmetic.
** System Commands: <code>NEW</code> <code>RUN</code> <code>LIST</code> <code>LOAD</code> <code>SAVE</code>
* System Commands: <code>NEW</code> <code>RUN</code> <code>LIST</code> <code>LOAD</code> <code>SAVE</code>
** Control Statements: <code>GOTO</code> <code>IF</code> <code>THEN</code> <code>GOSUB</code> <code>STOP</code> <code>RETURN</code> <code>FOR</CODE> <code>TO</code> <code>NEXT</code> <code>CONTINUE</code>
* Control Statements: <code>GOTO</code> <code>IF</code> <code>THEN</code> <code>GOSUB</code> <code>STOP</code> <code>RETURN</code> <code>FOR</code> <code>TO</code> <code>NEXT</code> <code>CONTINUE</code>
** Input/Output Statements: <code>PRINT</code> <code>INPUT</code>
* Input/Output Statements: <code>PRINT</code> <code>INPUT</code>
** Assignment Statement: <code>LET</code>
* Assignment Statement: <code>LET</code>
** Other Statements: <code>CLEAR</code> <code>CLS</code> <code>DIM</code> <code>REM</code> <code>RANDOMIZE</code> <code>POKE</code>
* Other Statements: <code>CLEAR</code> <code>CLS</code> <code>DIM</code> <code>REM</code> <code>RANDOMIZE</code> <code>POKE</code>
* Functions: <code>ABS</code> <code>CHR$</code> <code>CODE</code><code>PEEK</code> <code>RND</code> <code>STR$</code> <code>TL$</code> <code>USR</code>


===8K BASIC===
===8K BASIC===
* ''8K BASIC'' is the ZX81 BASIC (also available as an upgrade for the ZX80<ref name=8Kupgrade/>), updated with floating-point arithmetic by [[Steve Vickers (computer scientist)|Steve Vickers]], so named for residing in 8&nbsp;KiB ROM.
''8K BASIC'' is the ZX81 BASIC (also available as an upgrade for the ZX80<ref name="8Kupgrade" />), updated with floating-point arithmetic by [[Steve Vickers (computer scientist)|Steve Vickers]], so named for residing in 8&nbsp;KiB ROM.
** Statements: <code>PRINT</code> <code>RAND</code> <code>LET</code> <code>CLEAR</code> <code>RUN</code> <code>LIST</code> <code>GOTO</code> <code>CONT</code> <code>INPUT</code> <code>NEW</code> <code>REM</code> <code>PRINT</code> <code>STOP</code> <code>BREAK</code> <code>IF</code> <code>STOP</code> <code>FOR</code> <code>NEXT</code> <code>TO</code> <code>STEP</code> <code>SLOW</code> <code>FAST</code> <code>GOSUB</code> <code>RETURN</code> <code>SAVE</code> <code>LOAD</code> <code>CLS</code> <code>SCROLL</code> <code>PLOT</code> <code>UNPLOT</code> <code>PAUSE</code> <code>LPRINT</code> <code>LLIST</code> <code>COPY</code> <code>DIM</code> <code>POKE</code> <code>NEW</code>
* Statements: <code>PRINT</code> <code>RAND</code> <code>LET</code> <code>CLEAR</code> <code>RUN</code> <code>LIST</code> <code>GOTO</code> <code>CONT</code> <code>INPUT</code> <code>NEW</code> <code>REM</code> <code>PRINT</code> <code>STOP</code> <code>BREAK</code> <code>IF</code> <code>STOP</code> <code>FOR</code> <code>NEXT</code> <code>TO</code> <code>STEP</code> <code>SLOW</code> <code>FAST</code> <code>GOSUB</code> <code>RETURN</code> <code>SAVE</code> <code>LOAD</code> <code>CLS</code> <code>SCROLL</code> <code>PLOT</code> <code>UNPLOT</code> <code>PAUSE</code> <code>LPRINT</code> <code>LLIST</code> <code>COPY</code> <code>DIM</code> <code>POKE</code> <code>NEW</code>
** Functions: <code>ABS</code> <code>SGN</code> <code>SIN</code> <code>COS</code> <code>TAN</code> <code>ASN</code> <code>ACS</code> <code>ATN</code> <code>LN</code> <code>EXP</code> <code>SQR</code> <code>INT</code> <code>PI</code> <code>RND</code> <code>FUNCTION</code> <code>LEN</code> <code>VALSTR$</code> <code>NOT</code> <code>CODE</code> <code>CHR$</code> <code>INKEY$</code> <code>AT</code> <code>TAB</code> <code>INKEY$</code> <code>PEEK</code> <code>USR</code>
* Functions: <code>ABS</code> <code>SGN</code> <code>SIN</code> <code>COS</code> <code>TAN</code> <code>ASN</code> <code>ACS</code> <code>ATN</code> <code>LN</code> <code>EXP</code> <code>SQR</code> <code>INT</code> <code>PI</code> <code>RND</code> <code>FUNCTION</code> <code>LEN</code> <code>VALSTR$</code> <code>NOT</code> <code>CODE</code> <code>CHR$</code> <code>INKEY$</code> <code>AT</code> <code>TAB</code> <code>INKEY$</code> <code>PEEK</code> <code>USR</code>


===48 BASIC===
===48 BASIC===
* ''48 BASIC'' is the BASIC for the original 16/48&nbsp;KB [[random-access memory|RAM]] ZX Spectrum (and clones), with colour and more peripherals added by Steve Vickers and John Grant. It resides in 16&nbsp;KB ROM and began to be called 48 BASIC with the introduction of the ZX Spectrum 128 at which time the 16&nbsp;KB Spectrum was no longer sold and most existing ones in use had been upgraded to 48&nbsp;KB<ref name="worldofspectrum.org">{{Cite web|url=https://worldofspectrum.org/ZXSpectrum128+3Manual/chapter7.html|title=World of Spectrum - Documentation - ZX Spectrum +3 - Chapter 7|website=worldofspectrum.org}}</ref>
''48 BASIC'' is the BASIC for the original 16/48&nbsp;KB [[random-access memory|RAM]] ZX Spectrum (and clones), with colour and more peripherals added by Steve Vickers and John Grant. It resides in 16&nbsp;KB ROM and began to be called 48 BASIC with the introduction of the ZX Spectrum 128 at which time the 16&nbsp;KB Spectrum was no longer sold and most existing ones in use had been upgraded to 48&nbsp;KB.<ref name="worldofspectrum.org">{{Cite web|url=https://worldofspectrum.org/ZXSpectrum128+3Manual/chapter7.html|title=World of Spectrum - Documentation - ZX Spectrum +3 - Chapter 7|website=worldofspectrum.org}}</ref>


===128 BASIC===
===128 BASIC===
* ''128 BASIC'' is the BASIC for the ZX Spectrum 128.<ref>{{Cite web|url=https://worldofspectrum.org/ZXSpectrum128Manual/sp128p06.html|title=World of Spectrum - Documentation - ZX Spectrum 128 Manual Page 6|website=worldofspectrum.org}}</ref> It offers extra commands and uses letter-by-letter input.
''128 BASIC'' is the BASIC for the ZX Spectrum 128.<ref name=":0">{{Cite web|url=https://worldofspectrum.org/ZXSpectrum128Manual/sp128p06.html|title=World of Spectrum - Documentation - ZX Spectrum 128 Manual Page 6|website=worldofspectrum.org}}</ref> It offers extra commands and uses letter-by-letter input.
**New commands: <code>LOAD !</code> <code>SAVE !</code> <code>MERGE !</code> <code>ERASE !</code> <code>PLAY</code> <code>SPECTRUM</code>
*New commands: <code>LOAD !</code> <code>SAVE !</code> <code>MERGE !</code> <code>ERASE !</code> <code>PLAY</code> <code>SPECTRUM</code>


===+3 BASIC===
===+3 BASIC===
* ''+3 BASIC'' is the BASIC with disk support for the ZX Spectrum +3 and +2A.<ref name="worldofspectrum.org"/>
''+3 BASIC'' is the BASIC with disk support for the ZX Spectrum +3 and +2A.<ref name="worldofspectrum.org" />
** New commands: <code>FORMAT</code> <code>COPY</code>
* New commands: <code>FORMAT</code> <code>COPY</code>


===T/S 2000 BASIC===
===T/S 2000 BASIC===
* ''T/S 2000 BASIC'' is used on the Spectrum-compatible [[Timex Sinclair 2068]] (T/S 2068) and adds the following six new keywords:
''T/S 2000 BASIC'' is used on the Spectrum-compatible [[Timex Sinclair 2068]] (T/S 2068) and adds the following six new keywords:
** <code>DELETE</code> deletes BASIC program line ranges.<!-- {{keypress|CAPS&nbsp;SHIFT|0}} with the <code>K</code> cursor produces the command <code>DELETE</code>.-->
* <code>DELETE</code> deletes BASIC program line ranges.<!-- {{keypress|CAPS&nbsp;SHIFT|0}} with the <code>K</code> cursor produces the command <code>DELETE</code>.-->
** <code>FREE</code> is a function that gives the amount of free RAM. <code>PRINT FREE</code> will show how much RAM is free.
* <code>FREE</code> is a function that gives the amount of free RAM. <code>PRINT FREE</code> will show how much RAM is free.
** <code>ON ERR</code> is an error-handling function mostly used as <code>ON ERR GO TO</code> or <code>ON ERR CONT</code>.
* <code>ON ERR</code> is an error-handling function mostly used as <code>ON ERR GO TO</code> or <code>ON ERR CONT</code>.
** <code>RESET</code> can be used to reset the behaviour of <code>ON ERR</code>. It was also intended to reset peripherals.
* <code>RESET</code> can be used to reset the behaviour of <code>ON ERR</code>. It was also intended to reset peripherals.
** <code>SOUND</code> controls the AY-3-8192 sound chip.
* <code>SOUND</code> controls the [[General Instrument AY-3-8910|AY-3-8192]] [[sound chip]].
** <code>STICK</code> is a function that gives the position of the internal joystick (Timex Sinclair 2090).
* <code>STICK</code> is a function that gives the position of the internal joystick (Timex Sinclair 2090).


===BASIC64===
===BASIC64===
* ''BASIC64'' by [[Timex of Portugal]], is a software extension<ref>{{Cite web|url=http://timex.comboios.info/tmxtechb64-2048.html|title=Timex tech info - Basic 64 for TC2048|website=timex.comboios.info}}</ref> 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]].
''BASIC64'' by [[Timex of Portugal]], is a [[software extension]]<ref>{{Cite web|url=http://timex.comboios.info/tmxtechb64-2048.html|title=Timex tech info Basic 64 for TC2048|website=timex.comboios.info}}</ref> 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]].
** <code>PRINT #</code> Prints to a specific output channel.
* <code>PRINT #</code> prints to a specific output channel.
** <code>LIST #</code> Lists the program to a specific output channel.
* <code>LIST #</code> lists the program to a specific output channel.
** <code>CLS*</code> Clears both display areas.
* <code>CLS*</code> clears both display areas.
** <code>INK*</code> Sets ink colour for both display areas
* <code>INK*</code> sets ink colour for both display areas
** <code>PAPER*</code> Sets paper colour both display areas
* <code>PAPER*</code> sets paper colour both display areas
** <code>SCREEN$</code> Selects the high / normal resolution modes.
* <code>SCREEN$</code> selects the high / normal resolution modes.
** <code>PLOT*</code> Plots a pixel and updates the drawing position.
* <code>PLOT*</code> plots a pixel and updates the drawing position.
** <code>LINE</code> Draws a line from the previous PLOT position, supporting arc drawing
* <code>LINE</code> draws a line from the previous PLOT position, supporting arc drawing
** <code>CIRCLE*</code> Draws a circle or oval, depending on screen mode.
* <code>CIRCLE*</code> draws a circle or oval, depending on screen mode.


===Timex Extended Basic===
===Timex Extended Basic===
* ''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.<ref>{{Cite web|url=https://loadzx.com/wp-content/uploads/simple-file-list/LITERATURA/JORNAIS/Microsete/Microsete-n46.pdf|title=Microsete N.º46, Maio 1987|website=loadzx.com}}</ref><ref>{{Cite web|url=https://k1.spdns.de/Vintage/Sinclair/82/Timex%20Computer%203256%20(unreleased)/|title=Timex Computer 3256, Timex Portugal|website=k1.spdns.de}}</ref>
''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.<ref>{{Cite web|url=https://loadzx.com/wp-content/uploads/simple-file-list/LITERATURA/JORNAIS/Microsete/Microsete-n46.pdf|title=Microsete N.º46, Maio 1987|website=loadzx.com}}</ref><ref>{{Cite web|url=https://k1.spdns.de/Vintage/Sinclair/82/Timex%20Computer%203256%20(unreleased)/|title=Timex Computer 3256, Timex Portugal|website=k1.spdns.de}}</ref>
** RAM drive commands: <code>LOAD!</code> <code>SAVE!</code> <code>CAT!</code> <code>MERGE!</code> <code>ERASE!</code> <code>CLEAR!</code>
* RAM drive commands: <code>LOAD!</code> <code>SAVE!</code> <code>CAT!</code> <code>MERGE!</code> <code>ERASE!</code> <code>CLEAR!</code>
** RS-232 commands: <code>FORMAT!</code> <code>LPRINT</code> <code>LLIST</code>
* RS-232 commands: <code>FORMAT!</code> <code>LPRINT</code> <code>LLIST</code>
** AY-3-8912 commands: <code>BEEP!</code>
* AY-3-8912 commands: <code>BEEP!</code>
** 512x192 resolution commands: <code>SCREEN$</code> <code>DRAW!</code> <code>PLOT!</code> <code>CIRCLE!</code>
* 512 x 192 resolution commands: <code>SCREEN$</code> <code>DRAW!</code> <code>PLOT!</code> <code>CIRCLE!</code>


==Other versions, extensions, derivatives and successors==
==Other versions, extensions, derivatives and successors==
Line 683: Line 713:
Several ZX Spectrum interpreters exist.<ref name="ReferenceA">{{cite web |url=http://www.worldofspectrum.org/sinclairbasic/ |title=World of Spectrum - Sinclair BASIC - Home of the Sinclair Extended Basic Project |website=www.worldofspectrum.org |url-status=dead |archive-url=https://web.archive.org/web/20021013211218/http://www.worldofspectrum.org/sinclairbasic/ |archive-date=2002-10-13}} </ref>
Several ZX Spectrum interpreters exist.<ref name="ReferenceA">{{cite web |url=http://www.worldofspectrum.org/sinclairbasic/ |title=World of Spectrum - Sinclair BASIC - Home of the Sinclair Extended Basic Project |website=www.worldofspectrum.org |url-status=dead |archive-url=https://web.archive.org/web/20021013211218/http://www.worldofspectrum.org/sinclairbasic/ |archive-date=2002-10-13}} </ref>
* ''[[Beta BASIC]]'' by Dr. Andy Wright, was originally a [[BASIC extension]], but became a full interpreter.<ref>{{Cite web |title=Beta Basic at Spectrum Computing - Sinclair ZX Spectrum games, software and hardware |url=https://spectrumcomputing.co.uk/entry/7956/ZX-Spectrum/Beta_Basic |access-date=2022-12-13 |website=Spectrum Computing |language=en}}</ref>
* ''[[Beta BASIC]]'' by Dr. Andy Wright, was originally a [[BASIC extension]], but became a full interpreter.<ref>{{Cite web |title=Beta Basic at Spectrum Computing - Sinclair ZX Spectrum games, software and hardware |url=https://spectrumcomputing.co.uk/entry/7956/ZX-Spectrum/Beta_Basic |access-date=2022-12-13 |website=Spectrum Computing |language=en}}</ref>
* ''[[YS MegaBasic]]'' by [[Mike Leaman]].<ref name="ReferenceA"/><ref>{{Cite web |title=YS MegaBasic at Spectrum Computing - Sinclair ZX Spectrum games, software and hardware |url=https://spectrumcomputing.co.uk/entry/8997/ZX-Spectrum/YS_MegaBasic |access-date=2022-12-13 |website=Spectrum Computing |language=en}}</ref>
* ''[[YS MegaBasic]]'' by Mike Leaman.<ref name="ReferenceA"/><ref>{{Cite web |title=YS MegaBasic at Spectrum Computing - Sinclair ZX Spectrum games, software and hardware |url=https://spectrumcomputing.co.uk/entry/8997/ZX-Spectrum/YS_MegaBasic |access-date=2022-12-13 |website=Spectrum Computing |language=en}}</ref>
* ''[[ZebraOS]]'' by [[Zebra Systems]] in New York, a cartridge version of T/S 2000 BASIC that used the 512×192 screen mode.<ref>{{Cite web |title=Zebra OS64 at Spectrum Computing - Sinclair ZX Spectrum games, software and hardware |url=https://spectrumcomputing.co.uk/entry/4000090/Timex/Zebra_OS64 |access-date=2022-12-13 |website=Spectrum Computing |language=en}}</ref>
* ''ZebraOS'' by Zebra Systems in New York, a [[ROM cartridge|cartridge]] version of T/S 2000 BASIC that used the 512×192 screen mode.<ref>{{Cite web |title=Zebra OS64 at Spectrum Computing - Sinclair ZX Spectrum games, software and hardware |url=https://spectrumcomputing.co.uk/entry/4000090/Timex/Zebra_OS64 |access-date=2022-12-13 |website=Spectrum Computing |language=en}}</ref>
* ''[https://web.archive.org/web/20150901085346/http://www.wearmouth.demon.co.uk/ Sea Change ROM]'' by Steve Vickers and Ian Logan, modified by Geoff Wearmouth, a replacement ROM with an enhanced Sinclair BASIC.<ref>{{Cite web|url=https://sinclair.wiki.zxnet.co.uk/wiki/Sinclair_BASIC_history|title=Sinclair BASIC history - Sinclair Wiki|website=sinclair.wiki.zxnet.co.uk}}</ref>
* ''[https://web.archive.org/web/20150901085346/http://www.wearmouth.demon.co.uk/ Sea Change ROM]'' by Steve Vickers and Ian Logan, modified by Geoff Wearmouth, a replacement ROM with an enhanced Sinclair BASIC.<ref>{{Cite web|url=https://sinclair.wiki.zxnet.co.uk/wiki/Sinclair_BASIC_history|title=Sinclair BASIC history - Sinclair Wiki|website=sinclair.wiki.zxnet.co.uk}}</ref>
*''[[Gosh Wonderful]]'' by [[Geoff Wearmouth]], a replacement ROM that fixes bugs and adds a tokenizer, stream lister, delete and renumber commands.<ref name="ReferenceA"/><ref>{{cite web|title=The Incomplete Spectrum ROM Assembly|url=http://www.wearmouth.demon.co.uk/ |archive-url=https://web.archive.org/web/20150901085346/http://www.wearmouth.demon.co.uk |archive-date=2015-09-01 |url-status=dead}}</ref>
*''Gosh Wonderful'' by Geoff Wearmouth, a replacement ROM that fixes bugs and adds a tokenizer, stream lister, delete and renumber commands.<ref name="ReferenceA"/><ref>{{cite web|title=The Incomplete Spectrum ROM Assembly|url=http://www.wearmouth.demon.co.uk/ |archive-url=https://web.archive.org/web/20150901085346/http://www.wearmouth.demon.co.uk |archive-date=2015-09-01 |url-status=dead}}</ref>
* ''[[OpenSE BASIC]]'' (formerly SE BASIC) by [[Andrew Owen]], a replacement ROM with bug fixes and many enhancements including [[ULAplus]]<ref>{{Cite web|url=https://sites.google.com/site/ulaplus/|title=ULAplus|website=sites.google.com}}</ref> support, published as open source in 2011<ref>{{Cite web|url=http://www.fruitcake.plus.com/Sinclair/Interface2/Cartridges/Interface2_RC_New_3rdParty_SEBASIC.htm|title=ZX Interface 2 - SE BASIC (3rd Party ROM Cartridge)|website=www.fruitcake.plus.com}}</ref><ref>{{Cite web|url=https://sourceforge.net/projects/sebasic/|title=OpenSE BASIC|website=SourceForge}}</ref><ref>{{Cite web |title=OpenSE BASIC at Spectrum Computing - Sinclair ZX Spectrum games, software and hardware |url=https://spectrumcomputing.co.uk/entry/27510/ZX-Spectrum/OpenSE_BASIC |access-date=2022-12-13 |website=Spectrum Computing |language=en}}</ref>
* ''OpenSE BASIC'' (formerly SE BASIC) by Andrew Owen, a replacement ROM with bug fixes and many enhancements including ULAplus<ref>{{Cite web|url=https://sites.google.com/site/ulaplus/|title=ULAplus|website=sites.google.com|access-date=21 March 2016|archive-date=25 May 2013|archive-url=https://web.archive.org/web/20130525190223/https://sites.google.com/site/ulaplus/|url-status=dead}}</ref> support, published as open source in 2011<ref>{{Cite web|url=http://www.fruitcake.plus.com/Sinclair/Interface2/Cartridges/Interface2_RC_New_3rdParty_SEBASIC.htm|title=ZX Interface 2 - SE BASIC (3rd Party ROM Cartridge)|website=www.fruitcake.plus.com|access-date=23 March 2016|archive-date=25 March 2015|archive-url=https://web.archive.org/web/20150325030638/http://www.fruitcake.plus.com/Sinclair/Interface2/Cartridges/Interface2_RC_New_3rdParty_SEBASIC.htm|url-status=dead}}</ref><ref>{{Cite web|url=https://sourceforge.net/projects/sebasic/|title=OpenSE BASIC|website=SourceForge|date=16 April 2013 }}</ref><ref>{{Cite web |title=OpenSE BASIC at Spectrum Computing - Sinclair ZX Spectrum games, software and hardware |url=https://spectrumcomputing.co.uk/entry/27510/ZX-Spectrum/OpenSE_BASIC |access-date=2022-12-13 |website=Spectrum Computing |language=en}}</ref>


===Compilers for the ZX Spectrum family===
===Compilers for the ZX Spectrum family===
Several ZX Spectrum compilers exist.<ref name="ReferenceA"/>
Several ZX Spectrum [[compiler]]s exist.<ref name="ReferenceA"/>
* ''[[HiSoft Systems|HiSoft]] COLT Compiler'' (a.k.a. HiSoft COLT Integer Compiler)<ref>{{Cite web|url=https://worldofspectrum.org/software|title=World of Spectrum - HiSoft COLT Compiler|website=World of Spectrum}}</ref><ref>{{Cite web |title=HiSoft COLT Compiler at Spectrum Computing - Sinclair ZX Spectrum games, software and hardware |url=https://spectrumcomputing.co.uk/entry/8254/ZX-Spectrum/HiSoft_COLT_Compiler |access-date=2022-12-13 |website=Spectrum Computing |language=en}}</ref>
* ''[[HiSoft Systems|HiSoft]] COLT Compiler'' (a.k.a. HiSoft COLT Integer Compiler)<ref>{{Cite web|url=https://worldofspectrum.org/software|title=World of Spectrum - HiSoft COLT Compiler|website=World of Spectrum}}</ref><ref>{{Cite web |title=HiSoft COLT Compiler at Spectrum Computing - Sinclair ZX Spectrum games, software and hardware |url=https://spectrumcomputing.co.uk/entry/8254/ZX-Spectrum/HiSoft_COLT_Compiler |access-date=2022-12-13 |website=Spectrum Computing |language=en}}</ref>
* ''[[HiSoft Systems|HiSoft]] BASIC'' (a.k.a. HiSoft BASIC Compiler), an integer and floating-point capable compiler<ref>{{Cite web|url=https://worldofspectrum.org/software|title=World of Spectrum - HiSoft BASIC|website=World of Spectrum}}</ref><ref>{{Cite web |title=HiSoft BASIC at Spectrum Computing - Sinclair ZX Spectrum games, software and hardware |url=https://spectrumcomputing.co.uk/entry/8249/ZX-Spectrum/HiSoft_BASIC |access-date=2022-12-13 |website=Spectrum Computing |language=en}}</ref>
* ''[[HiSoft Systems|HiSoft]] BASIC'' (a.k.a. HiSoft BASIC Compiler), an integer and floating-point capable compiler<ref>{{Cite web|url=https://worldofspectrum.org/software|title=World of Spectrum - HiSoft BASIC|website=World of Spectrum}}</ref><ref>{{Cite web |title=HiSoft BASIC at Spectrum Computing - Sinclair ZX Spectrum games, software and hardware |url=https://spectrumcomputing.co.uk/entry/8249/ZX-Spectrum/HiSoft_BASIC |access-date=2022-12-13 |website=Spectrum Computing |language=en}}</ref>
Line 701: Line 731:
* ''[[SuperBASIC]]'', a much more advanced BASIC dialect introduced with the [[Sinclair QL]] personal computer, with some similarities to the earlier Sinclair BASICs<ref>{{cite web |last1=Berry |first1=Stephen |title=QL Keywords |url=http://www.dilwyn.me.uk/docs/ebooks/olqlug/QL%20Manual%20-%20Keywords.htm |access-date=27 June 2023 |archive-url=https://web.archive.org/web/20170222113142/http://www.dilwyn.me.uk/docs/ebooks/olqlug/QL%20Manual%20-%20Keywords.htm |archive-date=February 22, 2017 |language=en |date=1984 |url-status=unfit}}</ref>
* ''[[SuperBASIC]]'', a much more advanced BASIC dialect introduced with the [[Sinclair QL]] personal computer, with some similarities to the earlier Sinclair BASICs<ref>{{cite web |last1=Berry |first1=Stephen |title=QL Keywords |url=http://www.dilwyn.me.uk/docs/ebooks/olqlug/QL%20Manual%20-%20Keywords.htm |access-date=27 June 2023 |archive-url=https://web.archive.org/web/20170222113142/http://www.dilwyn.me.uk/docs/ebooks/olqlug/QL%20Manual%20-%20Keywords.htm |archive-date=February 22, 2017 |language=en |date=1984 |url-status=unfit}}</ref>
* ''SAM Basic'', the BASIC on the [[SAM Coupé]], generally considered a ZX Spectrum clone<ref>{{Cite web |title=Sam Coupe Scrapbook: Sam BASIC |url=https://www.mono.org/~unc/Coupe/Tech/basic.html |access-date=2022-12-13 |website=www.mono.org}}</ref>
* ''SAM Basic'', the BASIC on the [[SAM Coupé]], generally considered a ZX Spectrum clone<ref>{{Cite web |title=Sam Coupe Scrapbook: Sam BASIC |url=https://www.mono.org/~unc/Coupe/Tech/basic.html |access-date=2022-12-13 |website=www.mono.org}}</ref>
* ''ROMU6'' by Cesar and Juan Hernandez - [[MSX]]<ref name="ReferenceA"/>
* ''ROMU6'' by Cesar and Juan Hernandez [[MSX]]<ref name="ReferenceA"/>
* ''Spectrum 48'' by Whitby Computers - [[Commodore 64]]<ref name="ReferenceA"/>
* ''Spectrum 48'' by Whitby Computers [[Commodore 64]]<ref name="ReferenceA"/>
* ''Sparky eSinclair BASIC'' by Richard Kelsh, an operating system loosely based on ZX Spectrum BASIC - [[Zilog eZ80]]<ref>{{Cite web|url=http://rk-internet.com/eZXSparky/|title=Sparky eZX BASIC Project|website=rk-internet.com}}</ref>
* ''Sparky eSinclair BASIC'' by Richard Kelsh, an operating system loosely based on ZX Spectrum BASIC - [[Zilog eZ80]]<ref>{{Cite web|url=http://rk-internet.com/eZXSparky/|title=Sparky eZX BASIC Project|website=rk-internet.com}}</ref>
* ''Sinbas'' by Pavel Napravnik - [[DOS]]<ref name="ReferenceA"/>
* ''Sinbas'' by Pavel Napravnik [[DOS]]<ref name="ReferenceA"/>
* ''Basic''<ref>{{Cite web|url=http://www.shadowmagic.org.uk/spectrum/basic.html|title=Philip Kendall - Basic|website=www.shadowmagic.org.uk}}</ref> (and CheckBasic<ref>{{Cite web|url=http://www.shadowmagic.org.uk/spectrum/checkbasic.html|title=Philip Kendall - CheckBasic|website=www.shadowmagic.org.uk}}</ref>) by Philip Kendall - [[Unix]]
* ''Basic''<ref>{{Cite web|url=http://www.shadowmagic.org.uk/spectrum/basic.html|title=Philip Kendall - Basic|website=www.shadowmagic.org.uk}}</ref> (and CheckBasic<ref>{{Cite web|url=http://www.shadowmagic.org.uk/spectrum/checkbasic.html|title=Philip Kendall CheckBasic|website=www.shadowmagic.org.uk}}</ref>) by Philip Kendall - [[Unix]]
* ''BINSIC''<ref name="BINSIC"/> by Adrian McMenamin, a reimplementation in [[Groovy (programming language)|Groovy]] closely modelled on ZX81 BASIC - Java
* ''BINSIC''<ref name="BINSIC"/> by Adrian McMenamin, a reimplementation in [[Groovy (programming language)|Groovy]] closely modelled on ZX81 BASIC [[Java (programming language)|Java]]
* ''BASin''<ref>{{Cite web|url=https://sites.google.com/site/ulaplus/home/zx-spin-and-basin|title=ZX Spin and BASin - ULAplus|website=sites.google.com}}</ref> by Paul Dunn, a complete Sinclair BASIC [[integrated development environment]] (IDE) based on a ZX Spectrum emulator<ref name="ReferenceA"/> - Windows
* ''BASin''<ref>{{Cite web|url=https://sites.google.com/site/ulaplus/home/zx-spin-and-basin|title=ZX Spin and BASin - ULAplus|website=sites.google.com}}</ref> by Paul Dunn, a complete Sinclair BASIC [[integrated development environment]] (IDE) based on a ZX Spectrum emulator<ref name="ReferenceA"/> Windows
* ''[[SpecBAS]]''<ref>{{Cite web|url=https://github.com/ZXDunny/SpecBAS|title=ZXDunny/SpecBAS|date=June 5, 2021|via=GitHub}}</ref> (a.k.a. SpecOS) by Paul Dunn, an [[integrated development environment]] (IDE) providing an enhanced superset of Sinclair BASIC - [[Windows]], [[Linux]], [[Pandora (console)|Pandora]], and [[Raspberry Pi]]
* ''SpecBAS''<ref>{{Cite web|url=https://github.com/ZXDunny/SpecBAS|title=ZXDunny/SpecBAS|date=June 5, 2021|via=GitHub}}</ref> (a.k.a. SpecOS) by Paul Dunn, an integrated development environment (IDE) providing an enhanced superset of Sinclair BASIC [[Windows]], [[Linux]], [[Pandora (console)|Pandora]], and [[Raspberry Pi]]
* ''[[ZX-Basicus]]''<ref>{{Cite web|url=https://jafma.net/software/zxbasicus/|title=ZX-Basicus: analyzer/synthesizer/optimizer/interpreter of Sinclair BASIC programs for the ZX Spectrum 48K|website=jafma.net}}</ref> 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]].
* ''ZX-Basic''<ref>{{Cite web|url=https://zxbasic.readthedocs.io/en/docs/about/|title=ZX-Basic: Backwardly compatible, but enhanced compiler of Sinclair BASIC programs}}</ref> Backwardly compatible, but enhanced compiler of Sinclair BASIC programs the ZX Spectrum, written in [[Python (programming language)|Python]], freely available for Windows, Linux and [[Mac OS]]
* ''ZX-Basicus''<ref>{{Cite web|url=https://jafma.net/software/zxbasicus/|title=ZX-Basicus: analyzer/synthesizer/optimizer/interpreter of Sinclair BASIC programs for the ZX Spectrum 48K|website=jafma.net}}</ref> by Juan-Antonio Fernández-Madrigal, a synthesizer, analyzer, [[optimizing compiler|optimizer]], interpreter and [[debugger]] of Sinclair BASIC 48K for PCs, freely downloadable for Linux and Windows.


==See also==
==See also==
Line 743: Line 774:


==Bibliography==
==Bibliography==
* {{cite book |first1=Ian |last1=Adamson |first2=Richard |last2=Kennedy |publisher= Penguin |date=1986 |title=Sinclair and the 'sunrise' Technology |url=https://rk.nvg.ntnu.no/sinclair/computers/zx81/zx81_sst.htm}}
* {{cite book | last = Ardley | first = Neil | title = Sinclair ZX Spectrum+ User Guide | publisher = [[Dorling Kindersley]] in association with Sinclair Research | year = 1984 | isbn = 0-86318-080-9 }}
* {{cite book | last = Ardley | first = Neil | title = Sinclair ZX Spectrum+ User Guide | publisher = [[Dorling Kindersley]] in association with Sinclair Research | year = 1984 | isbn = 0-86318-080-9 }}
* {{cite book | last = Vickers | first = Steven | title = Sinclair ZX Spectrum BASIC Programming | publisher = Sinclair Research | year = 1982 }}
* {{cite book | last = Vickers | first = Steven | title = Sinclair ZX Spectrum BASIC Programming | publisher = Sinclair Research | year = 1982 }}
Line 749: Line 781:


==External links==
==External links==
* [http://www.worldofspectrum.org/ZXBasicManual/ Sinclair ZX Spectrum BASIC Programming]: The original 1982 manual by Steven Vickers (referenced above)
* [https://www.worldofspectrum.org/ZXBasicManual/ Sinclair ZX Spectrum BASIC Programming]: The original 1982 manual by Steven Vickers (referenced above)
* [http://www.worldofspectrum.org/ZX81BasicProgramming/ Sinclair ZX81 Basic Programming] {{Webarchive|url=https://web.archive.org/web/20070422024127/http://www.worldofspectrum.org/ZX81BasicProgramming/ |date=2007-04-22 }}: also by Vickers
* [https://www.worldofspectrum.org/ZX81BasicProgramming/ Sinclair ZX81 Basic Programming] {{Webarchive|url=https://web.archive.org/web/20070422024127/http://www.worldofspectrum.org/ZX81BasicProgramming/ |date=2007-04-22 }}: also by Vickers
* [http://scratchpad.wikia.com/wiki/Sinclair_BASIC_History The History of Sinclair BASIC]: By Andrew Owen
* [https://scratchpad.wikia.com/wiki/Sinclair_BASIC_History The History of Sinclair BASIC]: By Andrew Owen
* [http://timex.comboios.info/tmxtechb64-2048.html Timex Computer World]: Basic 64 user manual for Timex Computer 2048
* [https://loadzx.com/timexcomputerworld/tmxtechb64-2048.html Timex Computer World]: Basic 64 user manual for Timex Computer 2048
* [http://jafma.net/software/ll1grammar/index.htm Sinclair BASIC grammar]: A LL(1) grammar specification for parsing Sinclair BASIC 16/48K
* [https://jafma.net/software/ll1grammar/index.htm Sinclair BASIC grammar]: A LL(1) grammar specification for parsing Sinclair BASIC 16/48K


{{BASIC}}
{{BASIC}}

Latest revision as of 14:27, 26 October 2024

Sinclair BASIC
ParadigmImperative
Designed byJohn Grant, Steve Vickers
DeveloperNine Tiles Networks,
Sinclair Research
First appeared1979; 45 years ago (1979)
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.

Performance became a more serious issue with the release of the ZX Spectrum in 1983, 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]" [CODE [address[, length]]| DATA variable()] J Command Loads a program or data into RAM from tape, ZX Microdrive, disk, etc., deleting any existing BASIC program and variables;[50] if an empty string ("") is provided, this loads the first program found, else it will search the tape for the program named in the string; if the optional CODE is provided, will load the program into memory at the address it had when it was saved, or at the specified address (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);[57] if the optional DATA variable() is provided, will load the data from the tape into the array named variable()[36]
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[58]
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][59]
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[60] — "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][61]
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 [Memory-mapped I/O|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[62] (thus, PAUSE 50 halts for one second in Europe)
PEEK address EXTENDED MODE then O Function Returns a byte representing the contents of the memory location pointed to by address[63]
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)[64]
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[65]
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][66]
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[67]
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)[68]
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)[69]
SAVE "filename" [DATA variable() | LINE number] S Command Saves the current BASIC program to tape or other storage device, with the filename specified; 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; with the optional DATA, the command saves the contents of the array named by the variable instead of the current BASIC program[36]
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;[70]
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;[69] 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[71]
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;[72] 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.[73]
VAL string EXTENDED MODE then J Function Evaluates the string as a number and returns the result;[74] 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.[75]
ZX Spectrum
ZX Spectrum+

Official versions

[edit]

4K BASIC

[edit]

4K BASIC for ZX80[76] (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[77] 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.[78][79]

  • 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.[80]

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

Compilers for the ZX Spectrum family

[edit]

Several ZX Spectrum compilers exist.[80]

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[103]
  • SAM Basic, the BASIC on the SAM Coupé, generally considered a ZX Spectrum clone[104]
  • ROMU6 by Cesar and Juan Hernandez – MSX[80]
  • Spectrum 48 by Whitby Computers – Commodore 64[80]
  • Sparky eSinclair BASIC by Richard Kelsh, an operating system loosely based on ZX Spectrum BASIC - Zilog eZ80[105]
  • Sinbas by Pavel Napravnik – DOS[80]
  • Basic[106] (and CheckBasic[107]) by Philip Kendall - Unix
  • BINSIC[108] by Adrian McMenamin, a reimplementation in Groovy closely modelled on ZX81 BASIC – Java
  • BASin[109] by Paul Dunn, a complete Sinclair BASIC integrated development environment (IDE) based on a ZX Spectrum emulator[80] – Windows
  • SpecBAS[110] (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[111] 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[112] 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]
  1. ^ Optional parameters are enclosed in [square brackets]
  2. ^ These assume the computer is in  K  (keyword) mode, which it normally is at the start of a line when entering BASIC. On the Spectrum 16K and 48K, Extended Mode is entered by pressing CAPS SHIFT and SYMBOL SHIFT simultaneously rather than the EXTENDED MODE key that is present on the Spectrum+ and later models.
  3. ^ a b c “False” in Sinclair BASIC equates to 0 (zero), everything else equates to “true”. Functions that return true-or-false values thus actually return 0 for false and 1 for true, while AND usually returns the first of the conditions supplied for true, or 1 if no numerical values were given. For example, 6 AND 7 returns 6, while NOT 6=7 returns 1.
  4. ^ a b c The available numbers for colours are:
    1 2 3 4 5 6 7 0
    blue red magenta green cyan yellow white black

    In all colour-related commands, the number 8 may be used to indicate “transparent” while in INK and PAPER may also be set to 9 for “contrast” — that is, to put a dark colour on a light background or vice versa automatically.

  5. ^ a b c d e f INK, PAPER, FLASH, BRIGHT, OVER and INVERSE set attributes for outputting text and graphics to the screen. They can be used either as commands, to apply to all subsequent output until set again, or within a PRINT statement, to apply only from that point until the end of the statement.
  6. ^ a b c d e f CAT, ERASE, FORMAT and MOVE were originally designed to be used with peripherals, but at the launch of ZX Spectrum, they had not been completely implemented, such that their use generated an error message (Invalid Stream). Later with the aid of the ZX Interface 1 shadow ROM, they were used for the ZX Microdrive. (The shadow ROM was paged when the BASIC interpreter detected a syntax error, which is why most ZX Microdrive commands use a "*").
  7. ^ a b Unlike many other BASIC dialects, Sinclair Basic did not include the ELSE operator in the IFTHEN[–ELSE] clause. A workaround would be to use an IFTHENGO TO construct instead, bypassing the lines that would have been in an ELSE clause with the GO TO
  8. ^ The Spectrum’s display memory starts at address 16384 and is 6912 bytes long
  9. ^ A string inside a string must have its quotes doubled in Sinclair BASIC

References

[edit]
  1. ^ Garfield, Simon (28 February 2010). "Sir Clive Sinclair: "I don't use a computer at all"". The Guardian. Retrieved 23 May 2011. He is keen to credit [...], not least Nine Tiles, the company that made the Basic operating software.
  2. ^ Adamson & Kennedy, p. 63.
  3. ^ Adamson & Kennedy 1986, p. 64.
  4. ^ Adamson & Kennedy 1986, p. 70.
  5. ^ a b "ZX80 – 8K BASIC ROM Upgrade". www.fruitcake.plus.com.
  6. ^ a b c d "World of Spectrum - Documentation - ZX Spectrum +3 - Chapter 7". worldofspectrum.org.
  7. ^ a b c d "World of Spectrum - Documentation - ZX Spectrum 128 Manual Page 6". worldofspectrum.org.
  8. ^ Smith, Tony (23 April 2012). "Happy 30th Birthday, Sinclair ZX Spectrum". The Register.
  9. ^ Adamson & Kennedy 1986, p. 88.
  10. ^ Dunn, Paul (7 December 2022), SpecBAS, retrieved 12 December 2022
  11. ^ "CSDb". Commodore 64 Scene Database. Retrieved 12 December 2022.
  12. ^ Vickers 1983, p. 7–8.
  13. ^ "Picture of ZX80".
  14. ^ "Spectrum 128 ROM Disassembly - Spanish Spectrum 128". www.fruitcake.plus.com.
  15. ^ Sinclair (1985). ZX Spectrum 128 Introducción y Guía de Funcionamiento. Sinclair Research Ltd and Investronica, S. A. p. 9.
  16. ^ a b c d Vickers 1983, p. 59.
  17. ^ a b Vickers 1983, p. 70.
  18. ^ a b c Vickers 1983, p. 85.
  19. ^ Vickers 1983, p. 69–70.
  20. ^ a b c d Vickers 1983, p. 101.
  21. ^ Vickers 1983, p. 116.
  22. ^ Vickers 1983, p. 135.
  23. ^ a b Vickers 1983, p. 93.
  24. ^ Vickers 1983, p. 113.
  25. ^ Vickers 1983, p. 110–111.
  26. ^ Cambridge Communication 1983, p. 15.
  27. ^ a b Vickers 1983, p. 91.
  28. ^ a b Vickers 1983, p. 123.
  29. ^ a b c Vickers 1983, p. 103.
  30. ^ "World of Spectrum - Documentation - ZX Spectrum manual - Chapter 24". worldofspectrum.org.
  31. ^ Vickers 1983, p. 168.
  32. ^ Vickers 1983, p. 19.
  33. ^ a b c Vickers 1983, p. 151.
  34. ^ a b Vickers 1983, p. 68.
  35. ^ a b Vickers 1983, p. 41.
  36. ^ a b c Vickers 1983, p. 142.
  37. ^ a b c Vickers 1983, p. 60.
  38. ^ Vickers 1983, p. 79–81.
  39. ^ Vickers 1983, p. 11–123.
  40. ^ Cambridge Communication 1983, p. 18.
  41. ^ Vickers 1983, p. 66.
  42. ^ Cambridge Communication 1983, p. 19.
  43. ^ Vickers 1983, p. 31.
  44. ^ a b Vickers 1983, p. 32.
  45. ^ a b Vickers 1983, p. 37.
  46. ^ a b Vickers 1983, p. 25.
  47. ^ a b Vickers 1983, p. 159.
  48. ^ a b Vickers 1983, p. 110.
  49. ^ Vickers 1983, p. 131.
  50. ^ a b c d Vickers 1983, p. 16.
  51. ^ a b Vickers 1983, p. 112.
  52. ^ Vickers 1983, p. 57.
  53. ^ a b Vickers 1983, p. 13.
  54. ^ Vickers 1983, p. 144.
  55. ^ Vickers 1983, p. 15.
  56. ^ a b Vickers 1983, p. 67.
  57. ^ Vickers 1983, p. 142–143.
  58. ^ Vickers 1983, p. 147.
  59. ^ Cambridge Communication 1983, p. 39.
  60. ^ Vickers 1983, p. 31–32.
  61. ^ Cambridge Communication 1983, p. 22.
  62. ^ Vickers 1983, p. 129.
  63. ^ Vickers 1983, p. 130.
  64. ^ Vickers 1983, p. 121.
  65. ^ Vickers 1983, p. 163.
  66. ^ Vickers 1983, p. 74.
  67. ^ Vickers 1983, p. 42.
  68. ^ Vickers 1983, p. 73.
  69. ^ a b Vickers 1983, p. 14.
  70. ^ Vickers 1983, p. 143.
  71. ^ Vickers 1983, p. 69.
  72. ^ Vickers 1983, p. 32, 51.
  73. ^ Vickers 1983, p. 180.
  74. ^ Vickers 1983.
  75. ^ Vickers 1983, p. 141.
  76. ^ "Sinclair ZX80 User Manual 4K Basic for ZX80".
  77. ^ "Timex tech info – Basic 64 for TC2048". timex.comboios.info.
  78. ^ "Microsete N.º46, Maio 1987" (PDF). loadzx.com.
  79. ^ "Timex Computer 3256, Timex Portugal". k1.spdns.de.
  80. ^ a b c d e f g h "World of Spectrum - Sinclair BASIC - Home of the Sinclair Extended Basic Project". www.worldofspectrum.org. Archived from the original on 13 October 2002.
  81. ^ "Beta Basic at Spectrum Computing - Sinclair ZX Spectrum games, software and hardware". Spectrum Computing. Retrieved 13 December 2022.
  82. ^ "YS MegaBasic at Spectrum Computing - Sinclair ZX Spectrum games, software and hardware". Spectrum Computing. Retrieved 13 December 2022.
  83. ^ "Zebra OS64 at Spectrum Computing - Sinclair ZX Spectrum games, software and hardware". Spectrum Computing. Retrieved 13 December 2022.
  84. ^ "Sinclair BASIC history - Sinclair Wiki". sinclair.wiki.zxnet.co.uk.
  85. ^ "The Incomplete Spectrum ROM Assembly". Archived from the original on 1 September 2015.
  86. ^ "ULAplus". sites.google.com. Archived from the original on 25 May 2013. Retrieved 21 March 2016.
  87. ^ "ZX Interface 2 - SE BASIC (3rd Party ROM Cartridge)". www.fruitcake.plus.com. Archived from the original on 25 March 2015. Retrieved 23 March 2016.
  88. ^ "OpenSE BASIC". SourceForge. 16 April 2013.
  89. ^ "OpenSE BASIC at Spectrum Computing - Sinclair ZX Spectrum games, software and hardware". Spectrum Computing. Retrieved 13 December 2022.
  90. ^ "World of Spectrum - HiSoft COLT Compiler". World of Spectrum.
  91. ^ "HiSoft COLT Compiler at Spectrum Computing - Sinclair ZX Spectrum games, software and hardware". Spectrum Computing. Retrieved 13 December 2022.
  92. ^ "World of Spectrum - HiSoft BASIC". World of Spectrum.
  93. ^ "HiSoft BASIC at Spectrum Computing - Sinclair ZX Spectrum games, software and hardware". Spectrum Computing. Retrieved 13 December 2022.
  94. ^ "World of Spectrum - Laser Compiler". World of Spectrum.
  95. ^ "Laser Compiler at Spectrum Computing - Sinclair ZX Spectrum games, software and hardware". Spectrum Computing. Retrieved 13 December 2022.
  96. ^ "World of Spectrum - Softek 'IS' BASIC Compiler". World of Spectrum.
  97. ^ "Integer Compiler at Spectrum Computing - Sinclair ZX Spectrum games, software and hardware". Spectrum Computing. Retrieved 13 December 2022.
  98. ^ "World of Spectrum - Integer Compiler". World of Spectrum.
  99. ^ "World of Spectrum - Softek 'FP' Full Compiler". World of Spectrum.
  100. ^ "Softek 'FP' Full Compiler at Spectrum Computing - Sinclair ZX Spectrum games, software and hardware". Spectrum Computing. Retrieved 13 December 2022.
  101. ^ "World of Spectrum - ZIP Compiler". World of Spectrum.
  102. ^ "ZIP Compiler at Spectrum Computing - Sinclair ZX Spectrum games, software and hardware". Spectrum Computing. Retrieved 13 December 2022.
  103. ^ Berry, Stephen (1984). "QL Keywords". Archived from the original on 22 February 2017. Retrieved 27 June 2023.{{cite web}}: CS1 maint: unfit URL (link)
  104. ^ "Sam Coupe Scrapbook: Sam BASIC". www.mono.org. Retrieved 13 December 2022.
  105. ^ "Sparky eZX BASIC Project". rk-internet.com.
  106. ^ "Philip Kendall - Basic". www.shadowmagic.org.uk.
  107. ^ "Philip Kendall – CheckBasic". www.shadowmagic.org.uk.
  108. ^ "Binsic Is Not Sinclair Instruction Code". 25 June 2012.
  109. ^ "ZX Spin and BASin - ULAplus". sites.google.com.
  110. ^ "ZXDunny/SpecBAS". 5 June 2021 – via GitHub.
  111. ^ "ZX-Basic: Backwardly compatible, but enhanced compiler of Sinclair BASIC programs".
  112. ^ "ZX-Basicus: analyzer/synthesizer/optimizer/interpreter of Sinclair BASIC programs for the ZX Spectrum 48K". jafma.net.

Bibliography

[edit]
  • Adamson, Ian; Kennedy, Richard (1986). Sinclair and the 'sunrise' Technology. Penguin.
  • Ardley, Neil (1984). Sinclair ZX Spectrum+ User Guide. Dorling Kindersley in association with Sinclair Research. ISBN 0-86318-080-9.
  • Vickers, Steven (1982). Sinclair ZX Spectrum BASIC Programming. Sinclair Research.
  • Vickers, Steven (1983). Sinclair ZX Spectrum BASIC Programming (2 ed.). Sinclair Research.
  • Cambridge Communication (1983). Sinclair ZX Spectrum Microdrive and Interface 1 manual. Sinclair Research.
[edit]