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

Subversion Repositories rtf65002

[/] [rtf65002/] [trunk/] [software/] [asm/] [t65002d.asm] - Blame information for rev 25

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

Line No. Rev Author Line
1 4 robfinch
UART            EQU             $CF00
2
XMIT_FUL        EQU             8
3
 
4
        cpu     rtf65002
5
        org $0FFFFE000          ; 8kB ROM
6
start
7
        sei
8
        lda     #0x01                   ; turn on instruction cache
9
        trs     r1,cc                   ; transfer to cache control reg
10
        ldx     #$1000                  ; set stack pointer to word address $1000
11
        txs
12
        emm                                     ; switch to emulation mode
13
;------------------------------------------------------------------------------
14
; 65C02 testing
15
;------------------------------------------------------------------------------
16
        cpu     W65C02                  ; tell assembler to use 6502 tables
17
        ldx     #$FF
18
        txs
19
        jsr             putmsg
20
        db              "C02 Testing Processor", 13, 10, 0
21
        bra             braok8
22
        jsr             putmsg
23
        db              "BRA:F", 13, 10, 0
24
braok8
25
        brl             brlok8
26
        jsr             putmsg
27
        db              "BRL:F", 13, 10, 0
28
brlok8
29
        sec
30
        bcs             bcsok8
31
        jsr             putmsg
32
        db              "BCS:F", 13, 10, 0
33
bcsok8
34
        clc
35
        bcc             bccok8
36
        jsr             putmsg
37
        db              "BCC:F", 13, 10, 0
38
bccok8
39
        ld              r1,#$00
40
        beq             beqok8
41
        jsr             putmsg
42
        db              "BEQ:F", 13, 10, 0
43
beqok8
44
        ld              r1,#$80000000
45
        bne             bneok8
46
        jsr             putmsg
47
        db              "BNE:F", 13, 10, 0
48
bneok8
49
        or              r1,r1,#$00
50
        bmi             bmiok8
51
        jsr             putmsg
52
        db              "BMI:F", 13, 10, 0
53
bmiok8
54
        eor             r1,r1,#$80000000
55
        bpl             bplok8
56
        jsr             putmsg
57
        db              "BPL:F", 13, 10, 0
58
bplok8
59
        ld              r1,#$7fffffff
60
        add             r1,r1,#$1               ; should give signed overflow
61
        bvs             bvsok8
62
        jsr             putmsg
63
        db              "BVS:F", 13, 10, 0
64
bvsok8
65
        clv
66
        bvc             bvcok
67
        jsr             putmsg
68
        db              "BVC:F", 13, 10, 0
69
bvcok8
70
 
71
;--------------------------------------------------------------------------------------
72
; Native mode tests
73
;--------------------------------------------------------------------------------------
74
 
75
        nat                                     ; switch to native mode
76
        cpu             rtf65002
77
        jsr             putmsg3
78
        db              "65k Testing Processor", 13, 10, 0
79
 
80
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
81
; First thing to test is branches. If you can't branch reliably
82
; then the validity of the remaining tests are in question.
83
; Test branches and also simultaneously some other simple
84
; instructions.
85
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
86
 
87
        sei
88
 
89
        bra             braok
90
        jsr             putmsg3
91
        db              "BRA:F", 13, 10, 0
92
braok
93
        brl             brlok
94
        jsr             putmsg3
95
        db              "BRL:F", 13, 10, 0
96
brlok
97
        sec
98
        bcs             bcsok
99
        jsr             putmsg3
100
        db              "BCS:F", 13, 10, 0
101
bcsok
102
        clc
103
        bcc             bccok
104
        jsr             putmsg3
105
        db              "BCC:F", 13, 10, 0
106
bccok
107
        ld              r1,#$00
108
        beq             beqok
109
        jsr             putmsg3
110
        db              "BEQ:F", 13, 10, 0
111
beqok
112
        ld              r1,#$80000000
113
        bne             bneok
114
        jsr             putmsg3
115
        db              "BNE:F", 13, 10, 0
116
bneok
117
        or              r1,r1,#$00
118
        bmi             bmiok
119
        jsr             putmsg3
120
        db              "BMI:F", 13, 10, 0
121
bmiok
122
        eor             r1,r1,#$80000000
123
        bpl             bplok
124
        jsr             putmsg3
125
        db              "BPL:F", 13, 10, 0
126
bplok
127
        ld              r1,#$7fffffff
128
        add             r1,r1,#$1               ; should give signed overflow
129
        bvs             bvsok
130
        jsr             putmsg3
131
        db              "BVS:F", 13, 10, 0
132
bvsok
133
        clv
134
        bvc             bvcok
135
        jsr             putmsg3
136
        db              "BVC:F", 13, 10, 0
137
bvcok
138
 
139
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
140
; Compare Instructions
141
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
142
 
143
        jsr             putmsg3
144
        db              "test cmp/cpx/cpy", 13, 10, 0
145
 
146
        ld              r1,#27                  ; bit 7 = 0
147
        clc
148
        cmp             r1,#27
149
        bcs             cmperr
150
        bne             cmperr
151
        bmi             cmperr
152
        lda             #$A1000000
153
        cmp             r1,#20000000
154
        bpl             cmperr          ; should be neg.
155
        sec
156
        lda             #10
157
        cmp             r1,#20                  ; should be a borrow here
158
        bcc             cmperr
159
        clv
160
        lda             #$80000000              ; -128 - 32 = -160 should overflow
161
        cmp             r1,#$20000000           ; compare doesn't affect overflow
162
        bvs             cmperr
163
        bvc             cmpok
164
 
165
cmperr
166
        jsr             putmsg
167
        db              "CMP:F", 13, 10, 0
168
 
169
cmpok
170
        ldx             #27
171
        clc
172
        cpx             #27
173
        bcs             cpxerr
174
        bne             cpxerr
175
        bmi             cpxerr
176
        ldx             #$A1000000
177
        cpx             #20000000
178
        bpl             cpxerr
179
        ldx             #10
180
        cpx             #20                     ; should be a borrow here
181
        bcc             cpxerr
182
        clv
183
        ldx             #$80000000              ; -128 - 32 = -160 should overflow
184
        cpx             #$20000000              ; but cpx shouldn't change overflow
185
        bvs             cpxerr
186
        bvc             cpxok
187
 
188
cpxerr
189
        jsr             putmsg
190
        db              "CPX:F", 13, 10, 0
191
 
192
cpxok
193
        ldy             #27
194
        clc
195
        cpy             #27
196
        bcs             cpyerr
197
        bne             cpyerr
198
        bmi             cpyerr
199
        ldy             #$B0000000
200
        cpy             #20000000
201
        bpl             cpyerr
202
        ldy             #10
203
        cpy             #20                     ; should be a borrow here
204
        bcc             cpyerr
205
        clv
206
        ldy             #$80000000              ; -128 - 32 = -160 should overflow
207
        cpy             #$20000000              ; but cpy shouldn't change overflow
208
        bvs             cpyerr
209
        bvc             cpyok
210
 
211
cpyerr
212
        jsr             putmsg
213
        db              "CPY:F", 13, 10, 0
214
 
215
cpyok
216
 
217
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
218
; Accumulator ops
219
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
220
 
221
        jsr             putmsg
222
        db              "Test Acc ops", 13, 10, 0
223
; OR
224
        clv
225
        clc
226
        lda             #0
227
        or              r1,r1,#0
228
        bne             oraerr
229
        bvs             oraerr
230
        bmi             oraerr
231
        bcs             oraerr
232
        sec
233
        or              r1,r1,#0
234
        bcc             oraerr
235
        or              r1,r1,#$55
236
        beq             oraerr
237
        cmp             r1,#$55
238
        bne             oraerr
239
        or              r1,r1,#$aa
240
        cmp             r1,#$ff
241
        bne             oraerr
242
        beq             oraok
243
 
244
oraerr
245
        jsr             putmsg
246
        db              "ORA:F", 13, 10, 0
247
 
248
oraok
249
; SUB
250
        lda             #27                     ; bit 7 = 0
251
        sec
252
        sub             r1,r1,#27
253
        bcs             sbcerr1
254
        bne             sbcerr3
255
        bmi             sbcerr2
256
        bvs             sbcerr4
257
        lda             #$A1000000
258
        sub             r1,r1,#$20000000
259
        bpl             sbcerr2         ; should be neg.
260
        cmp             r1,#$81000000
261
        bne             sbcerr3
262
        sec
263
        lda             #10
264
        sub             r1,r1,#20                       ; should be a borrow here
265
        bcc             sbcerr1
266
        clv
267
        lda             #$80000000              ; -128 - 32 = -160 should overflow
268
        sub             r1,r1,#$20000000                ;
269
        bvc             sbcerr4
270
        bvs             sbcok
271
 
272
sbcerr
273
        bsr             putmsg
274
        db              "SBC:F", 13, 10, 0
275
        jmp             sbcok
276
 
277
sbcerr1
278
        bsr             putmsg
279
        db              "SBC:C", 13, 10, 0
280
        jmp             sbcok
281
 
282
sbcerr2
283
        jsr             putmsg
284
        db              "SBC2:N", 13, 10, 0
285
        jmp             sbcok
286
 
287
sbcerr3
288
        jsr             putmsg
289
        db              "SBC3:Z", 13, 10, 0
290
        jmp             sbcok
291
 
292
sbcerr4
293
        jsr             putmsg
294
        db              "SBC:V", 13, 10, 0
295
        jmp             sbcok
296
 
297
sbcok
298
 
299
 
300
; BIT / AND
301
 
302
        clv
303
        lda             #$ffFFFFFF
304
        bit             r1,n5555
305
        bvc             biterr
306
        bmi             biterr
307
        bit             r1,nAAAA
308
        bvs             biterr
309
        bpl             biterr
310
        bmi             bitok
311
 
312
biterr
313
        jsr             putmsg
314
        db              "BIT:F", 13, 10, 0
315
 
316
bitok
317
 
318
; PLP
319
 
320
        lda             #$DFFFFFFF      ; leave em bit clear
321
        pha
322
        plp
323
        bpl     plperr
324
        bvc             plperr
325
        bne             plperr
326
        bcc             plperr
327
        bcs             plpok
328
 
329
plperr
330
        jsr             putmsg
331
        db              "PLP:F", 13, 10, 0
332
 
333
plpok
334
 
335
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
336
; Load
337
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
338
 
339
        jsr             putmsg
340
        db              "Test lda/ldx/ldy", 13, 10, 0
341
 
342
; lda
343
 
344
        clc
345
        lda             #0
346
        bne             ldaerr
347
        bmi             ldaerr
348
        bcs             ldaerr
349
        lda             #$80000000
350
        beq             ldaerr
351
        bpl             ldaerr
352
 
353
        lda             #$00
354
        st              r1,$800
355
        bne             ldaerr
356
        bmi             ldaerr
357
        bcs             ldaerr
358
 
359
        lda             #-1
360
        lda             $800
361
        bne             ldaerr
362
        bmi             ldaerr
363
        bcs             ldaerr
364
 
365
        cmp             r1,#0
366
        bne             ldaerr
367
 
368
        sec
369
        lda             #-1
370
        st              r1,$800
371
        beq             ldaerr
372
        bpl             ldaerr
373
        bcc             ldaerr
374
 
375
        lda             #0
376
        lda             $800
377
        beq             ldaerr
378
        bpl             ldaerr
379
        bcc             ldaerr
380
 
381
        cmp             r1,#-1
382
        beq             ldaok
383
 
384
ldaerr
385
        jsr             putmsg
386
        db              "LDA:F", 13, 10, 0
387
 
388
ldaok
389
 
390
 
391
; ldx
392
 
393
        clc
394
        lda             #$80000000              ; z = 0, n = 1
395
        ldx             #0
396
        bcs             ldxerr
397
        bne             ldxerr
398
        bmi             ldxerr
399
 
400
        stx             $800
401
        bne             ldxerr
402
        bmi             ldxerr
403
        bcs             ldxerr
404
 
405
        ldx             #-1
406
        ldx             $800
407
        bne             ldxerr
408
        bmi             ldxerr
409
        bcs             ldxerr
410
 
411
        cpx             #0
412
        bne             ldxerr
413
 
414
        sec
415
        ldx             #-1
416
        stx             $800
417
        beq             ldxerr
418
        bpl             ldxerr
419
        bcc             ldxerr
420
 
421
        ldx             #0
422
        ldx             $800
423
        beq             ldxerr
424
        bpl             ldxerr
425
        bcc             ldxerr
426
 
427
        cpx             #-1
428
        beq             ldxok
429
 
430
ldxerr
431
        jsr             putmsg
432
        db              "LDX:F", 13, 10, 0
433
 
434
 
435
; ldy
436
 
437
ldxok
438
        clc
439
        lda             #$80000000              ; z = 0, n = 1
440
        ldy             #0
441
        bcs             ldyerr
442
        bne             ldyerr
443
        bmi             ldyerr
444
 
445
        sty             $800
446
        bne             ldyerr
447
        bmi             ldyerr
448
        bcs             ldyerr
449
 
450
        ldy             #-1
451
        ldy             $800
452
        bne             ldyerr
453
        bmi             ldyerr
454
        bcs             ldyerr
455
 
456
        cpy             #0
457
        bne             ldyerr
458
 
459
        sec
460
        ldy             #-1
461
        sty             $800
462
        beq             ldyerr
463
        bpl             ldyerr
464
        bcc             ldyerr
465
 
466
        ldy             #0
467
        ldy             $800
468
        beq             ldyerr
469
        bpl             ldyerr
470
        bcc             ldyerr
471
 
472
        cpy             #-1
473
        beq             ldyok
474
 
475
ldyerr
476
        jsr             putmsg
477
        db              "LDY:F", 13, 10, 0
478
 
479
ldyok
480
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
481
; Test register transfers
482
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
483
 
484
        jsr             putmsg
485
        db              "Test tax/tay/txa/tya/tsx/txs", 13, 10, 0
486
 
487
; tax
488
 
489
        clc
490
        lda             #0
491
        ldx             #$80000000              ; z = 0, n = 1
492
        tax
493
        bcs             taxerr
494
        bmi             taxerr
495
        bne             taxerr
496
 
497
        txa
498
        bne             taxerr
499
 
500
        lda             #-1
501
        sec
502
        ldx             #0
503
        tax
504
        bcc             taxerr
505
        bpl             taxerr
506
        beq             taxerr
507
 
508
        txa
509
        cmp             r1,#-1
510
        beq             taxok
511
 
512
taxerr
513
        jsr             putmsg
514
        db              "TAX:F", 13, 10, 0
515
taxok
516
 
517
; tay
518
 
519
        clc
520
        lda             #0
521
        ldy             #$80000000                      ; z = 0, n = 1
522
        tay
523
        bcs             tayerr
524
        bmi             tayerr
525
        bne             tayerr
526
 
527
        tya
528
        bne             tayerr
529
 
530
        lda             #-1
531
        sec
532
        ldy             #0
533
        tay
534
        bcc             tayerr
535
        bpl             tayerr
536
        beq             tayerr
537
 
538
        tya
539
        cmp             r1,#-1
540
        beq             tayok
541
 
542
tayerr
543
        jsr             putmsg
544
        db              "TAY:F", 13, 10, 0
545
tayok
546
 
547
 
548
; txs
549
 
550
        ldx             #15
551
        txs
552
        ldx             #87
553
        tsx
554
        cpx             #15
555
        beq             txsok
556
        ldx             #$1000
557
        txs
558
        jsr             putmsg
559
        db              "TSX:F", 13, 10, 0
560
txsok
561
        ldx             #87
562
        txa
563
        cmp             r1,#87
564
        beq             txaok
565
        jsr             putmsg
566
        db              "TXA:F", 13, 10, 0
567
txaok
568
        tay
569
        cpy             #87
570
        beq             tayok1
571
        jsr             putmsg
572
        db              "TAY:F", 13, 10, 0
573
tayok1
574
        tya
575
        beq             tyaerr
576
        bmi             tyaerr
577
        cmp             r1,#87
578
        beq             tyaok
579
tyaerr
580
        jsr             putmsg
581
        db              "TYA:F", 13, 10, 0
582
tyaok
583
 
584
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
585
; Increment / Decrement
586
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
587
 
588
        jsr             putmsg
589
        db              "Test inx/dex/iny/dey/ina/dea/inc/dec", 13, 10, 0
590
 
591
        ldx             #$FFFFFFFE
592
        clc
593
        lda             #0
594
        inx
595
        bcs             inxerr
596
        beq             inxerr
597
        bpl             inxerr
598
 
599
        cpx             #$ffFFFFFF
600
        bne             inxerr
601
 
602
        sec
603
        lda             #$80
604
        inx
605
        bcc             inxerr
606
        bne             inxerr
607
        bmi             inxerr
608
 
609
        cpx             #0
610
        bne             inxerr
611
 
612
        clc
613
;inxl1                          ; test loop
614
;       inx
615
;       bcs             inxerr
616
;       bne             inxl1
617
 
618
        sec
619
;inxl2
620
;       inx
621
;       bcc             inxerr
622
;       bne             inxl2
623
 
624
        beq             inxok
625
 
626
inxerr
627
        jsr             putmsg
628
        db              "INX:F", 13, 10, 0
629
 
630
inxok
631
 
632
;       dex
633
 
634
        ldx             #2
635
        clc
636
        lda             #0
637
        dex
638
        bcs             dexerr
639
        beq             dexerr
640
        bmi             dexerr
641
 
642
        cpx             #1
643
        bne             dexerr
644
 
645
        sec
646
        lda             #$80
647
        dex
648
        bcc             dexerr
649
        bne             dexerr
650
        bmi             dexerr
651
 
652
        cpx             #0
653
        bne             dexerr
654
 
655
        lda             #0
656
        dex
657
        beq             dexerr
658
        bpl             dexerr
659
 
660
        cpx             #$ffffffff
661
        bne             dexerr
662
 
663
        clc
664
;dexl1
665
;       dex
666
;       bcs             dexerr
667
;       bne             dexl1
668
 
669
;       sec
670
dexl2
671
;       dex
672
;       bcc             dexerr
673
;       bne             dexl2
674
 
675
        beq             dexok
676
 
677
dexerr
678
        jsr             putmsg
679
        db              "DEX:F", 13, 10, 0
680
 
681
dexok
682
 
683
; iny
684
 
685
        ldy             #$FFFFFFFE
686
        clc
687
        add             r1,r1,#0
688
        iny
689
        bcs             inyerr
690
        beq             inyerr
691
        bpl             inyerr
692
 
693
        cpy             #$ffffffff
694
        bne             inyerr
695
 
696
        sec
697
        lda             #$80
698
        iny
699
        bcc             inyerr
700
        bne             inyerr
701
        bmi             inyerr
702
 
703
        cpy             #0
704
        bne             inyerr
705
 
706
        clc
707
inyl1                           ; test loop
708
;       iny
709
;       bcs             inyerr
710
;       bne             inyl1
711
 
712
        sec
713
inyl2
714
;       iny
715
;       bcc             inyerr
716
;       bne             inyl2
717
 
718
        beq             inyok
719
 
720
inyerr
721
        jsr             putmsg
722
        db              "INY:F", 13, 10, 0
723
 
724
 
725
;       dey
726
 
727
inyok
728
 
729
        ldy             #2
730
        clc
731
        lda             #0
732
        dey
733
        bcs             deyerr
734
        beq             deyerr
735
        bmi             deyerr
736
 
737
        cpy             #1
738
        bne             deyerr
739
 
740
        sec
741
        lda             #$80
742
        dey
743
        bcc             deyerr
744
        bne             deyerr
745
        bmi             deyerr
746
 
747
        cpy             #0
748
        bne             deyerr
749
 
750
        lda             #0
751
        dey
752
        beq             deyerr
753
        bpl             deyerr
754
 
755
        cpy             #$ffffffff
756
        bne             deyerr
757
 
758
;       clc
759
deyl1
760
;       dey
761
;       bcs             deyerr
762
;       bne             deyl1
763
 
764
;       sec
765
deyl2
766
;       dey
767
;       bcc             deyerr
768
;       bne             deyl2
769
 
770
        bra             deyok
771
 
772
deyerr
773
        jsr             putmsg
774
        db              "DEY:F", 13, 10, 0
775
 
776
deyok
777
 
778
 
779
        lda             #1
780
        ina
781
        cmp             r1,#2
782
        beq             inaok
783
 
784
        jsr             putmsg
785
        db              "INA:F", 13, 10, 0
786
 
787
inaok
788
 
789
        lda             #2
790
        dea
791
        cmp             r1,#1
792
        beq             deaok
793
 
794
        jsr             putmsg
795
        db              "DEA:F", 13, 10, 0
796
 
797
deaok
798
 
799
 
800
        stp
801
 
802
putmsg
803
putmsg3
804
        plx                             ; pop the return address off the stack
805
pm5
806
        lb              r1,$0,x ; load byte into accumulator
807
        inx
808
        ora             #0              ; test for end of string
809
        beq             pm6
810
        bsr             putSer
811
        bra             pm5
812
pm6
813
        jmp             (x)             ; return to next code byte
814
 
815
; put character to serial port
816
; test and,bne,pha,pla,sta,lda,rts
817
 
818
putSer
819
        pha                                     ; temporarily save character
820
ps1
821
        lb              r1,UART+1               ; get serial port status
822
        and             #XMIT_FUL       ; is it full ?
823
        bne             ps1                     ; If full then wait
824
        pla                                     ; get back the char to write
825
        sb              r1,UART         ; write it to the xmit register
826
        rts
827
 
828
nmirout
829
        rti
830
 
831
        align   4
832
n5555
833
        dw              $55555555
834
nAAAA
835
        dw              $AAAAAAAA
836
 
837
        dw              12
838
        dw              34
839
 
840
        org $0FFFFFFF4          ; NMI vector
841
        dw      nmirout
842
 
843
        org     $0FFFFFFF8              ; reset vector, native mode
844
        dw      start

powered by: WebSVN 2.1.0

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