aboutsummaryrefslogtreecommitdiff
path: root/src/test/z80.1
blob: 732d1cb024d9e64788ddc993922e6cd566d9b2b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
	option	-list
	option	+list-hex
	option	+list-pc
	option	list-macros,off
	option	list-labels,off

	;output	file,a.tap
	;output	format,spectrum

	cpu	z80

	org	$8000

	;
	; Simple comments
	;

ld8test:macro reg
	LD @reg,A	; Comment?
	LD @reg,B
	LD @reg,C
	LD @reg,D
	LD @reg,E
	LD @reg,H
	LD @reg,L
.test
	LD @reg,(HL)
	LD @reg,(IX+127)
	LD @reg,(IY-128)
	LD (hl),@reg
	LD (IX+127),@reg
	LD (IY-128),@reg
	ld @reg,$e5
	ld @reg,ixh
	ld @reg,ixl
	ld @reg,iyh
	ld @reg,iyl
	endm

ld8test_undoc:macro
	LD \1,A	; Comment?
	LD \1,B
	LD \1,C
	LD \1,D
	LD \1,E
	LD \1,\1
	LD \1,\1
	ld \1,$e5
	endm

ld_tests:
.value
	ld (hl),$e5
	ld (ix+127),$e5
	ld (iy-128),$e5
.a
	ld8test a
	LD a,(BC)
	LD a,(DE)
	LD a,(word)
	ld a,i
	ld a,r
	ld r,a
	ld i,a

.b
	ld8test b
.c
	ld8test c
.d
	ld8test d
.e
	ld8test e
.h
	ld8test h
.l
	ld8test l
.ixl
	ld8test_undoc ixl
.ixh
	ld8test_undoc ixh
.iyl
	ld8test_undoc iyl
.iyh
	ld8test_undoc iyh

.bit16
	ld	bc,word
	ld	de,word
	ld	hl,word
	ld	sp,word
	ld	ix,word
	ld	iy,word

	ld	bc,(word)
	ld	de,(word)
	ld	hl,(word)
	ld	sp,(word)
	ld	ix,(word)
	ld	iy,(word)

alu:	macro
	\1	a,a
	\1	a
	\1	a,b
	\1	b
	\1	a,c
	\1	a,d
	\1	a,e
	\1	a,h
	\1	a,l
	\1	a,ixh
	\1	a,ixl
	\1	a,iyh
	\1	a,iyl
	\1	a,(hl)
	\1	a,(ix+100)
	\1	a,(iy-100)
	endm

alutest:
	alu	add
	alu	adc
	alu	sub
	alu	sbc
	alu	and
	alu	or
	alu	xor
	alu	eor
	alu	cp

	inc	a
	inc	b
	inc	c
	inc	d
	inc	e
	inc	h
	inc	l
	inc	ixh
	inc	ixl
	inc	iyh
	inc	iyl
	inc	(hl)
	inc	(ix-64)
	inc	(iy+64)
	inc	bc
	inc	de
	inc	hl
	inc	sp
	inc	ix
	inc	iy

	dec	a
	dec	b
	dec	c
	dec	d
	dec	e
	dec	h
	dec	l
	dec	ixh
	dec	ixl
	dec	iyh
	dec	iyl
	dec	(hl)
	dec	(ix-64)
	dec	(iy+64)
	dec	bc
	dec	de
	dec	hl
	dec	sp
	dec	ix
	dec	iy

	im	0
	im	1
	im	2

alu16:
	add	hl,bc
	add	hl,de
	add	hl,hl
	add	hl,sp

	add	ix,bc
	add	ix,de
	add	ix,ix
	add	ix,sp

	add	iy,bc
	add	iy,de
	add	iy,iy
	add	iy,sp

	adc	hl,bc
	adc	hl,de
	adc	hl,hl
	adc	hl,sp

	sbc	hl,bc
	sbc	hl,de
	sbc	hl,hl
	sbc	hl,sp

stack:
	push	af
	push	bc
	push	de
	push	hl
	push	ix
	push	iy
	pop	af
	pop	bc
	pop	de
	pop	hl
	pop	ix
	pop	iy

exchange:
	ex	de,hl
	ex	af,af'
	ex	(sp),hl
	ex	(sp),ix
	ex	(sp),iy
	ex	hl,de
	ex	af',af
	ex	hl,(sp)
	ex	ix,(sp)
	ex	iy,(sp)
	ldi
	ldir
	ldd
	lddr
	cpi
	cpir
	cpdr

bitm:	macro
	\1	a
	\1	b
	\1	c
	\1	d
	\1	e
	\1	h
	\1	l
	\1	(hl)
	\1	(ix+1)
	\1	(iy-1)
	\1	(ix+1),a
	\1	(iy-1),a
	\1	(ix+1),b
	\1	(iy-1),b
	\1	(ix+1),c
	\1	(iy-1),c
	\1	(ix+1),d
	\1	(iy-1),d
	\1	(ix+1),e
	\1	(iy-1),e
	\1	(ix+1),h
	\1	(iy-1),h
	\1	(ix+1),l
	\1	(iy-1),l
	endm

set_res:macro
	\1	0,a
	\1	1,b
	\1	2,c
	\1	3,d
	\1	4,e
	\1	5,h
	\1	6,l
	\1	7, (hl)
	\1	0, (ix+1)
	\1	0, (iy-1)
	\1	1, (ix+1),a
	\1	1, (iy-1),a
	\1	2, (ix+1),b
	\1	2, (iy-1),b
	\1	3, (ix+1),c
	\1	3, (iy-1),c
	\1	4, (ix+1),d
	\1	4, (iy-1),d
	\1	5, (ix+1),e
	\1	5, (iy-1),e
	\1	6, (ix+1),h
	\1	6, (iy-1),h
	\1	7, (ix+1),l
	\1	7, (iy-1),l
	endm

bits:
	RLCA
	RRCA
	RLA
	RRA

	bitm	rlc
	bitm	rl
	bitm	rrc
	bitm	rr
	bitm	sla
	bitm	SRA
	bitm	srl
	bitm	sll

	set_res	set
	set_res	res

	bit	0,a
	bit	1,b
	bit	2,c
	bit	3,d
	bit	4,e
	bit	5,h
	bit	6,l
	bit	7, (hl)
	bit	0, (ix+1)
	bit	0, (iy-1)

jtest:	macro
	\1	endjmp
	\1	nz,endjmp
	\1	z,endjmp
	\1	nc,endjmp
	\1	c,endjmp
	\1	po,endjmp
	\1	pe,endjmp
	\1	p,endjmp
	\1	m,endjmp
.endjmp
	endm

jump:
	jtest	jp
	jtest	call

	jp	(hl)
	jp	(ix)
	jp	(iy)

.jrjump1
	jr	jrjump1
	jr	nz,jrjump1
	jr	z,jrjump1
	jr	nc,jrjump1
	jr	c,jrjump1
	djnz	jrjump1

	jr	jrjump2
	jr	nz,jrjump2
	jr	z,jrjump2
	jr	nc,jrjump2
	jr	c,jrjump2
	djnz	jrjump2
.jrjump2
	call	0

	ret
	ret	nz
	ret	z
	ret	nc
	ret	c
	ret	po
	ret	pe
	ret	p
	ret	m
	reti
	retn

	rst	0
	rst	0h
	rst	8
	rst	8h
	rst	10
	rst	10h
	rst	18
	rst	18h
	rst	20
	rst	20h
	rst	28
	rst	28h
	rst	30
	rst	30h
	rst	38
	rst	38h


io:
	in	(c)
	in	a,(255)
	in	a,(c)
	in	b,(c)
	in	c,(c)
	in	d,(c)
	in	e,(c)
	in	h,(c)
	in	l,(c)
	in	f,(c)
	ini
	inir
	ind
	indr

	out	(c),0
	out	(255),a
	out	(c),a
	out	(c),b
	out	(c),c
	out	(c),d
	out	(c),e
	out	(c),h
	out	(c),l
	out	(c),f
	out	(c),255
	out	(c),123456789
	outi
	otir
	outd
	otdr

implied:
	NOP
	DI
	EI
	HALT
	HLT
	EXX
	DAA
	CPL
	SCF
	CCF
	NEG
	CPI
	CPIR
	CPD
	CPDR
	INI
	INIR
	IND
	INDR
	OUTI
	OTIR
	OUTD
	OTDR
	LDI
	LDIR
	LDD
	LDDR

word:	defs	2

string:	db	"Hello World",0