aboutsummaryrefslogtreecommitdiff
path: root/src/test/6502.1
blob: 6f15101a1eb20404b9c3c3d442c682d3889717c2 (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
	;option	list-file,list.txt
	option	+list
	option	+list-hex
	option	+list-pc
	option	list-labels,all
	option	list-macros,all

        option  output-file, "6502.bin"
        option  output-format, raw

	;
	; Test basically created by pasting in opcodes from 6502.org
	;
	cpu	6502

	org	$8000

zero:	equ	0

	option	zero-page,off

adc_test
	ADC #$44
	option	+zero-page
	ADC $44
	adc $44,x
	option	-zero-page
	adc $4400
	adc $4400,x
	adc $4400,y
	ADC ($44,X)
	ADC ($44),Y

zp_test
	option	zero-page,auto
	adc	$80	; Always ZP
	adc	$8080	; Always !ZP
	adc	fwd_80	; Always ZP - sure after 2nd pass onwards
	adc	fwd_101	; Initially ZP - sure !ZP after 2nd pass onwards
	option	-zero-page


addr_mode_tests:	; Uncomment to test
	option	+zero-page
	; adc	$4400	; Outside of ZP
	option	-zero-page
	; adc	$4400,z	; Unknown index reg
	; adc	($44,y) ; Wrong indirect reg
	; adc	($44),x ; Wrong indirect reg

        option  zero-page,auto

and_test
	and #$44
	and $44
	and $44,x
	and $4400
	and $4400,x
	and $4400,y
	and ($44,x)
	and ($44),y

asl_test
	ASL A
	ASL $44
	ASL $44,X
	ASL $4400
	ASL $4400,X

bit_test
	BIT $44
	BIT $4400

branch_test
	BPL branch_test
	BMI branch_test
	BVC branch_test
	BVS branch_test
	BCC branch_test
	BCS branch_test
	BNE branch_test
	BEQ branch_test

	BPL brk_test
	BMI brk_test
	BVC brk_test
	BVS brk_test
	BCC brk_test
	BCS brk_test
	BNE brk_test
	BEQ brk_test

	; BEQ zero		; Would generate an error/warning
	; BEQ $f000		; Would generate an error/warning

brk_test
    	BRK

cmp_test
.acc
	CMP #$44
	CMP $44
	CMP $44,X
	CMP $4400
	CMP $4400,X
	CMP $4400,Y
	CMP ($44,X)
	CMP ($44),Y

.xreg
	CPX #$44
	CPX $44
	CPX $4400

 
.yreg
	CPY #$44
	CPY $44
	CPY $4400

dec_test
	DEC $44
	DEC $44,X
	DEC $4400
	DEC $4400,X

 

eor_test
	EOR #$44
	EOR $44
	EOR $44,X
	EOR $4400
	EOR $4400,X
	EOR $4400,Y
	EOR ($44,X)
	EOR ($44),Y

flag_test
	CLC
	SEC
	CLI
	SEI
	CLV
	CLD
	SED

inc_test
	INC $44
	INC $44,X
	INC $4400
	INC $4400,X
 

jmp_test
	JMP $5597
	JMP ($5597)

jsr_test
	JSR $5597

ld_test
.acc
	LDA #$44
	LDA $44
	LDA $44,X
	LDA $4400
	LDA $4400,X
	LDA $4400,Y
	LDA ($44,X)
	LDA ($44),Y

.xreg
	LDX #$44
	LDX $44
	LDX $44,Y
	LDX $4400
	LDX $4400,Y

.yreg
	LDY #$44
	LDY $44
	LDY $44,X
	LDY $4400
	LDY $4400,X

lst_test

	LSR A
	LSR $44
	LSR $44,X
	LSR $4400
	LSR $4400,X

nop_test

	NOP

ora_test
	ORA #$44
	ORA $44
	ORA $44,X
	ORA $4400
	ORA $4400,X
	ORA $4400,Y
	ORA ($44,X)
	ORA ($44),Y

xfer_test
	TAX
	TXA
	DEX
	INX
	TAY
	TYA
	DEY
	INY
 

rol_test
	ROL A
	ROL $44
	ROL $44,X
	ROL $4400
	ROL $4400,X

rot_test
	ROR A
	ROR $44
	ROR $44,X
	ROR $4400
	ROR $4400,X

ret_test
	RTI
	rts

sbc_test
	SBC #$44
	SBC $44
	SBC $44,X
	SBC $4400
	SBC $4400,X
	SBC $4400,Y
	SBC ($44,X)
	SBC ($44),Y

store_test
.acc
	STA $44
	STA $44,X
	STA $4400
	STA $4400,X
	STA $4400,Y
	STA ($44,X)
	STA ($44),Y

.xreg
	STX $44
	STX $44,Y
	STX $4400
 
.yreg
	STY $44
	STY $44,X
	STY $4400

stack_test
	TXS
	TSX
	PHA
	PLA
	PHP
	PLP

fwd_80:	equ	$80
fwd_101	equ	$101

; Illegal opcodes
        JAM
        ALR     #$44
        ANC     #$44
        ANC2    #$44
        ANE     #$44
        ARR     #$44
        DCP     $44
        DCP     $44,X
        DCP     $4400
        DCP     $4400,X
        DCP     $4400,Y
        DCP     ($44,X)
        DCP     ($44),Y
        ISC     $44
        ISC     $44,X
        ISC     $4400
        ISC     $4400,X
        ISC     $4400,Y
        ISC     ($44,X)
        ISC     ($44),Y
        LAS     $4400,Y
        LAX     $44
        LAX     $44,Y
        LAX     $4400
        LAX     $4400,Y
        LAX     ($44,X)
        LAX     ($44),Y
        LXA     #$44
        RLA     $44
        RLA     $44,X
        RLA     $4400
        RLA     $4400,X
        RLA     $4400,Y
        RLA     ($44,X)
        RLA     ($44),Y
        RRA     $44
        RRA     $44,X
        RRA     $4400
        RRA     $4400,X
        RRA     $4400,Y
        RRA     ($44,X)
        RRA     ($44),Y
        SAX     $44
        SAX     $44,Y
        SAX     $4400
        SAX     ($44,X)
        SBX     #$44
        SHA     $4400,Y
        SHA     ($44),Y
        SHX     $4400,Y
        SHY     $4400,X
        SLO     $44
        SLO     $44,X
        SLO     $4400
        SLO     $4400,X
        SLO     $4400,Y
        SLO     ($44,X)
        SLO     ($44),Y
        SRE     $44
        SRE     $44,X
        SRE     $4400
        SRE     $4400,X
        SRE     $4400,Y
        SRE     ($44,X)
        SRE     ($44),Y
        TAS     $4400,Y
        USBC    #$44