ZX81 character set

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
The Sinclair ZX81 character set rendered in the system font.

The ZX81 character set is the character encoding used by the Sinclair Research ZX81 family of microcomputers including the Timex Sinclair 1000 and Timex Sinclair 1500. The encoding uses one byte per character for 256 code points. It has no relationship with previously established ones like ASCII or EBCDIC, but it is related though not identical to the character set of the predecessor ZX80.

Printable characters[edit]

Screenshot of a ZX81 8K BASIC program that demonstrates all code points including BASIC keywords and nonprintable characters, rendered as question marks.

The character set has 64 unique glyphs present at code points 0–63. With the most significant bit set the character is generated in inverse video; corresponding to code points 128–191. These 128 values are the only displayable ones allowed in the video memory (known as the display file). The remaining code points (64–127 and 192–255) are used as control characters such as 118 for newline or, uniquely to Sinclair BASIC, for keywords, while some are unused.

The small effective range of only 64 unique glyphs precludes support for Latin lower case letters, and many symbols used widely in computing such as the exclamation point and the at sign. The lack of an apostrophe led some software authors to use a comma instead.

There are 11 block graphics characters, counting code point 0 which also doubles as space. Together with the 11 inverse video versions these 22 code points provide every combination of the character cell divided into 2×2 black-and-white block pixels for low-resolution 64×48 pixel graphics, or into 1×2 black, white or dithered gray wide block pixels for a 32×48 resolution. The 2×2 versions of these are also present in the Block Elements Unicode block.

Code point 11 is the double-quote (") symbol when used in the display file. The BASIC function CHR$ 192 prints as the same character but is shown as "" in BASIC source listings; it is used for including the literal " character in a string without conflict with the " string delimiter.[1]

Changes from the ZX80[edit]

The character set in the ZX81 was derived from the ZX80 character set. They have mostly the same code points, e.g. for A-Z and 0-9, but the code points are different for the block graphics characters, the symbols ", -, +, *, /, =, >, <, and the BASIC keyword tokens (with many new added). There are also changes to the control characters. Code point 1 is no longer an unprintable string terminator. The ZX81 8K BASIC ROM was also available as an upgrade for the ZX80, replacing its integer-only 4K BASIC ROM.[2]

The ZX81 system font uses an 8×8 pixel-per-character grid where most glyphs fit in 6×6 pixels leaving two pixels horizontal and vertical space between rows and columns. The ZX80's ROM which had slightly wider 7×6 pixel glyphs with only one pixel horizontal space between them. Some glyphs also received a different design in the ZX81 system font, noticeable on the *, the slashed and less rounded 0, and the less rounded $, C, G and J.

In the later Sinclair ZX Spectrum the entire character encoding was replaced with the ZX Spectrum character set, which is a derivative of ASCII and includes lower case letters and more.

Character set[edit]

ZX81 character set[1][3]
0 1 2 3 4 5 6 7 8 9 A B C D E F
0x  SP  ZXSpectrum82.svg ZXSpectrum81.svg ZXSpectrum83.svg ZXSpectrum88.svg ZXSpectrum8a.svg ZXSpectrum89.svg ZXSpectrum8b.svg ZX80 character 0x09, ZX81 character 0x08.png ZX80 character 0x0A, ZX81 character 0x09.png ZX80 character 0x0B, ZX81 character 0x0A.png "[a] £ $ : ?
1x ( ) > < = + - * / ; , . 0 1 2 3
2x 4 5 6 7 8 9 A B C D E F G H I J
3x K L M N O P Q R S T U V W X Y Z
4x RND INKEY$ PI
5x
6x
7x UP DOWN LEFT RIGHT graphics EDIT newline rubout K/L
MODE
function number cursor
8x ZXSpectrum8f.svg ZXSpectrum8d.svg ZXSpectrum8e.svg ZXSpectrum8c.svg ZXSpectrum87.svg ZXSpectrum85.svg ZXSpectrum86.svg ZXSpectrum84.svg ZX80 character 0x89, ZX81 character 0x88.png ZX80 character 0x8A, ZX81 character 0x89.png ZX80 character 0x8B, ZX81 character 0x8A.png " £ $ : ?
9x ( ) > < = + - * / ; , . 0 1 2 3
Ax 4 5 6 7 8 9 A B C D E F G H I J
Bx K L M N O P Q R S T U V W X Y Z
Cx ""[a] AT TAB CODE VAL LEN SIN COS TAN ASN ACS ATN LN EXP INT
Dx SQR SGN ABS PEEK USR STR$ CHR$ NOT **[b] OR AND <=[c] >=[d] <>[e] THEN TO
Ex STEP LPRINT LLIST STOP SLOW FAST NEW SCROLL CONT DIM REM FOR GOTO GOSUB INPUT LOAD
Fx LIST LET PAUSE NEXT POKE PRINT PLOT RUN SAVE RAND IF CLS UNPLOT CLEAR RETURN COPY
  Sinclair BASIC tokenizes keywords into single-byte code points.

See also[edit]

Notes[edit]

  1. ^ a b Code point 11 is the double-quote (") symbol when used in the video memory (called the display file). Code point 192, CHR$ 192, prints as the same character but shows as "" in BASIC listings and is used for including the literal " character in a string without conflict with the " string delimiter.[1]
  2. ^ The raise to a power multi-character operator tokenized into a single-byte code point.
  3. ^ The greater than or equal to multi-character operator tokenized into a single-byte code point.
  4. ^ The less than or equal to multi-character operator tokenized into a single-byte code point.
  5. ^ The not equal sign multi-character operator tokenized into a single-byte code point.

References[edit]

  1. ^ a b c Vickers, Steven (1981). Sinclair ZX81 BASIC Programming. Sinclair Research Ltd.
  2. ^ "8K BASIC ROM UPGRADE".
  3. ^ Wearmouth, Geoff. "An Assembly Listing of the Operating System of the ZX81 ROM". Archived from the original on August 15, 2015.