OpenCores
URL https://opencores.org/ocsvn/rtf65002/rtf65002/trunk

Subversion Repositories rtf65002

[/] [rtf65002/] [trunk/] [software/] [asm/] [t65C.asm] - Blame information for rev 36

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 robfinch
;==================================================================
2
; (C) 2003  Bird Computer
3
; All rights reserved.
4
;
5
; W65C02 Processor Test Routine
6
;
7
;       The basic format is to test the things needed for further
8
; testing first, like branches and compare, then move onto other
9
; instructions.
10
;==================================================================
11
 
12
UART                    equ             $CF00
13
XMIT_FUL                equ             $08             ; the transmit buffer is full
14
data_ptr                equ             $08
15
dpf                             equ             $AA
16
 
17
        org $0FFFFE000
18
        cpu             rtf65002
19
 
20
; If the program gets here then we know at least the boot strap
21
; worked okay, which is in itself a good test of processor health.
22
start
23
        sei
24
        cld             ; set decimal mode flag to zero
25
        ldx             #$1000
26
        txs
27
        trs             r0,dp           ; set zero page location
28
        emm             ; emulation mode
29
        cpu             W65C02
30
        sei
31
        ldx             #$FF
32
        txs
33
        jsr             putmsg
34
        db              "C02 Testing Processor", 13, 10, 0
35
 
36
 
37
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
38
; First thing to test is branches. If you can't branch reliably
39
; then the validity of the remaining tests are in question.
40
; Test branches and also simultaneously some other simple
41
; instructions.
42
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
43
 
44
        sei
45
 
46
        bra             braok
47
        jsr             putmsg
48
        db              "BRA:F", 13, 10, 0
49
 
50
braok
51
 
52
        sec
53
        bcs             bcsok
54
        jsr             putmsg
55
        db              "BCS:F", 13, 10, 0
56
bcsok
57
        clc
58
        bcc             bccok
59
        jsr             putmsg
60
        db              "BCC:F", 13, 10, 0
61
bccok
62
        lda             #$00
63
        beq             beqok
64
        jsr             putmsg
65
        db              "BEQ:F", 13, 10, 0
66
beqok
67
        lda             #$80
68
        bne             bneok
69
        jsr             putmsg
70
        db              "BNE:F", 13, 10, 0
71
bneok
72
        ora             #$00
73
        bmi             bmiok
74
        jsr             putmsg
75
        db              "BMI:F", 13, 10, 0
76
bmiok
77
        eor             #$80
78
        bpl             bplok
79
        jsr             putmsg
80
        db              "BPL:F", 13, 10, 0
81
bplok
82
        lda             #$7f
83
        clc
84
        adc             #$10            ; should give signed overflow
85
        bvs             bvsok
86
        jsr             putmsg
87
        db              "BVS:F", 13, 10, 0
88
bvsok
89
        clv
90
        bvc             bvcok
91
        jsr             putmsg
92
        db              "BVC:F", 13, 10, 0
93
bvcok
94
 
95
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
96
; Compare Instructions
97
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
98
 
99
        jsr             putmsg
100
        db              "test cmp/cpx/cpy", 13, 10, 0
101
 
102
        lda             #27                     ; bit 7 = 0
103
        clc
104
        cmp             #27
105
        bcc             cmperr
106
        bne             cmperr
107
        bmi             cmperr
108
        lda             #$A1
109
        cmp             #20
110
        bpl             cmperr          ; should be neg.
111
        sec
112
        lda             #10
113
        cmp             #20                     ; should be a borrow here
114
        bcs             cmperr
115
        clv
116
        lda             #$80            ; -128 - 32 = -160 should overflow
117
        cmp             #$20            ; compare doesn't affect overflow
118
        bvs             cmperr
119
        bvc             cmpok
120
 
121
cmperr
122
        jsr             putmsg
123
        db              "CMP:F", 13, 10, 0
124
 
125
cmpok
126
        ldx             #27
127
        clc
128
        cpx             #27
129
        bcc             cpxerr
130
        bne             cpxerr
131
        bmi             cpxerr
132
        ldx             #$A1
133
        cpx             #20
134
        bpl             cpxerr
135
        ldx             #10
136
        cpx             #20                     ; should be a borrow here
137
        bcs             cpxerr
138
        clv
139
        ldx             #$80            ; -128 - 32 = -160 should overflow
140
        cpx             #$20            ; but cpx shouldn't change overflow
141
        bvs             cpxerr
142
        bvc             cpxok
143
 
144
cpxerr
145
        jsr             putmsg
146
        db              "CPX:F", 13, 10, 0
147
 
148
cpxok
149
        ldy             #27
150
        clc
151
        cpy             #27
152
        bcc             cpyerr
153
        bne             cpyerr
154
        bmi             cpyerr
155
        ldy             #$B0
156
        cpy             #20
157
        bpl             cpyerr
158
        ldy             #10
159
        cpy             #20                     ; should be a borrow here
160
        bcs             cpyerr
161
        clv
162
        ldy             #$80            ; -128 - 32 = -160 should overflow
163
        cpy             #$20            ; but cpy shouldn't change overflow
164
        bvs             cpyerr
165
        bvc             cpyok
166
 
167
cpyerr
168
        jsr             putmsg
169
        db              "CPY:F", 13, 10, 0
170
 
171
cpyok
172
 
173
 
174
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
175
; Accumulator ops
176
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
177
 
178
        jsr             putmsg
179
        db              "Test Acc ops", 13, 10, 0
180
 
181
        clv
182
        clc
183
        lda             #0
184
        ora             #0
185
        bne             oraerr
186
        bvs             oraerr
187
        bmi             oraerr
188
        bcs             oraerr
189
        sec
190
        ora             #0
191
        bcc             oraerr
192
        ora             #$55
193
        beq             oraerr
194
        cmp             #$55
195
        bne             oraerr
196
        ora             #$aa
197
        cmp             #$ff
198
        bne             oraerr
199
        beq             oraok
200
 
201
oraerr
202
        jsr             putmsg
203
        db              "ORA:F", 13, 10, 0
204
 
205
oraok
206
 
207
        lda             #27                     ; bit 7 = 0
208
        sec
209
        sbc             #27
210
        bcc             sbcerr1
211
        bne             sbcerr3
212
        bmi             sbcerr2
213
        bvs             sbcerr4
214
        lda             #$A1
215
        sbc             #$20
216
        bpl             sbcerr2         ; should be neg.
217
        cmp             #$81
218
        bne             sbcerr3
219
        sec
220
        lda             #10
221
        sbc             #20                     ; should be a borrow here
222
        bcs             sbcerr1
223
        clv
224
        lda             #$80            ; -128 - 32 = -160 should overflow
225
        sbc             #$20            ;
226
        bvc             sbcerr4
227
        bvs             sbcok
228
 
229
sbcerr
230
        jsr             putmsg
231
        db              "SBC:F", 13, 10, 0
232
        jmp             sbcok
233
 
234
sbcerr1
235
        jsr             putmsg
236
        db              "SBC:C", 13, 10, 0
237
        jmp             sbcok
238
 
239
sbcerr2
240
        jsr             putmsg
241
        db              "SBC2:N", 13, 10, 0
242
        jmp             sbcok
243
 
244
sbcerr3
245
        jsr             putmsg
246
        db              "SBC3:Z", 13, 10, 0
247
        jmp             sbcok
248
 
249
sbcerr4
250
        jsr             putmsg
251
        db              "SBC:V", 13, 10, 0
252
        jmp             sbcok
253
 
254
sbcok
255
 
256
 
257
; bit
258
 
259
        clv
260
        lda             #$ff
261
        bit             n55
262
        bvc             biterr
263
        bmi             biterr
264
        bit             nAA
265
        bvs             biterr
266
        bpl             biterr
267
        lda             #$00
268
        sta             data_ptr
269
        lda             #$ff
270
        bit             data_ptr
271
        bne             biterr
272
        beq             bitok
273
 
274
biterr
275
        jsr             putmsg
276
        db              "BIT:F", 13, 10, 0
277
 
278
bitok
279
 
280
        lda             #$ff
281
        pha
282
        plp
283
        bpl     plperr
284
        bvc             plperr
285
        bne             plperr
286
        bcc             plperr
287
        bcs             plpok
288
 
289
plperr
290
        jsr             putmsg
291
        db              "PLP:F", 13, 10, 0
292
 
293
plpok
294
 
295
        cld
296
        clc
297
        clv
298
        sei
299
        lda             #$00    ; p = 00xx0100
300
        php
301
        pla
302
        ror             a               ; C ?
303
        jsr             psr
304
        ror             a               ; Z ?
305
        jsr             psr
306
        ror             a
307
        jsr             psr
308
        ror             a
309
        jsr             psr
310
        ror             a               ; B?
311
        jsr             psr
312
        ror             a               ; x?
313
        jsr             psr
314
        ror             a
315
        jsr             psr
316
        ror             a
317
        jsr             psr
318
        jmp             phpok
319
 
320
psr
321
        pha
322
        bcc             psr1
323
        jsr             putmsg
324
        db              "1", 0
325
        pla
326
        rts
327
psr1
328
        jsr             putmsg
329
        db              "0", 0
330
        pla
331
        rts
332
 
333
phperr
334
        jsr             putmsg
335
        db              "PHP:F", 13, 10, 0
336
        jmp     phpok
337
 
338
phperr1
339
        jsr             putmsg
340
        db              "PHP:1F", 13, 10, 0
341
        jmp     phpok
342
phperr2
343
        jsr             putmsg
344
        db              "PHP:2F", 13, 10, 0
345
        jmp     phpok
346
phperr3
347
        jsr             putmsg
348
        db              "PHP:3F", 13, 10, 0
349
        jmp     phpok
350
phperr4
351
        jsr             putmsg
352
        db              "PHP:4F", 13, 10, 0
353
        jmp     phpok
354
phperr5
355
        jsr             putmsg
356
        db              "PHP:5F", 13, 10, 0
357
        jmp     phpok
358
phperr6
359
        jsr             putmsg
360
        db              "PHP:6F", 13, 10, 0
361
        jmp     phpok
362
 
363
phpok
364
 
365
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
366
; Load
367
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
368
 
369
        jsr             putmsg
370
        db              "Test lda/ldx/ldy", 13, 10, 0
371
 
372
; lda
373
 
374
        clc
375
        lda             #0
376
        bne             ldaerr
377
        bmi             ldaerr
378
        bcs             ldaerr
379
        lda             #$80
380
        beq             ldaerr
381
        bpl             ldaerr
382
 
383
        lda             #$00
384
        sta             $800
385
        bne             ldaerr
386
        bmi             ldaerr
387
        bcs             ldaerr
388
 
389
        lda             #$ff
390
        lda             $800
391
        bne             ldaerr
392
        bmi             ldaerr
393
        bcs             ldaerr
394
 
395
        cmp             #0
396
        bne             ldaerr
397
 
398
        sec
399
        lda             #$ff
400
        sta             $800
401
        beq             ldaerr
402
        bpl             ldaerr
403
        bcc             ldaerr
404
 
405
        lda             #0
406
        lda             $800
407
        beq             ldaerr
408
        bpl             ldaerr
409
        bcc             ldaerr
410
 
411
        cmp             #$ff
412
        beq             ldaok
413
 
414
ldaerr
415
        jsr             putmsg
416
        db              "LDA:F", 13, 10, 0
417
 
418
ldaok
419
 
420
 
421
; ldx
422
 
423
        clc
424
        lda             #$80            ; z = 0, n = 1
425
        ldx             #0
426
        bcs             ldxerr
427
        bne             ldxerr
428
        bmi             ldxerr
429
 
430
        stx             $800
431
        bne             ldxerr
432
        bmi             ldxerr
433
        bcs             ldxerr
434
 
435
        ldx             #$ff
436
        ldx             $800
437
        bne             ldxerr
438
        bmi             ldxerr
439
        bcs             ldxerr
440
 
441
        cpx             #0
442
        bne             ldxerr
443
 
444
        sec
445
        ldx             #$ff
446
        stx             $800
447
        beq             ldxerr
448
        bpl             ldxerr
449
        bcc             ldxerr
450
 
451
        ldx             #0
452
        ldx             $800
453
        beq             ldxerr
454
        bpl             ldxerr
455
        bcc             ldxerr
456
 
457
        cpx             #$ff
458
        beq             ldxok
459
 
460
ldxerr
461
        jsr             putmsg
462
        db              "LDX:F", 13, 10, 0
463
 
464
 
465
; ldy
466
 
467
ldxok
468
        clc
469
        lda             #$80            ; z = 0, n = 1
470
        ldy             #0
471
        bcs             ldyerr
472
        bne             ldyerr
473
        bmi             ldyerr
474
 
475
        sty             $800
476
        bne             ldyerr
477
        bmi             ldyerr
478
        bcs             ldyerr
479
 
480
        ldy             #$ff
481
        ldy             $800
482
        bne             ldyerr
483
        bmi             ldyerr
484
        bcs             ldyerr
485
 
486
        cpy             #0
487
        bne             ldyerr
488
 
489
        sec
490
        ldy             #$ff
491
        sty             $800
492
        beq             ldyerr
493
        bpl             ldyerr
494
        bcc             ldyerr
495
 
496
        ldy             #0
497
        ldy             $800
498
        beq             ldyerr
499
        bpl             ldyerr
500
        bcc             ldyerr
501
 
502
        cpy             #$ff
503
        beq             ldyok
504
 
505
ldyerr
506
        jsr             putmsg
507
        db              "LDY:F", 13, 10, 0
508
 
509
ldyok
510
 
511
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
512
; Test register transfers
513
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
514
 
515
        jsr             putmsg
516
        db              "Test tax/tay/txa/tya/tsx/txs", 13, 10, 0
517
 
518
; tax
519
 
520
        clc
521
        lda             #0
522
        ldx             #$80                    ; z = 0, n = 1
523
        tax
524
        bcs             taxerr
525
        bmi             taxerr
526
        bne             taxerr
527
 
528
        txa
529
        bne             taxerr
530
 
531
        lda             #$ff
532
        sec
533
        ldx             #0
534
        tax
535
        bcc             taxerr
536
        bpl             taxerr
537
        beq             taxerr
538
 
539
        txa
540
        cmp             #$ff
541
        beq             taxok
542
 
543
taxerr
544
        jsr             putmsg
545
        db              "TAX:F", 13, 10, 0
546
taxok
547
 
548
; tay
549
 
550
        clc
551
        lda             #0
552
        ldy             #$80                    ; z = 0, n = 1
553
        tay
554
        bcs             tayerr
555
        bmi             tayerr
556
        bne             tayerr
557
 
558
        tya
559
        bne             tayerr
560
 
561
        lda             #$ff
562
        sec
563
        ldy             #0
564
        tay
565
        bcc             tayerr
566
        bpl             tayerr
567
        beq             tayerr
568
 
569
        tya
570
        cmp             #$ff
571
        beq             tayok
572
 
573
tayerr
574
        jsr             putmsg
575
        db              "TAY:F", 13, 10, 0
576
tayok
577
 
578
 
579
; txs
580
 
581
        ldx             #15
582
        txs
583
        ldx             #87
584
        tsx
585
        cpx             #15
586
        beq             txsok
587
        ldx             #$ff
588
        txs
589
        jsr             putmsg
590
        db              "TSX:F", 13, 10, 0
591
txsok
592
        ldx             #87
593
        txa
594
        cmp             #87
595
        beq             txaok
596
        jsr             putmsg
597
        db              "TXA:F", 13, 10, 0
598
txaok
599
        tay
600
        cpy             #87
601
        beq             tayok1
602
        jsr             putmsg
603
        db              "TAY:F", 13, 10, 0
604
tayok1
605
        tya
606
        beq             tyaerr
607
        bmi             tyaerr
608
        cmp             #87
609
        beq             tyaok
610
tyaerr
611
        jsr             putmsg
612
        db              "TYA:F", 13, 10, 0
613
tyaok
614
 
615
 
616
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
617
; Increment / Decrement
618
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
619
 
620
        jsr             putmsg
621
        db              "Test inx/dex/iny/dey/ina/dea/inc/dec", 13, 10, 0
622
 
623
        ldx             #$FE
624
        clc
625
        lda             #0
626
        inx
627
        bcs             inxerr
628
        beq             inxerr
629
        bpl             inxerr
630
 
631
        cpx             #$ff
632
        bne             inxerr
633
 
634
        sec
635
        lda             #$80
636
        inx
637
        bcc             inxerr
638
        bne             inxerr
639
        bmi             inxerr
640
 
641
        cpx             #0
642
        bne             inxerr
643
 
644
        clc
645
inxl1                           ; test loop
646
        inx
647
        bcs             inxerr
648
        bne             inxl1
649
 
650
        sec
651
inxl2
652
        inx
653
        bcc             inxerr
654
        bne             inxl2
655
 
656
        beq             inxok
657
 
658
inxerr
659
        jsr             putmsg
660
        db              "INX:F", 13, 10, 0
661
 
662
inxok
663
 
664
;       dex
665
 
666
        ldx             #2
667
        clc
668
        lda             #0
669
        dex
670
        bcs             dexerr
671
        beq             dexerr
672
        bmi             dexerr
673
 
674
        cpx             #1
675
        bne             dexerr
676
 
677
        sec
678
        lda             #$80
679
        dex
680
        bcc             dexerr
681
        bne             dexerr
682
        bmi             dexerr
683
 
684
        cpx             #0
685
        bne             dexerr
686
 
687
        lda             #0
688
        dex
689
        beq             dexerr
690
        bpl             dexerr
691
 
692
        cpx             #$ff
693
        bne             dexerr
694
 
695
        clc
696
dexl1
697
        dex
698
        bcs             dexerr
699
        bne             dexl1
700
 
701
        sec
702
dexl2
703
        dex
704
        bcc             dexerr
705
        bne             dexl2
706
 
707
        beq             dexok
708
 
709
dexerr
710
        jsr             putmsg
711
        db              "DEX:F", 13, 10, 0
712
 
713
dexok
714
 
715
; iny
716
 
717
        ldy             #$FE
718
        clc
719
        adc             #0
720
        iny
721
        bcs             inyerr
722
        beq             inyerr
723
        bpl             inyerr
724
 
725
        cpy             #$ff
726
        bne             inyerr
727
 
728
        sec
729
        lda             #$80
730
        iny
731
        bcc             inyerr
732
        bne             inyerr
733
        bmi             inyerr
734
 
735
        cpy             #0
736
        bne             inyerr
737
 
738
        clc
739
inyl1                           ; test loop
740
        iny
741
        bcs             inyerr
742
        bne             inyl1
743
 
744
        sec
745
inyl2
746
        iny
747
        bcc             inyerr
748
        bne             inyl2
749
 
750
        beq             inyok
751
 
752
inyerr
753
        jsr             putmsg
754
        db              "INY:F", 13, 10, 0
755
 
756
 
757
;       dey
758
 
759
inyok
760
 
761
        ldy             #2
762
        clc
763
        lda             #0
764
        dey
765
        bcs             deyerr
766
        beq             deyerr
767
        bmi             deyerr
768
 
769
        cpy             #1
770
        bne             deyerr
771
 
772
        sec
773
        lda             #$80
774
        dey
775
        bcc             deyerr
776
        bne             deyerr
777
        bmi             deyerr
778
 
779
        cpy             #0
780
        bne             deyerr
781
 
782
        lda             #0
783
        dey
784
        beq             deyerr
785
        bpl             deyerr
786
 
787
        cpy             #$ff
788
        bne             deyerr
789
 
790
        clc
791
deyl1
792
        dey
793
        bcs             deyerr
794
        bne             deyl1
795
 
796
        sec
797
deyl2
798
        dey
799
        bcc             deyerr
800
        bne             deyl2
801
 
802
        beq             deyok
803
 
804
deyerr
805
        jsr             putmsg
806
        db              "DEY:F", 13, 10, 0
807
 
808
deyok
809
 
810
 
811
        lda             #1
812
        ina
813
        cmp             #2
814
        beq             inaok
815
 
816
        jsr             putmsg
817
        db              "INA:F", 13, 10, 0
818
 
819
inaok
820
 
821
        lda             #2
822
        dea
823
        cmp             #1
824
        beq             deaok
825
 
826
        jsr             putmsg
827
        db              "DEA:F", 13, 10, 0
828
 
829
deaok
830
 
831
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
832
; Stores
833
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
834
 
835
        jsr             putmsg
836
        db              "Test sta/stx/sty/stz", 13, 10, 0
837
 
838
; sta
839
 
840
        lda             #0
841
        clc
842
        sta             $00
843
        bne             staerr
844
        bmi             staerr
845
        bcs             staerr
846
 
847
        lda             $00
848
        bne             staerr
849
 
850
        lda             #$ff
851
        sec
852
        sta             $00
853
        beq             staerr
854
        bpl             staerr
855
        bcc             staerr
856
        bcs             staok
857
 
858
staerr
859
        jsr             putmsg
860
        db              "STA:F", 13, 10, 0
861
staok
862
 
863
; stx
864
 
865
        ldx             #0
866
        clc
867
        stx             $00
868
        bne             stxerr
869
        bmi             stxerr
870
        bcs             stxerr
871
 
872
        ldx             $00
873
        bne             stxerr
874
 
875
        ldx             #$ff
876
        sec
877
        stx             $00
878
        beq             stxerr
879
        bpl             stxerr
880
        bcc             stxerr
881
        bcs             stxok
882
 
883
stxerr
884
        jsr             putmsg
885
        db              "STX:F", 13, 10, 0
886
stxok
887
 
888
; sty
889
 
890
        ldy             #0
891
        clc
892
        sty             $00
893
        bne             styerr
894
        bmi             styerr
895
        bcs             styerr
896
 
897
        ldy             $00
898
        bne             styerr
899
 
900
        ldy             #$ff
901
        sec
902
        sty             $00
903
        beq             styerr
904
        bpl             styerr
905
        bcc             styerr
906
        bcs             styok
907
 
908
styerr
909
        jsr             putmsg
910
        db              "STY:F", 13, 10, 0
911
styok
912
 
913
; stz
914
 
915
        lda             #$ff
916
        sta             data_ptr
917
        stz             data_ptr
918
        lda             data_ptr
919
        beq             stzok
920
 
921
        jsr             putmsg
922
        db              "STZ:F", 13, 10, 0
923
 
924
stzok
925
 
926
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
927
; Test addressing mode
928
;       Note that addressing modes are handled independently of the
929
; actual operation performed by the processor. This means that
930
; if a mode works with one instruction, it should work properly
931
; with all instructions that use that mode.
932
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
933
 
934
        jsr             putmsg
935
        db              "Test amodes", 13, 10, 0
936
 
937
        lda             #$AA
938
        eor             #$55
939
        cmp             #$ff
940
        beq             imm_ok
941
        jsr             putmsg
942
        db              "IMM:F", 13, 10, 0
943
imm_ok
944
        lda             n55
945
        eor             nAA
946
        clc
947
        adc             #1
948
        beq             abs_ok
949
        jsr             putmsg
950
        db              "ABS:F", 13, 10, 0
951
abs_ok
952
        ldx             #2
953
        lda             n55,x
954
        cmp             #12
955
        beq             absx_ok
956
        jsr             putmsg
957
        db              "ABS,X:F", 13, 10, 0
958
absx_ok
959
        ldy             #3
960
        lda             n55,y
961
        cmp             #34
962
        beq             absy_ok
963
        jsr             putmsg
964
        db              "ABS,Y:F", 13, 10, 0
965
absy_ok
966
        lda             #33
967
        sta             data_ptr
968
        ldx             #0
969
        ldx             data_ptr
970
        cpx             #33
971
        beq             zp_ok
972
        jsr             putmsg
973
        db              "ZP:F", 13, 10, 0
974
zp_ok
975
        lda             #44
976
        sta             data_ptr+33
977
        lda             data_ptr,x
978
        cmp             #44
979
        beq             zpx_ok
980
        jsr             putmsg
981
        db              "ZP,X:F", 13, 10, 0
982
zpx_ok
983
        lda             #$12
984
        sta             $201
985
        lda             #$01
986
        sta             data_ptr
987
        lda             #$2
988
        sta             data_ptr+1
989
        ldx             #5
990
        lda             (data_ptr-5,x)
991
        cmp             #$12
992
        bne             zpixerr
993
        lda             #$33
994
        sta             (data_ptr-5,x)
995
        lda             #$00
996
        lda             $201
997
        cmp             #$33
998
        bne             zpixerr
999
        beq             zpixok
1000
zpixerr
1001
        jsr             putmsg
1002
        db              "(ZP,X):F", 13, 10, 0
1003
zpixok
1004
        lda             #$fe
1005
        sta             data_ptr
1006
        lda             #$01
1007
        sta             data_ptr+1
1008
        ldy             #3
1009
        lda             (data_ptr),y
1010
        cmp             #$33
1011
        beq             zpiy_ok
1012
        jsr             putmsg
1013
        db              "(ZP),y:F", 13, 10, 0
1014
zpiy_ok
1015
        ldy             #7
1016
        ldx             data_ptr-7,y
1017
        cpx             #$fe
1018
        beq             zpy_ok
1019
        jsr             putmsg
1020
        db              "ZP,Y:F", 13, 10, 0
1021
zpy_ok
1022
 
1023
        ; test (zp)
1024
 
1025
        lda             #$34
1026
        sta             $201
1027
        lda             #$01
1028
        sta             data_ptr
1029
        lda             #$02
1030
        sta             data_ptr+1
1031
        lda             (data_ptr)
1032
        cmp             #$34
1033
        beq             zpiok
1034
        jsr             putmsg
1035
        db              "(ZP):F", 13, 10, 0
1036
zpiok
1037
 
1038
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1039
        ldy             #$ff
1040
        iny
1041
        cpy             #0
1042
        beq             iny_ok
1043
        jsr             putmsg
1044
        db              "INY:F", 13, 10, 0
1045
iny_ok
1046
        ldy             #10
1047
        dey
1048
        cpy             #9
1049
        beq             dey_ok
1050
        jsr             putmsg
1051
        db              "DEY:F", 13, 10, 0
1052
dey_ok
1053
        ldx             #$80
1054
        inx
1055
        cpx             #$81
1056
        beq             inx_ok
1057
        jsr             putmsg
1058
        db              "INX:F", 13, 10, 0
1059
inx_ok
1060
        ldx             #$00
1061
        dex
1062
        cpx             #$ff
1063
        beq             dex_ok
1064
        jsr             putmsg
1065
        db              "DEX:F", 13, 10, 0
1066
dex_ok
1067
 
1068
 
1069
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1070
; Shift ops
1071
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1072
 
1073
        jsr             putmsg
1074
        db              "Test asl/rol/lsr/ror", 13, 10, 0
1075
 
1076
; asl a
1077
 
1078
        lda             #$01
1079
        asl             a
1080
        asl             a
1081
        asl             a
1082
        asl             a
1083
        asl             a
1084
        asl             a
1085
        asl             a
1086
        bpl             aslaerr
1087
        beq             aslaerr
1088
        bcs             aslaerr
1089
        cmp             #$80
1090
        beq             aslaok
1091
        asl             a                               ; check that carry is shifted out
1092
        bcc             aslaerr
1093
        bcs             aslaok
1094
 
1095
aslaerr
1096
        jsr             putmsg
1097
        db              "ASLA:F", 13, 10, 0
1098
 
1099
aslaok
1100
 
1101
; lsr a
1102
 
1103
        lda             #$80
1104
        lsr             a
1105
        lsr             a
1106
        lsr             a
1107
        lsr             a
1108
        lsr             a
1109
        lsr             a
1110
        lsr             a
1111
        bmi             lsraerr
1112
        beq             lsraerr
1113
        bcs             lsraerr
1114
        bcc             lsraok
1115
        lsr             a
1116
        bcc             lsraerr
1117
        bcs             lsraok
1118
 
1119
lsraerr
1120
        jsr             putmsg
1121
        db              "LSRA:F", 13, 10, 0
1122
 
1123
lsraok
1124
 
1125
 
1126
; rol a
1127
 
1128
        clc
1129
        lda             #$01
1130
        rol             a
1131
        rol             a
1132
        rol             a
1133
        rol             a
1134
        rol             a
1135
        rol             a
1136
        rol             a
1137
        bpl             rolaerr
1138
        beq             rolaerr
1139
        bcs             rolaerr
1140
        cmp             #$80            ; this will set the carry !!!
1141
        bne             rolaerr
1142
        clc
1143
        rol             a
1144
        bcc             rolaerr
1145
        bne             rolaerr
1146
        bmi             rolaerr
1147
        rol             a
1148
        bcs             rolaerr
1149
        bmi             rolaerr
1150
        beq             rolaerr
1151
        cmp             #1
1152
        beq             rolaok
1153
 
1154
rolaerr
1155
        jsr             putmsg
1156
        db              "ROLA:F", 13, 10, 0
1157
        jmp             rolaok
1158
 
1159
rolaok
1160
 
1161
 
1162
; ror a
1163
 
1164
        clc
1165
        lda             #$80
1166
        ror             a
1167
        ror             a
1168
        ror             a
1169
        ror             a
1170
        ror             a
1171
        ror             a
1172
        ror             a
1173
        bmi             roraerr
1174
        beq             roraerr
1175
        bcs             roraerr
1176
        cmp             #$01            ; this will set the carry !!!
1177
        bne             roraerr
1178
        clc
1179
        ror             a
1180
        bcc             roraerr
1181
        bne             roraerr
1182
        bmi             roraerr
1183
        ror             a
1184
        bcs             roraerr
1185
        bpl             roraerr
1186
        beq             roraerr
1187
        cmp             #$80
1188
        beq             roraok
1189
        bne             roraerr
1190
 
1191
roraerr
1192
        jsr             putmsg
1193
        db              "RORA:F", 13, 10, 0
1194
 
1195
roraok
1196
 
1197
 
1198
; ror m
1199
 
1200
        clc
1201
        lda             #$80
1202
        sta             dpf
1203
        ror             dpf
1204
        ror             dpf
1205
        ror             dpf
1206
        ror             dpf
1207
        ror             dpf
1208
        ror             dpf
1209
        ror             dpf
1210
        bmi             rormerr
1211
        beq             rormerr
1212
        bcs             rormerr
1213
        lda             dpf
1214
        cmp             #$01            ; this will set the carry !!!
1215
        bne             rormerr
1216
        clc
1217
        ror             dpf
1218
        bcc             rormerr
1219
        bne             rormerr
1220
        bmi             rormerr
1221
        ror             dpf
1222
        bcs             rormerr
1223
        bpl             rormerr
1224
        beq             rormerr
1225
        lda             dpf
1226
        cmp             #$80
1227
        bne             rormerr
1228
        jmp             rormok
1229
 
1230
rormerr
1231
        jsr             putmsg
1232
        db              "RORM:F", 13, 10, 0
1233
        jmp             rormok
1234
 
1235
rormok
1236
 
1237
 
1238
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1239
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1240
 
1241
        jsr             putmsg
1242
        db              "Test psh/pul", 13, 10, 0
1243
 
1244
; pha / pla
1245
        lda             #$ee
1246
        pha
1247
        lda             #00
1248
        clc
1249
        pla
1250
        bpl             plaerr
1251
        beq             plaerr
1252
        bcs             plaerr
1253
        bcc             plaok
1254
 
1255
plaerr
1256
        jsr             putmsg
1257
        db              "PLA:F", 13, 10, 0
1258
 
1259
plaok
1260
 
1261
; phx / plx
1262
        ldx             #$ee
1263
        phx
1264
        ldx             #00
1265
        plx
1266
        cpx             #$ee
1267
        beq             plxok
1268
 
1269
        jsr             putmsg
1270
        db              "PLX:F", 13, 10, 0
1271
 
1272
plxok
1273
 
1274
; phy / ply
1275
        ldy             #$ee
1276
        phy
1277
        ldy             #00
1278
        ply
1279
        cpy             #$ee
1280
        beq             plyok
1281
 
1282
        jsr             putmsg
1283
        db              "PLY:F", 13, 10, 0
1284
 
1285
plyok
1286
 
1287
        ; jmp (a,x)
1288
 
1289
        jsr             putmsg
1290
        db              "test jmp(a,x)", 13, 10, 0
1291
 
1292
        lda             #
1293
        ldx             #>jmpiaxok
1294
        sta             $201
1295
        stx             $202
1296
        ldx             #20
1297
        jmp             ($201-20,x)
1298
 
1299
        jsr             putmsg
1300
        db              "JMP (a,x):F", 13, 10, 0
1301
 
1302
jmpiaxok
1303
        stp
1304
        jmp             ($FFFC)         ; go back to reset
1305
 
1306
;------------------------------------------------------------------
1307
; Kind of a chicken and egg problem here. If there is something
1308
; wrong with the processor, then this code likely won't execute.
1309
;
1310
 
1311
; put message to screen
1312
; tests pla,sta,ldy,inc,bne,ora,jmp,jmp(abs)
1313
 
1314
putmsg
1315
        pla                                     ; pop the return address off the stack
1316
        sta             data_ptr        ; to use as a pointer to the data
1317
        pla
1318
        sta             data_ptr+1
1319
pm2
1320
        ldy             #$01
1321
        lda             (data_ptr),y
1322
        inc             data_ptr
1323
        bne             pm3
1324
        inc             data_ptr+1
1325
pm3
1326
        ora             #0                      ; end of string ?
1327
        beq             pm1
1328
        jsr             putSer
1329
        jmp             pm2
1330
pm1                                             ; must update the return address !
1331
        inc             data_ptr
1332
        bne             pm4
1333
        inc             data_ptr+1
1334
pm4
1335
        jmp             (data_ptr)
1336
 
1337
 
1338
 
1339
; put character to serial port
1340
; test and,bne,pha,pla,sta,lda,rts
1341
 
1342
putSer
1343
        pha                                     ; temporarily save character
1344
ps1
1345
        lda             UART+1          ; get serial port status
1346
        and             #XMIT_FUL       ; is it full ?
1347
        bne             ps1                     ; If full then wait
1348
        pla                                     ; get back the char to write
1349
        sta             UART            ; write it to the xmit register
1350
        rts
1351
 
1352
n55
1353
        db              $55
1354
nAA
1355
        db              $AA
1356
 
1357
        db              12
1358
        db              34
1359
nmirout
1360
        rti
1361
 
1362
        align   4
1363
n5555
1364
        dw              $55555555
1365
nAAAA
1366
        dw              $AAAAAAAA
1367
 
1368
        dw              12
1369
        dw              34
1370
 
1371
        org $0FFFFFFF4          ; NMI vector
1372
        dw      nmirout
1373
 
1374
        org     $0FFFFFFF8              ; reset vector, native mode
1375
        dw      start

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.