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 |
---|---|---|
0 | 00 | not used |
1 | 01 | not used |
2 | 02 | not used |
3 | 03 | not used |
4 | 04 | not used |
5 | 05 | not used |
6 | 06 | print COMMA Moves the current print position on to column 16 of the current line, or column 0 of the next line, whichever comes first |
7 | 07 | EDIT |
8 | 08 | cursor left Acts as backspace |
9 | 09 | cursor right |
10 | 0A | cursor down |
11 | 0B | cursor up |
12 | 0C | DELETE |
13 | 0D | ENTER I.e. CR/LF |
14 | 0E | number 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. |
15 | 0F | not used |
16 | 10 | INK control |
17 | 11 | PAPER control |
18 | 12 | FLASH control |
19 | 13 | BRIGHT control |
20 | 14 | INVERSE control |
21 | 15 | OVER control |
22 | 16 | AT control |
23 | 17 | TAB 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.) | ||
24 | 18 | not used |
25 | 19 | not used |
26 | 1A | not used |
27 | 1B | not used |
28 | 1C | not used |
29 | 1D | not used |
30 | 1E | not used |
31 | 1F | not used |
32 | 20 | (Space) |
33 | 21 | ! |
34 | 22 | " |
35 | 23 | # |
36 | 24 | $ |
37 | 25 | % |
38 | 26 | & |
39 | 27 | ' |
40 | 28 | ( |
41 | 29 | ) |
42 | 2A | * |
43 | 2B | + |
44 | 2C | , |
45 | 2D | - |
46 | 2E | . |
47 | 2F | / |
48 | 30 | 0 |
49 | 31 | 1 |
50 | 32 | 2 |
51 | 33 | 3 |
52 | 34 | 4 |
53 | 35 | 5 |
54 | 36 | 6 |
55 | 37 | 7 |
56 | 38 | 8 |
57 | 39 | 9 |
58 | 3A | : |
59 | 3B | ; |
60 | 3C | < |
61 | 3D | = |
62 | 3E | > |
63 | 3F | ? |
64 | 40 | @ |
65 | 41 | A |
66 | 42 | B |
67 | 43 | C |
68 | 44 | D |
69 | 45 | E |
70 | 46 | F |
71 | 47 | G |
72 | 48 | H |
73 | 49 | I |
74 | 4A | J |
75 | 4B | K |
76 | 4C | L |
77 | 4D | M |
78 | 4E | N |
79 | 4F | O |
80 | 50 | P |
81 | 51 | Q |
82 | 52 | R |
83 | 53 | S |
84 | 54 | T |
85 | 55 | U |
86 | 56 | V |
87 | 57 | W |
88 | 58 | X |
89 | 59 | Y |
90 | 5A | Z |
91 | 5B | [ |
92 | 5C | \ |
93 | 5D | ] |
94 | 5E | ^ In the form with a vertical bar |
95 | 5F | _ |
96 | 60 | £ ASCII has ` |
97 | 61 | a |
98 | 62 | b |
99 | 63 | c |
100 | 64 | d |
101 | 65 | e |
102 | 66 | f |
103 | 67 | g |
104 | 68 | h |
105 | 69 | i |
106 | 6A | j |
107 | 6B | k |
108 | 6C | l |
109 | 6D | m |
110 | 6E | n |
111 | 6F | o |
112 | 70 | p |
113 | 71 | q |
114 | 72 | r |
115 | 73 | s |
116 | 74 | t |
117 | 75 | u |
118 | 76 | v |
119 | 77 | w |
120 | 78 | x |
121 | 79 | y |
122 | 7A | z |
123 | 7B | { |
124 | 7C | | |
125 | 7D | } |
126 | 7E | ~ |
127 | 7F | © ASCII has DEL |
128 | 80 | block graphic |
129 | 81 | block graphic |
130 | 82 | block graphic |
131 | 83 | block graphic |
132 | 84 | block graphic |
133 | 85 | block graphic |
134 | 86 | block graphic |
135 | 87 | block graphic |
136 | 88 | block graphic |
137 | 89 | block graphic |
138 | 8A | block graphic |
139 | 8B | block graphic |
140 | 8C | block graphic |
141 | 8D | block graphic |
142 | 8E | block graphic |
143 | 8F | block 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: | ||
144 | 90 | udg A |
145 | 91 | udg B |
146 | 92 | udg C |
147 | 93 | udg D |
148 | 94 | udg E |
149 | 95 | udg F |
150 | 96 | udg G |
151 | 97 | udg H |
152 | 98 | udg I |
153 | 99 | udg J |
154 | 9A | udg K |
155 | 9B | udg L |
156 | 9C | udg M |
157 | 9D | udg N |
158 | 9E | udg O |
159 | 9F | udg P |
160 | A0 | udg Q |
161 | A1 | udg R |
162 | A2 | udg S |
163 | A3 | udg T |
164 | A4 | udg 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. | ||
165 | A5 | RND |
166 | A6 | INKEY$ |
167 | A7 | PI |
168 | A8 | FN |
169 | A9 | POINT |
170 | AA | SCREEN$ |
171 | AB | ATTR |
172 | AC | AT |
173 | AD | TAB |
174 | AE | VAL$ |
175 | AF | CODE |
176 | B0 | VAL |
177 | B1 | LEN |
178 | B2 | SIN |
179 | B3 | COS |
180 | B4 | TAN |
181 | B5 | ASN |
182 | B6 | ACS |
183 | B7 | ATN |
184 | B8 | LN |
185 | B9 | EXP |
186 | BA | INT |
187 | BB | SQR |
188 | BC | SGN |
189 | BD | ABS |
190 | BE | PEEK |
191 | BF | IN |
192 | C0 | USR |
193 | C1 | STR$ |
194 | C2 | CHR$ |
195 | C3 | NOT |
196 | C4 | BIN |
197 | C5 | OR |
198 | C6 | AND |
199 | C7 | <= |
200 | C8 | >= |
201 | C9 | <> |
202 | CA | LINE |
203 | CB | THEN |
204 | CC | TO |
205 | CD | STEP |
206 | CE | DEF FN |
207 | CF | CAT |
208 | D0 | FORMAT |
209 | D1 | MOVE |
210 | D2 | ERASE |
211 | D3 | OPEN # |
212 | D4 | CLOSE # |
213 | D5 | MERGE |
214 | D6 | VERIFY |
215 | D7 | BEEP |
216 | D8 | CIRCLE |
217 | D9 | INK |
218 | DA | PAPER |
219 | DB | FLASH |
220 | DC | BRIGHT |
221 | DD | INVERSE |
222 | DE | OVER |
223 | DF | OUT |
224 | E0 | LPRINT |
225 | E1 | LLIST |
226 | E2 | STOP |
227 | E3 | READ |
228 | E4 | DATA |
229 | E5 | RESTORE |
230 | E6 | NEW |
231 | E7 | BORDER |
232 | E8 | CONTINUE |
233 | E9 | DIM |
234 | EA | REM |
235 | EB | FOR |
236 | EC | GO TO |
237 | ED | GO SUB |
238 | EE | INPUT |
239 | EF | LOAD |
240 | F0 | LIST |
241 | F1 | LET |
242 | F2 | PAUSE |
243 | F3 | NEXT |
244 | F4 | POKE |
245 | F5 | |
246 | F6 | PLOT |
247 | F7 | RUN |
248 | F8 | SAVE |
249 | F9 | RANDOMIZE |
250 | FA | IF |
251 | FB | CLS |
252 | FC | DRAW |
253 | FD | CLEAR |
254 | FE | RETURN |
255 | FF | COPY |
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. |