Sinclair BASIC

Sinclair BASIC

Sinclair BASIC (taking its name from innovator Sir Clive Sinclair) is a dialect of the BASIC programming language used in the 8-bit home computers from Sinclair Research and Timex Sinclair. The Sinclair BASIC interpreter was made by Nine Tiles Networks Ltd.

Originally developed in 1979 to fit in the 4 kB ROM of the ZX80, it was initially an incomplete implementation of the 1978 ANSI minimal BASIC standard and evolved through the 8 kB ROM ZX81 and TS1000 to be an almost complete version in the 16 kB ROM ZX Spectrum.

Original Sinclair BASIC

[


The larger upper portion of the screen shows a portion of the currently loaded program, "3D Monster Maze". The currently selected line is marked with the "program cursor", the inverse greater than sign. The lower portion of the screen shows the current version of the edited line in the line-oriented editor buffer. The current insert position is marked with the inverse letter cursor; the letter "L" signifies that the keyboard is in the ordinary letter input mode. The user has just changed the busy-waiting loop upper limit to the minimum, as per the original game instructions, to maximize the in-game speed; hitting ENTER will commit the change.]

Reserved words

On the Spectrum there are 86 reserved words in Sinclair BASIC, denoting commands (of which there were 50), functions (31), and "other keywords" (5). They were entered with the ZX Spectrum's sometimes obscure context-based keyword entry system, whereby BEEP (for example), was keyed by pressing CAPS plus SYMBOL SHIFT, followed by SYMBOL SHIFT plus Z. More common commands were entered using a single keystroke, for example pressing P caused the entire command PRINT to appear.

:ABS, ACS, AND1, ASN, "AT", ATN, ATTR, BEEP, BIN, BORDER, BRIGHT, CAT2, CHR$3, CIRCLE, CLEAR, CLOSE#2, CLS, CODE3, CONTINUE, COPY, COS, DATA, DEF FN, DIM, DRAW, ERASE2, EXP, FLASH, FN, FOR, FORMAT2, GO SUB, GO TO, IF4, IN, INK, INKEY$3, INPUT, INT, INVERSE, LEN, LET5, "LINE", LIST, LLIST, LN, LOAD, LPRINT, MERGE, MOVE2, NEW, NEXT, NOT1, OPEN#2, OR1, OUT, OVER, PAPER, PAUSE, PEEK, PI, PLOT, POINT, POKE, PRINT, RANDOMIZE, READ, REM, RESTORE, RETURN, RND, RUN, SAVE, SCREEN$3, SGN, SIN, SQR, "STEP", STR$3, "TAB", TAN, "THEN" 4, TO, USR, VAL3, 6, VAL$3, VERIFY

Commands found exclusively on the ZX81 and its clones the TS1000 and TS1500 are:

:FAST, SCROLL, SLOW, UNPLOT, GOSUB, GOTO (vs the Spectrum's functionally identical GO SUB, GO TO)

On the ZX Spectrum each reserved word was assigned a character code between 165 and 255 in the latter half of the system character set, and expanded by referencing a token table held in ROM. As a result, any reserved word in a program listing occupied just one byte of memory, 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 a single byte.

The Spectrum 128K models—the Spectrum 128K, Spectrum +2, +3, +2A, and +2B—introduced a conventional letter-by-letter BASIC input system, and two new commands, neither of which were present or recognised by the machine's legacy version of 48K BASIC:

:PLAY (which operated the 128K model's new AY-3-8910 music chip), SPECTRUM (which switched the 128K Spectrum into a 48K Spectrum compatibility mode)

Notes

# The AND, NOT, and OR functions are logical operators.
# 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 "*").
# String variable names must consist of only one alphabetical character.
Thus, «LET A=5», «LET Apples=5», and «LET A$="Hello"» are all good, while «LET APPLES$="Fruit"» is not.
# Unlike most other BASIC dialects, there is no ELSE operator in the IF–THEN(–ELSE) clause.
Thus, instead of
10 IF V=5 THEN GO TO 50 ELSE GO TO 100
it is
10 IF V=5 THEN GO TO 50
20 GO TO 100
# LET is compulsory (i.e., «LET A=1» but never «A=1»). This practice is also different from most other BASIC dialects.
# The VAL function does not just evaluate numbers but instead evaluates full expressions. For example, «PRINT VAL(A$)» will output 14 when given an A$ of "3*3+4+COS(0)".

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 in a manner similar to arrays. For example, «A$ (5 TO 10) » will give a substring starting with the 5th and ending with the 10th character of A$. As with modern programming languages such as Python, it was therefore possible to replace the LEFT$() and RIGHT$() commands simply by omitting the left or right array position respectively; for instance «A$ ( TO 5) » is equivalent to LEFT$(5).

Timex BASIC

The Timex BASIC dialect, used on the Spectrum-compatible TS2068, but not the TC2048, which used the ordinary Sinclair BASIC, has the following six keywords as well as the ordinary Sinclair BASIC ones:

:DELETE, FREE, ON ERR, RESET, SOUND, STICK
DELETE deletes BASIC program lines. SHIFT + 0 with the K cursor produces the command DELETE
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 detection function mostly used as ON ERR GO TO or ON ERR GO SUB
RESET has no use on the basic machine. It was intended to reset peripherals
SOUND commands the AY-3-8192 sound ship
STICK is a function that gives the position of the internal joystick (Timex Sinclair 2090)

Extensions and variants

*Beta BASIC, written by Dr. Andy Wright, was originally a BASIC extension, but ended up as a full-fledged interpreter.

References

*Vickers, Steven (1982). "Sinclar ZX Spectrum BASIC Programming". Sinclair Research.
*Ardley, Neil (1984). "Sinclair ZX Spectrum+ User Guide". Dorling Kindersley in association with Sinclair Research. ISBN 0-86318-080-9.

External links

* [http://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] — also by Vickers
* [http://www.worldofspectrum.org/sinclairbasic/history.html The History of Sinclair BASIC] — By Andrew Owen, whose Sinclair BASIC documents are hosted by the World of Spectrum website


Wikimedia Foundation. 2010.

Игры ⚽ Нужен реферат?

Look at other dictionaries:

  • Sinclair BASIC — (назван по фамилии изобретателя сэра Клайва Синклера)  диалект языка программирования BASIC, применявшийся на 8 разрядных бытовых компьютерах производства Sinclair Research и Timex Sinclair. Интерпретатор Sinclair BASIC разработан компанией… …   Википедия

  • Sinclair BASIC — es el nombre que recibe el BASIC implementado en la ROM de los ordenadores Sinclair desde el ZX80 hasta las diferentes versiones del ZX Spectrum. Estos ordenadores se comercializaron desde 1980 (modelo Sinclair ZX80) hasta 1992[1] (modelos… …   Wikipedia Español

  • Sinclair BASIC — es el nombre que recibe el BASIC implementado en la ROM de los ordenadores Sinclair desde el ZX 81 hasta el ZX Spectrum. Estos ordenadores se comercializaron en los años 80 …   Enciclopedia Universal

  • Sinclair ZX Spectrum — de 48K. El Sinclair ZX Spectrum fue un ordenador de 8 bits basado en el microprocesador Zilog Z80A, fabricado por la compañía británica Sinclair Research y lanzado al mercado el 23 de abril de 1982. En Europa, el Sinclair ZX Spectrum fue uno de… …   Wikipedia Español

  • Sinclair ZX80 — ZX80 Тип Домашний компьютер Выпущен 1980 Выпускался по 1981 Процессор Z80 (на большинстве машин стоял аналог Память …   Википедия

  • Sinclair ZX80 — Sinclair ZX80. El Sinclair ZX80 fue un computador personal comercializado a partir de 1980 por Science of Cambridge. Fue notable por ser la primera computadora disponible en el Reino Unido por cien libras (£99,95, para ser exacto). Se… …   Wikipedia Español

  • Sinclair ZX80 — Der Sinclair ZX80 ist ein Heimcomputer der britischen Firma Sinclair aus dem Jahr 1980. Er ist der direkte Vorgänger des Sinclair ZX81. Die Hardware des in weit höheren Stückzahlen produzierten Nachfolgers ist ähnlich, jedoch höher integriert und …   Deutsch Wikipedia

  • Sinclair ZX81 — ZX81 Тип Домашний компьютер Выпущен 1981 Выпускался по 1983 Процессор Z80 (на большинстве машин стоял аналог NEC μPD780C 1) …   Википедия

  • BASIC — Класс языка: алгоритмическое, процедурное, объектное программирование Появился в: 1963 г. Расширение файлов: .bas Типизация данных: нестрогая Бейсик (от BASIC, сокращение от англ.  …   Википедия

  • BASIC — Información general Paradigma estructurado imperativo Apareció en 1964 Diseñado por John George Kemeny; Thomas Eugene Kurtz …   Wikipedia Español

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”