Sinclair Logo


Sinclair ZX Spectrum Character Set



The Sinclair ZX Spectrum, unlike the earlier ZX80 and ZX81, used an almost standard ASCII character set for character codes up to 127 decimal, but had its own system for characters 128 to 255.
The full character set is listed below, with some annotation.

Decimal
Code
Hexadecimal
Code
Character
  000not used
  101not used
  202not used
  303not used
  404not used
  505not used
  606print COMMA
Moves the current print position on to column 16 of the current line, or column 0 of the next line, whichever comes first
  707EDIT
  808cursor left     Acts as backspace
  909cursor right
 100Acursor down
 110Bcursor up
 120CDELETE
 130DENTER      I.e. CR/LF
 140Enumber
In Spectrum BASIC program listings, the character form of numerical constants (e.g. 3.142) is followed, invisibly, by character 14 then the five-byte floating point binary equivalent of the number.
 150Fnot used
 1610INK control
 1711PAPER control
 1812FLASH control
 1913BRIGHT control
 2014INVERSE control
 2115OVER control
 2216AT control
 2317TAB control
Normally to temporarily change the colour that text was printed in you would use a statement of the form:
PRINT INK 3;"Hello"
which prints the word Hello in magenta.
However it is also possible to embed control codes within text strings so that for example
LET a$=CHR$(16)+CHR$(3)+"Hello":PRINT a$
would also print Hello in magenta.
It is even possible to embed the control codes within program listings so that different parts of the program list in different colours. In this case the control codes are not visible in the listing and of course have no effect on paper printouts.
Similarly the codes for PAPER, FLASH, BRIGHT, INVERSE and OVER, followed by a single byte parameter, can be embedded.

The AT and TAB control characters can also be embedded but are followed by two bytes as parameters. For AT these are the line and column number to move the print position to, and for TAB they represent a number from 0-65535 which is then reduced to modulo 32 to obtain the column number to move to. (So it seems pointless using two bytes.)
 2418not used
 2519not used
 261Anot used
 271Bnot used
 281Cnot used
 291Dnot used
 301Enot used
 311Fnot used
 3220       (Space)
 3321!
 3422"
 3523#
 3624$
 3725%
 3826&
 3927'
 4028(
 4129)
 422A*
 432B+
 442C,
 452D-
 462E.
 472F/
 48300
 49311
 50322
 51333
 52344
 53355
 54366
 55377
 56388
 57399
 583A:
 593B;
 603C<
 613D=
 623E>
 633F?
 6440@
 6541A
 6642B
 6743C
 6844D
 6945E
 7046F
 7147G
 7248H
 7349I
 744AJ
 754BK
 764CL
 774DM
 784EN
 794FO
 8050P
 8151Q
 8252R
 8353S
 8454T
 8555U
 8656V
 8757W
 8858X
 8959Y
 905AZ
 915B[
 925C\
 935D]
 945E^      In the form with a vertical bar
 955F_
 9660£      ASCII has `
 9761a
 9862b
 9963c
10064d
10165e
10266f
10367g
10468h
10569i
1066Aj
1076Bk
1086Cl
1096Dm
1106En
1116Fo
11270p
11371q
11472r
11573s
11674t
11775u
11876v
11977w
12078x
12179y
1227Az
1237B{
1247C|
1257D}
1267E~
1277F©      ASCII has DEL
12880block graphic
12981block graphic
13082block graphic
13183block graphic
13284block graphic
13385block graphic
13486block graphic
13587block graphic
13688block graphic
13789block graphic
1388Ablock graphic
1398Bblock graphic
1408Cblock graphic
1418Dblock graphic
1428Eblock graphic
1438Fblock graphic
The Spectrum has 16 'block graphic' characters which consist of a character square divided into four smaller squares, with every combination of none, one, two, three or four of the small squares 'filled-in', as shown below:

Block graphic characters
14490udg A
14591udg B
14692udg C
14793udg D
14894udg E
14995udg F
15096udg G
15197udg H
15298udg I
15399udg J
1549Audg K
1559Budg L
1569Cudg M
1579Dudg N
1589Eudg O
1599Fudg P
160A0udg Q
161A1udg R
162A2udg S
163A3udg T
164A4udg U
'udg' stands for User Defined Graphic.
There were 21 characters whose bit patterns, on an 8x8 grid, could be defined by the programmer. Typically they were used for special symbols like greek letters or for missiles in games.
Before they were redefined they appeared as the capital letters A-U.
165A5RND
166A6INKEY$
167A7PI
168A8FN
169A9POINT
170AASCREEN$
171ABATTR
172ACAT
173ADTAB
174AEVAL$
175AFCODE
176B0VAL
177B1LEN
178B2SIN
179B3COS
180B4TAN
181B5ASN
182B6ACS
183B7ATN
184B8LN
185B9EXP
186BAINT
187BBSQR
188BCSGN
189BDABS
190BEPEEK
191BFIN
192C0USR
193C1STR$
194C2CHR$
195C3NOT
196C4BIN
197C5OR
198C6AND
199C7<=
200C8>=
201C9<>
202CALINE
203CBTHEN
204CCTO
205CDSTEP
206CEDEF FN
207CFCAT
208D0FORMAT
209D1MOVE
210D2ERASE
211D3OPEN #
212D4CLOSE #
213D5MERGE
214D6VERIFY
215D7BEEP
216D8CIRCLE
217D9INK
218DAPAPER
219DBFLASH
220DCBRIGHT
221DDINVERSE
222DEOVER
223DFOUT
224E0LPRINT
225E1LLIST
226E2STOP
227E3READ
228E4DATA
229E5RESTORE
230E6NEW
231E7BORDER
232E8CONTINUE
233E9DIM
234EAREM
235EBFOR
236ECGO TO
237EDGO SUB
238EEINPUT
239EFLOAD
240F0LIST
241F1LET
242F2PAUSE
243F3NEXT
244F4POKE
245F5PRINT
246F6PLOT
247F7RUN
248F8SAVE
249F9RANDOMIZE
250FAIF
251FBCLS
252FCDRAW
253FDCLEAR
254FERETURN
255FFCOPY
Character codes from 165 to 255 are the BASIC keywords. They are stored within the program as a single byte but in listings they are expanded to full words, including a space before and after as necessary to improve readability.
The idea of storing BASIC's words as a single byte was carried through from the Sinclair ZX80 which had a very small memory. 'PRINT ' would normally take up six bytes whereas character 245 is only one byte.



Close window


Hosted by www.Geocities.ws

1