ZX81

From Grahams Wiki
Jump to: navigation, search

Contents

Useful links

Specifications

CPU Z80 @ 3.25mhz
Ram 1K
Rom 8K
Display 32x24 Monochrome character display. 64x48 block graphics mode

With interrupt tricks, a 192x168 bit mode can be achieved.

Sound None
keyboard 40 key membrane
Power 9v @ 1A unregulated, center +ve

System variables

Again from the book above.

Old rom system variables

Dec Hex Name
16384 4000 ERR_NR
16385 4001 FLAGS
16386 4002 PPC
16388 4004 E_ADDR
16390 4006 E_PPC
16392 4008 VARS
16394 400A E_LINE
16396 400C D_FILE
16398 400E DF_EA
16400 4010 DF_END
16402 4012 DF_SZ
16403 4013 S_TOP
16405 4015 X_PTR
16407 4017 OLDPPC
16409 4019 FLAGX
16410 401A T_ADDR
16412 401C SEED
16414 401E FRAMES
16416 4020 V_ADDR
16418 4022 ACC
16420 4024 S_POSN
16422 4026 CH_ADD

New rom system variables

Decimal Hex Name
16384 4000 ERR_NR
16385 4001 FLAGS
16386 4002 ERR_SP
16388 4004 RAMTOP
16390 4006 MODE
16391 4007 PPC
16393 4009 VERSN
16394 400A E_PPC
16396 400C D_FILE
16398 400E DF_CC
16400 4010 VARS
16402 4012 DEST
16404 4014 E_LINE
16406 4016 CH_ADD
16408 4018 X_PTR
16410 401A STKBOT
16412 401C STKEND
16414 401E BERG
16415 401F MEM
16417 4021 SPARE1
16418 4022 DF_SZ
16419 4023 S_TOP
16421 4025 LAST_K
16423 4027 DB_ST
16424 4028 MARGIN
16425 4029 NXTLIN
16427 402B OLDPPC
16429 402D FLAGX
16430 402E STRLEN
16432 4030 T_ADDR
16434 4032 SEED
16436 4034 FRAMES
16438 4036 COORDS
16440 4038 PR_CC
16441 4039 S_POSN
16443 403B CDFLAG
16444 403C PRBUFF
16477 405D MEMBOT
16507 407B SPARE2


System Variables by name

Name Old Rom New Rom #Bytes Purpose
ACC 4022 2 Value of last expression
BERG 401E 1 Used by floating point calculator
CDFLAG 403B 1 Flags relating to FAST/SLOW mode
CH_ADD 4026 4016 2 Address of the next character to interpret
COORDS 4036 2 Coordinates of last point PLOTed
D_FILE 400C 400C 2 Address of start of display file
DB_ST 4027 1 Debounce status of keyboard
DEST 4012 2 Address of variable being assigned
DF_CC 400E 2 Address of print position within display file
DF_EA 400E 2 Address of start of lower part of screen
DF_END 4010 2 Address of end of display file
DF_SZ 4012 4022 2 Number of lines in lower part of screen
E_ADDR 4004 2 Address of cursor in edit line
E_LINE 400A 4014 2 Address of start of edit line
E_PPC 4006 400A 2 Line number of line with cursor
ERR_NR 4000 4000 1 Current report code minus one
ERR_SP 4002 2 Address of top of GOSUB stack
FLAGS 4001 4001 1 Various flags
FLAGX 4019 402D 1 Various flags
FRAMES 401E 4034 2 Updated once for every TV frame displayed
LAST_K 4025 2 Keyboard scan taken after the last TV frame
MARGIN 4028 1 Number of blank lines above or below picture
MEM 401F 2 Address of start of calculator's memory area
MEMBOT 405D 1E Area which may be used for calculator memory
MODE 4006 1 Current cursor mode
NXTLIN 4029 2 Address of next program line to be executed
OLDPPC 4017 402B 2 Line number to which CONT/CONTINUE jumps
PPC 4002 4007 2 Line number of line being executed
PR_CC 4038 1 Address of LPRINT position (high part assumed 40)
PRBUFF 403C 21h Buffer to store LPRINT output
RAMTOP 4004 2 Address of reserved area (not wiped out by NEW)
S_POSN 4024 4039 2 Coordinates of print position
S_TOP 4013 4023 2 Line number of line at top of screen
SEED 401C 4032 2 Seed for random number generator
SPARE1 4021 1 One spare byte
SPARE2 407B 2 Two spare bytes
STKBOT 401A 2 Address of calculator stack
STKEND 401C 2 Address of end of calculator stack
STRLEN 402E 2 Information concerning assigning of strings
T_ADDR 401A 4030 2 Address of next item in syntax table
V_ADDR 4020 2 Address of variable name to be assigned
VARS 4008 4010 2 Address of start of variables area
VERSN 4009 1 First system variable to be SAVEd
X_PTR 4015 4018 2 Address of char. preceding syntax error marker

Memory map

Map from Thunor as from the link above.

                 OLD ROM                NEW ROM   

Top of memory  --+------------------+   +------------------+-- Top of memory
                 |                  |   | Reserved area    |
                 |                  |   +------------------+-- (RAMTOP)
                 |                  |   | GOSUB stack      |
                 |                  |   +------------------+-- (ERR_SP)
                 |                  |   | Machine stack    |
                 |                  |   +------------------+-- SP
                 | Machine stack    |   | Spare memory     |
SP             --+------------------+   +------------------+-- (STKEND)
                 | Spare memory     | ^ | Calculator stack |
(DF_END)       --+------------------+ | +------------------+-- (STKBOT)
                 | Screen           | | | Edit line        |
(D_FILE)       --+------------------+   +------------------+-- (E_LINE)
                 | Edit line        |   | User variables   |
(E_LINE)       --+------------------+   +------------------+-- (VARS)
                 | User variables   |   | Screen           |
(VARS)         --+------------------+   +------------------+-- (D_FILE)
                 | User program     |   | User program     |
4028h (16424d) --+------------------+   +------------------+-- 407Dh (16509d)
                 | System variables |   | System variables |
4000h (16384d) --+------------------+   +------------------+-- 4000h (16384d )

Components

Character set and opcode map

Dec Hex Character z80 After CBh After EDh
0 00 <space> nop rlc b
1 01 Zx81 chr 01.png ld bc,nnnn rlc c
2 02 Zx81 chr 02.png ld (bc),a rlc d
3 03 Zx81 chr 03.png inc bc rlc e
4 04 Zx81 chr 04.png inc b rlc h
5 05 Zx81 chr 05.png dec b rlc l
6 06 Zx81 chr 06.png ld b,nn rlc (hl)
7 07 Zx81 chr 07.png rlca rlc a
8 08 Zx81 chr 08.png ex af,af' rrc b
9 09 Zx81 chr 09.png add hl,bc rrc c
10 0A Zx81 chr 0a.png ld a,(bc) rrc d
11 0B " dec bc rrc e
12 0C £ inc c rrc h
13 0D $ dec c rrc l
14 0E  : ld c,nn rrc (hl)
15 0F  ? rrca rrc a
16 10 ( djnz nn rl b
17 11 ) ld de,nnnn rl c
18 12 > ld (de),a rl d
19 13 < inc de rl e
20 14 = inc d rl h
21 15 + dec d rl l
22 16 - ld d,nn rl (hl)
23 17 * rla rl a
24 18 / jr nn rr b
25 19  ; add hl,de rr c
26 1A , ld a,(de) rr d
27 1B . dec de rr e
28 1C 0 inc e rr h
29 1D 1 dec e rr l
30 1E 2 ld e,nn rr (hl)
31 1F 3 rra rr a
32 20 4 jr nz,nn sla b
33 21 5 ld hl,nnnn sla c
34 22 6 ld (nnnn),hl sla d
35 23 7 inc hl sla e
36 24 8 inc h sla h
37 25 9 dec h sla l
38 26 A ld h,nn sla (hl)
39 27 B daa sla a
40 28 C jr z,nn sra b
41 29 D add hl,hl sra c
42 2A E ld hl,(nnnn) sra d
43 2B F dec hl sra e
44 2C G inc l sra h
45 2D H dec l sra l
46 2E I ld l,nn sra (hl)
47 2F J cpl sra a
48 30 K jr nc,nn
49 31 L ld sp,nnnn
50 32 M ld (nnnn),a
51 33 N inc sp
52 34 O inc (hl)
53 35 P dec (hl)
54 36 Q ld (hl),nn
55 37 R scf
56 38 S jr c,nn srl b
57 39 T add hl,sp srl c
58 3A U ld a,(nnnn) srl d
59 3B V dec sp srl e
60 3C W inc a srl h
61 3D X dec a srl l
62 3E Y ld a,nn srl (hl)
63 3F Z ccf srl a
64 40 RND ld b,b bit 0,b in b,(c)
65 41 INKEY$ ld b,c bit 0,c out (c),b
66 42 PI ld b,d bit 0,d sbc hl,bc
67 43 not used ld b,e bit 0,e ld (nnnn),bc
68 44 not used ld b,h bit 0,h neg
69 45 not used ld b,l bit 0,l retn
70 46 not used ld b,(hl) bit 0,(hl) im 0
71 47 not used ld b,a bit 0,a ld i,a
72 48 not used ld c,b bit 1,b in c,(c)
73 49 not used ld c,c bit 1,c out (c),c
74 4A not used ld c,d bit 1,d adc hl,bc
75 4B not used ld c,e bit 1,e ld bc,(nnnn)
76 4C not used ld c,h bit 1,h
77 4D not used ld c,l bit 1,l reti
78 4E not used ld c,(hl) bit 1,(hl)
79 4F not used ld c,a bit 1,a ld r,a
80 50 not used ld d,b bit 2,b in d,(c)
81 51 not used ld d,c bit 2,c out (c),d
82 52 not used ld d,d bit 2,d sbc hl,de
83 53 not used ld d,e bit 2,e ld (nnnn),de
84 54 not used ld d,h bit 2,h
85 55 not used ld d,l bit 2,l
86 56 not used ld d,(hl) bit 2,(hl) im 1
87 57 not used ld d,a bit 2,a ld a,i
88 58 not used ld e,b bit 3,b in e,(c)
89 59 not used ld e,c bit 3,c out (c),e
90 5A not used ld e,d bit 3,d adc hl,de
91 5B not used ld e,e bit 3,e ld de,(nnnn)
92 5C not used ld e,h bit 3,h
93 5D not used ld e,l bit 3,l
94 5E not used ld e,(hl) bit 3,(hl) im 2
95 5F not used ld e,a bit 3,a ld a,r
96 60 not used ld h,b bit 4,b in h,(c)
97 61 not used ld h,c bit 4,c out (c),h
98 62 not used ld h,d bit 4,d sbc hl,hl
99 63 not used ld h,e bit 4,e ld (nnnn),hl
100 64 not used ld h,h bit 4,h rrd
101 65 not used ld h,l bit 4,l in l,(c)
102 66 not used ld h,(hl) bit 4,(hl) out (c),l
103 67 not used ld h,a bit 4,a rrd
104 68 not used ld l,b bit 5,b in l,(c)
105 69 not used ld l,c bit 5,c out (c),l
106 6A not used ld l,d bit 5,d adc hl,hl
107 6B not used ld l,e bit 5,e ld de,(nnnn)
108 6C not used ld l,h bit 5,h
109 6D not used ld l,l bit 5,l
110 6E not used ld l,(hl) bit 5,(hl)
111 6F not used ld l,a bit 5,a rld
112 70 Cursor up ld (hl),b bit 6,b
113 71 Cursor down ld (hl),c bit 6,c
114 72 Cursor left ld (hl),d bit 6,d sbc hl,sp
115 73 Cursor Right ld (hl),e bit 6,e ld (nnnn),sp
116 74 GRAPHICS ld (hl),h bit 6,h
117 75 EDIT ld (hl),l bit 6,l
118 76 NEWLINE halt bit 6,(hl)
119 77 RUBOUT ld (hl),a bit 6,a
120 78 K/L mode ld a,b bit 7,b in a,(c)
121 79 FUNCTION ld a,c bit 7,c out (c),a
122 7A not used ld a,d bit 7,d adc hl,sp
123 7B not used ld a,e bit 7,e ld sp,(nnnn)
124 7C not used ld a,h bit 7,h
125 7D not used ld a,l bit 7,l
126 7E number ld a,(hl) bit 7,(hl)
127 7F Cursor ld a,a bit 7,a
128 80 Zx81 chr 80.png add b res 0,b
129 81 Zx81 chr 81.png add c res 0,c
130 82 Zx81 chr 82.png add d res 0,d
131 83 Zx81 chr 83.png add e res 0,e
132 84 Zx81 chr 84.png add h res 0,h
133 85 Zx81 chr 85.png add l res 0,l
134 86 Zx81 chr 86.png add (hl) res 0,(hl)
135 87 Zx81 chr 87.png add a res 0,a
136 88 Zx81 chr 88.png adc b res 1,b
137 89 Zx81 chr 89.png adc c res 1,c
138 8A Zx81 chr 8a.png adc d res 1,d
139 8B  "  adc e res 1,e
140 8C  £  adc h res 1,h
141 8D  $  adc l res 1,l
142 8E  :  adc (hl) res 1,(hl)
143 8F  ?  adc a res 1,a
144 90  (  sub b res 2,b
145 91  )  sub c res 2,c
146 92  >  sub d res 2,d
147 93  <  sub e res 2,e
148 94  =  sub h res 2,h
149 95  +  sub l res 2,l
150 96  -  sub (hl) res 2,(hl)
151 97  *  sub a res 2,a
152 98  /  sbc b res 3,b
153 99  ;  sbc c res 3,c
154 9A  ,  sbc d res 3,d
155 9B  .  sbc e res 3,e
156 9C  0  sbc h res 3,h
157 9D  1  sbc l res 3,l
158 9E  2  sbc (hl) res 3,(hl)
159 9F  3  sbc a res 3,a
160 A0  4  and b res 4,b ldi
161 A1  5  and c res 4,c cpi
162 A2  6  and d res 4,d ini
163 A3  7  and e res 4,e outi
164 A4  8  and h res 4,h
165 A5  9  and l res 4,l
166 A6  A  and (hl) res 4,(hl)
167 A7  B  and a res 4,a
168 A8  C  xor b res 5,b ldd
169 A9  D  xor c res 5,c cpd
170 AA  E  xor d res 5,d ind
171 AB  F  xor e res 5,e outd
172 AC  G  xor h res 5,h
173 AD  H  xor l res 5,l
174 AE  I  xor (hl) res 5,(hl)
175 AF  J  xor a res 5,a
176 B0  K  or b res 6,b ldir
177 B1  L  or c res 6,c cpir
178 B2  M  or d res 6,d inir
179 B3  N  or e res 6,e otir
180 B4  O  or h res 6,h
181 B5  P  or l res 6,l
182 B6  Q  or (hl) res 6,(hl)
183 B7  R  or a res 6,a
184 B8  S  cp b res 7,b lddr
185 B9  T  cp c res 7,c cpdr
186 BA  U  cp d res 7,d indr
187 BB  V  cp e res 7,e otdr
188 BC  W  cp h res 7,h
189 BD  X  cp l res 7,l
190 BE  Y  cp (hl) res 7,(hl)
191 BF  Z  cp a res 7,a
192 C0  "" ret nz set 0,b
193 C1 AT pop bc set 0,c
194 C2 TAB jp nz,nnnn set 0,d
195 C3 not used jp nnnn set 0,e
196 C4 CODE call nz,nnnn set 0,h
197 C5 VAL push bc set 0,l
198 C6 LEN add a,nn set 0,(hl)
199 C7 SIN rst 00h set 0,a
200 C8 COS ret z set 1,b
201 C9 TAN ret set 1,c
202 CA ASN jp z,nnnn set 1,d
203 CB ACS CB set 1,e
204 CC ATN call z,nnnn set 1,h
205 CD LN call nnnn set 1,l
206 CE EXP adc a,nn set 1,(hl)
207 CF INT rst 08h set 1,a
208 D0 SQR ret nc set 2,b
209 D1 SGN pop de set 2,c
210 D2 ABS jp nc,nnnn set 2,d
211 D3 PEEK out (nn),a set 2,e
212 D4 USR call nc,nnnn set 2,h
213 D5 STR$ push de set 2,l
214 D6 CHR$ sub nn set 2,(hl)
215 D7 NOT rst 10h set 2,a
216 D8 ** ret c set 3,b
217 D9 OR exx set 3,c
218 DA AND jp c,nnnn set 3,d
219 DB <= in a,(nn) set 3,e
220 DC >= call c,nnnn set 3,h
221 DD <> Prefixes IX instructions set 3,l
222 DE THEN sbc a,nn set 3,(hl)
223 DF TO rst 18h set 3,a
224 E0 STEP ret po set 4,b
225 E1 LPRING pop hl set 4,c
226 E2 LLIST jp po,nnnn set 4,d
227 E3 STOP ex (sp),hl set 4,e
228 E4 SLOW call po,nnnn set 4,h
229 E5 FAST push hl set 4,l
230 E6 NEW and nn set 4,(hl)
231 E7 SCROLL rst 20h set 4,a
232 E8 CONT ret pe set 5,b
233 E9 DIM jp (hl) set 5,c
234 EA REM jp pe,nnnn set 5,d
235 EB FOR ex de,hl set 5,e
236 EC GOTO call pe,nnnn set 5,h
237 ED GOSUB Prefixes ED instructions set 5,l
238 EE INPUT xor nn set 5,(hl)
239 EF LOAD rst 28h set 5,a
240 F0 LIST ret p set 6,b
241 F1 LET pop af set 6,c
242 F2 PAUSE jp p,nnnn set 6,d
243 F3 NEXT di set 6,e
244 F4 POKE call p,nnnn set 6,h
245 F5 PRINT push af set 6,l
246 F6 PLOT or nn set 6,(hl)
247 F7 RUN rst 30h set 6,a
248 F8 SAVE ret m set 7,b
249 F9 RAND ld sp,hl set 7,c
250 FA IF jp m,nnnn set 7,d
251 FB CLS ei set 7,e
252 FC UNPLOT call m,nnnn set 7,h
253 FD CLEAR Prefixes IY instructions set 7,l
254 FE RETURN cp nn set 7,(hl)
255 FF COPY rst 38h set 7,a

Hardware

pinouts

UHF

RCAPhono.png

Pin Desc
1 Signal ground
2 UHF video signal

Power connector

Mono jack 3.5mm.png

Pin Desc
1 +9v 1A
2 0v.

Ear

Mono jack 3.5mm.png

Pin Desc
1 Gnd.
2 Audio in


Mic

Mono jack 3.5mm.png

Pin Desc
1 Gnd.
2 Audio out

Expansion connector

2x24WayEdgeConnector.png

Pin Top Bottom
1 D7 +5V
2 /RamCS +9V
Key
4 D0 0v
5 D1 0v
6 D2 Clk
7 D6 A0
8 D5 A1
9 D3 A2
10 D4 A3
11 /Int A15
12 /NMI A14
13 /Halt A13
14 /MReq A12
15 /IORQ A11
16 /RD A10
17 /WR A9
18 /BusAK A8
19 /Wait A7
20 /BusRQ A6
21 /Reset A5
22 /M1 A4
23 /Rfsh /RomCS

Images

Note 1: Note the zx81 schematic was downloaded from from http://www.mainbyte.com/ts1000/good_schematic_hi.jpg It was originally re-worked by Ron Reuter

Note 2: Although i do have an Issue 1 board, i modified it before I took a picture. (16K, keyboard, ect). This image is from Wikipedia.

My projects and modifications

My Memotech zx81

The Memotech keyboard actually has rails in it which fits the zx81 motherboard. This was fitted internally when i got it, along with a soldered on zx81 ram pack mounted beside it. (This was a very long time ago) The regulator was removed and a TO-220 2A reg was mounted on the case instead.

The mods i have made were:

  • Removed the old regulator and fitted a discrete DC-DC converted board mounted on the motherboard.
  • Removed the old 16K ram pack and fitted a 62256 chip to the board.
  • added in a [ZX8-CCB] module to give myself a good composite out.
  • added a flying lead to the reset pin and ground.