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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [Projects/] [opencores.org/] [Mos6502/] [sw/] [irq_test/] [irq_test.asm] - Blame information for rev 133

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

Line No. Rev Author Line
1 131 jt_eaton
 
2
  include  ../io_module/io_module.asm
3
 
4
 
5
        ;;  page zero variables used during test
6
c_test         = $40    ;
7
n_test         = $41    ;
8
v_test         = $42    ;
9
z_test         = $43    ;
10
pointer        = $44    ;
11
counter0       = $46    ;
12
counter1       = $48    ;
13
 
14
        * = $c000  ; assemble at $f000
15
               code
16
 
17
                   jmp  .nmi_vec               ;
18
                   jmp  .irq_vec               ;
19
 
20
.start             nop
21
                   lda #$00
22
                   sta counter0
23
                   sta counter1
24
                   sta $04
25
                   sta $05
26
                   sta $06
27
                   sta $07
28
                   lda #$00
29
                   sta io_base+io_gpio_0
30
                   lda io_base+io_gpio_0
31
                   lda #$01
32
                   sta io_base+io_gpio_0
33
                   lda io_base+io_gpio_0
34
                   sta io_base+io_pic_irq_en
35
                   jmp .lab_00
36
                   lda #$00
37
                   jmp .error
38
.lab_00            lda #$01
39
                   sta io_base+io_gpio_0
40
                   lda io_base+io_gpio_0
41
                   lda #$02
42
                   sta io_base+io_gpio_0
43
                   lda io_base+io_gpio_0
44
                   clc
45
                   bcc .lab_44
46
                   lda #$01
47
                   jmp .error
48
 
49
.lab_44            lda #$28
50
                   sta io_base+io_gpio_0
51
                   lda #$EF
52
                   sta $0200
53
                   inc $0200
54
                   lda #$F0
55
                   cmp $0200
56
                   beq  .lab_45
57
                   lda #$39
58
                   jmp .error
59
.lab_45            lda #$FF
60
                   sta $0200
61
                   inc $0200
62
                   beq  .lab_46
63
                   lda #$40
64
                   jmp .error
65
.lab_46            lda #$29
66
                   sta io_base+io_gpio_0
67
                   ldy #$32
68
                   sty $0201
69
                   ldx #$B4
70
                   stx $0200
71
                   lda #$86
72
                   eor $0200
73
                   cmp $0201
74
                   beq  .lab_47
75
                   lda #$41
76
                   jmp .error
77
.lab_47            lda #$2A
78
                   sta io_base+io_gpio_0
79
                   ldy #$B6
80
                   sty $0201
81
                   ldx #$B4
82
                   stx $0200
83
                   lda #$86
84
                   ora $0200
85
                   cmp $0201
86
                   beq  .lab_59
87
                   lda #$42
88
                   jmp .error
89
 
90
 
91
 
92
.lab_59            lda #$31
93
                   sta io_base+io_gpio_0
94
                   lda #$42
95
                   pha
96
                   lda #$ED
97
                   pha
98
                   lda #$BE
99
                   pha
100
                   lda #$00
101
                   pla
102
                   cmp #$BE
103
                   bne .lab_60
104
                   pla
105
                   cmp #$ED
106
                   bne .lab_60
107
                   pla
108
                   cmp #$42
109
                   bne .lab_60
110
                   jmp  .lab_605
111
.lab_60            lda #$4E
112
                   jmp .error
113
.lab_605           lda #$32
114
                   sta io_base+io_gpio_0
115
                   ldx #$00
116
                   clc
117
                   lda #$03
118
                   sta $0200,X
119
                   adc #$07
120
                   inx
121
                   sta $0200,X
122
                   adc #$07
123
                   inx
124
                   sta $0200,X
125
                   adc #$07
126
                   inx
127
                   sta $0200,X
128
                   adc #$07
129
                   inx
130
                   sta $0200,X
131
                   adc #$07
132
                   inx
133
                   sta $0200,X
134
                   adc #$07
135
                   inx
136
                   sta $0200,X
137
                   ldx #$00
138
                   clc
139
                   lda $0200,X
140
                   cmp #$03
141
                   bne .lab_61
142
                   inx
143
                   lda $0200,X
144
                   cmp #$0A
145
                   bne .lab_61
146
                   inx
147
                   lda $0200,X
148
                   cmp #$11
149
                   bne .lab_61
150
                   inx
151
                   lda $0200,X
152
                   cmp #$18
153
                   bne .lab_61
154
                   inx
155
                   lda $0200,X
156
                   cmp #$1F
157
                   bne .lab_61
158
                   inx
159
                   lda $0200,X
160
                   cmp #$26
161
                   bne .lab_61
162
                   inx
163
                   lda $0200,X
164
                   cmp #$2D
165
                   bne .lab_61
166
                   jmp .lab_615
167
.lab_61            lda #$4F
168
                   jmp .error
169
.lab_615           lda #$33
170
                   sta io_base+io_gpio_0
171
                   ldy #$00
172
                   clc
173
                   lda #$03
174
                   sta $0200,Y
175
                   adc #$07
176
                   iny
177
                   sta $0200,Y
178
                   adc #$07
179
                   iny
180
                   sta $0200,Y
181
                   adc #$07
182
                   iny
183
                   sta $0200,Y
184
                   adc #$07
185
                   iny
186
                   sta $0200,Y
187
                   adc #$07
188
                   iny
189
                   sta $0200,Y
190
                   adc #$07
191
                   iny
192
                   sta $0200,Y
193
                   ldy #$00
194
                   clc
195
                   lda $0200,Y
196
                   cmp #$03
197
                   bne .lab_62
198
                   iny
199
                   lda $0200,Y
200
                   cmp #$0A
201
                   bne .lab_62
202
                   iny
203
                   lda $0200,Y
204
                   cmp #$11
205
                   bne .lab_62
206
                   iny
207
                   lda $0200,Y
208
                   cmp #$18
209
                   bne .lab_62
210
                   iny
211
                   lda $0200,Y
212
                   cmp #$1F
213
                   bne .lab_62
214
                   iny
215
                   lda $0200,Y
216
                   cmp #$26
217
                   bne .lab_62
218
                   iny
219
                   lda $0200,Y
220
                   cmp #$2D
221
                   bne .lab_62
222
                   jmp .lab_625
223
.lab_62            lda #$50
224
                   jmp .error
225
.lab_625           lda #$34
226
                   sta io_base+io_gpio_0
227
                   lda #$52
228
                   sta $0200
229
                   lda #$24
230
                   sta $0201
231
                   lda #$78
232
                   sta $0202
233
                   lda #$00
234
                   ldx #$00
235
                   clc
236
                   adc $0200,X
237
                   clc
238
                   inx
239
                   adc $0200,X
240
                   clc
241
                   inx
242
                   adc $0200,X
243
                   cmp #$EE
244
                   beq .lab_63
245
                   lda #$51
246
                   jmp .error
247
.lab_63            lda #$35
248
                   sta io_base+io_gpio_0
249
                   lda #$68
250
                   sta $0200
251
                   lda #$13
252
                   sta $0201
253
                   lda #$95
254
                   sta $0202
255
                   lda #$00
256
                   ldy #$00
257
                   clc
258
                   adc $0200,Y
259
                   clc
260
                   iny
261
                   adc $0200,Y
262
                   clc
263
                   iny
264
                   adc $0200,Y
265
                   cmp #$10
266
                   beq  .lab_64
267
                   lda #$52
268
                   jmp .error
269
.lab_64            lda #$36
270
                   sta io_base+io_gpio_0
271
                   lda #$34
272
                   sta $0200
273
                   lda #$54
274
                   sta $0201
275
                   lda #$97
276
                   sta $0202
277
                   lda #$FF
278
                   ldy #$00
279
                   and $0200,Y
280
                   iny
281
                   and $0200,Y
282
                   iny
283
                   and $0200,Y
284
                   cmp #$14
285
                   beq .lab_65
286
                   lda #$53
287
                   jmp .error
288
.lab_65            lda #$37
289
                   sta io_base+io_gpio_0
290
                   lda #$34
291
                   sta $0200
292
                   lda #$54
293
                   sta $0201
294
                   lda #$97
295
                   sta $0202
296
                   lda #$FF
297
                   ldx #$00
298
                   and $0200,X
299
                   inx
300
                   and $0200,X
301
                   inx
302
                   and $0200,X
303
                   cmp #$14
304
                   beq .lab_66
305
                   lda #$54
306
                   jmp .error
307
.lab_66            lda #$38
308
                   sta io_base+io_gpio_0
309
                   lda #$64
310
                   sta $00
311
                   lda #$39
312
                   clc
313
                   adc $00
314
                   cmp #$9D
315
                   beq  .lab_735
316
                   lda #$55
317
                   jmp .error
318
.lab_735           lda #$3F
319
                   sta io_base+io_gpio_0
320
                   lda #$95
321
                   sta $02
322
                   lda #$00
323
                   lda #$95
324
                   cmp  $02
325
                   beq  .lab_74
326
                   lda #$5C
327
                   jmp .error
328
.lab_74            lda #$75
329
                   sta $02
330
                   lda #$67
331
                   cmp  $02
332
                   bne .lab_75
333
                   lda #$5D
334
                   jmp .error
335
.lab_75            lda #$40
336
                   sta io_base+io_gpio_0
337
                   lda #$36
338
                   sta $02
339
                   lda #$00
340
                   ldx #$36
341
                   cpx $02
342
                   beq  .lab_76
343
                   lda #$5E
344
                   jmp .error
345
.lab_76            lda #$57
346
                   sta $02
347
                   ldx #$39
348
                   cpx $02
349
                   bne .lab_77
350
                   lda #$5F
351
                   jmp .error
352
.lab_77            lda #$41
353
                   sta io_base+io_gpio_0
354
                   lda #$75
355
                   sta $02
356
                   lda #$00
357
                   ldy #$75
358
                   cpy $02
359
                   beq  .lab_78
360
                   lda #$60
361
                   jmp .error
362
.lab_78            lda #$43
363
                   sta $02
364
                   ldy #$24
365
                   cpy $02
366
                   bne .lab_79
367
                   lda #$61
368
                   jmp .error
369
.lab_79            lda #$42
370
                   sta io_base+io_gpio_0
371
                   cli          ; was cli
372
                   lda #$00
373
                   sta $05
374
                   lda #$01
375
                   sta $04
376
                   lda #$10
377
                   sta io_base+io_tim0_end
378
                   sta io_base+io_tim0_start
379
                   ldx #$00
380
                   inx
381
                   inx
382
                   inx
383
                   inx
384
                   inx
385
                   inx
386
                   inx
387
                   inx
388
                   inx
389
                   inx
390
                   inx
391
                   inx
392
                   inx
393
                   inx
394
                   inx
395
                   inx
396
                   cpx  #$10
397
                   beq .lab_80
398
                   lda #$62
399
                   jmp .error
400
.lab_80            lda $05
401
                   cmp #$00     ; was 1 if int serviced
402
                   beq  .lab_81
403
                   lda #$63
404
                   jmp .error
405
.lab_81            nop          ;   was sei to disable interrupt
406
                   lda #$00
407
                   sta $05
408
                   lda #$01
409
                   sta $04
410
                   lda #$10
411
                   sta io_base+io_tim0_end
412
                   sta io_base+io_tim0_start
413
                   ldx #$00
414
                   inx
415
                   inx
416
                   inx
417
                   inx
418
                   inx
419
                   inx
420
                   inx
421
                   inx
422
                   inx
423
                   inx
424
                   inx
425
                   inx
426
                   inx
427
                   inx
428
                   inx
429
                   inx
430
                   cpx #$10
431
                   beq .lab_82
432
                   lda #$62
433
                   jmp .error
434
.lab_82            lda $05
435
                   cmp #$00
436
                   beq  .lab_83
437
                   lda #$63
438
                   jmp .error
439
.lab_83            lda #$00
440
                   sta $04
441
                   sta io_base+io_tim0_end
442
                   lda #$43
443
                   sta io_base+io_gpio_0
444
                   lda #$00
445
                   sta $07
446
                   lda #$01
447
                   sta $06
448
                   lda #$10
449
                   sta io_base+io_tim0_end ; change to tim1 for nmi
450
                   sta io_base+io_tim0_start   ; change to tim1 for nmi
451
                   ldx #$00
452
                   inx
453
                   inx
454
                   inx
455
                   inx
456
                   inx
457
                   inx
458
                   inx
459
                   inx
460
                   inx
461
                   inx
462
                   inx
463
                   inx
464
                   inx
465
                   inx
466
                   inx
467
                   inx
468
                   cpx  #$10
469
                   beq  .lab_84
470
                   lda #$64
471
                   jmp .error
472
.lab_84            lda $07
473
                   cmp #$00     ; change to 1 if nmi serviced
474
                   beq  .lab_85
475
                   lda #$65
476
                   jmp .error
477
.lab_85            lda #$00
478
                   sta $06
479
                   sta io_base+io_tim1_end
480
                   lda #$44
481
                   sta io_base+io_gpio_0
482
                   jmp .lab_865
483
.lab_86            jmp .lab_866
484
.lab_865           sec
485
                   bcs .lab_86
486
                   nop
487
                   nop
488
                   nop
489
                   lda #$66
490
                   jmp .error
491
.lab_866           lda #$45
492
                   sta io_base+io_gpio_0
493
                   sec
494
                   lda #$34
495
                   sbc #$75
496
                   bcc .lab_87
497
                   lda #$67
498
                   jmp .error
499
.lab_87            lda #$46
500
                   sta io_base+io_gpio_0
501
                   tsx
502
                   stx $00
503
                   lda #$42
504
                   pha
505
                   lda #$00
506
                   tsx
507
                   inx
508
                   lda $0100,X
509
                   cmp #$42
510
                   beq  .lab_88
511
                   lda #$68
512
                   jmp .error
513
.lab_88            lda #$69
514
                   sta $0112
515
                   lda #$00
516
                   ldx #$11
517
                   txs
518
                   pla
519
                   cmp #$69
520
                   beq  .lab_89
521
                   lda #$69
522
                   jmp .error
523
 
524
        ;;  Break test
525
        ;;
526
.lab_89            ldx $00
527
                   txs
528
                   lda #$47
529
                   sta io_base+io_gpio_0
530
                   lda #$24     ; keep int disabled
531
                   pha
532
                   plp
533
                   stx $08
534
                   lda #$00
535
                   sta $05
536
                   lda #$01
537
                   sta $04
538
                   sta $06
539
                   ldx #$59
540
                   brk          ; was brk
541
                   inx
542
                   lda #$00
543
                   sta $04
544
                   lda $05
545
                   cmp #$01     ; was 1 if brk taken
546
                   beq  .lab_92
547
                   lda #$70
548
                   jmp .error
549
 
550
.lab_92            lda #$48
551
                   sta io_base+io_gpio_0
552
                   lda #$53
553
                   sta $30
554
                   lda #$00
555
                   ldx #$40
556
                   lda $F0,X
557
                   cmp #$53
558
                   beq  .lab_93
559
                   lda #$73
560
                   jmp .error
561
.lab_93            lda #$49
562
                   sta io_base+io_gpio_0
563
                   clc
564
                   lda #$FF
565
                   adc #$01
566
                   bcs .lab_94
567
                   lda #$74
568
                   jmp .error
569
.lab_94            lda #$4A
570
                   sta io_base+io_gpio_0
571
                   sec
572
                   lda #$7F
573
                   sbc #$7E
574
                   bvc  .lab_95
575
                   lda #$75
576
                   jmp .error
577
.lab_95            lda #$4B
578
                   sta io_base+io_gpio_0
579
                   lda #$FF
580
                   pha
581
                   plp
582
                   php
583
                   pla
584
                   cmp #$FF
585
                   beq  .lab_96
586
                   lda #$76
587
                   jmp .error
588
.lab_96            lda #$4C
589
                   sta io_base+io_gpio_0
590
                   lda #$40
591
                   ldx #$00
592
                   sta $0200,X
593
                   inx
594
                   lsr a
595
                   sta $0200,X
596
                   inx
597
                   lsr a
598
                   sta $0200,X
599
                   inx
600
                   lsr a
601
                   sta $0200,X
602
                   inx
603
                   lsr a
604
                   sta $0200,X
605
                   inx
606
                   lsr a
607
                   sta $0200,X
608
                   inx
609
                   lsr a
610
                   sta $0200,X
611
                   ldx #$00
612
                   asl $0200,X
613
                   inx
614
                   asl $0200,X
615
                   inx
616
                   asl $0200,X
617
                   inx
618
                   asl $0200,X
619
                   inx
620
                   asl $0200,X
621
                   inx
622
                   asl $0200,X
623
                   inx
624
                   asl $0200,X
625
                   lda #$00
626
                   clc
627
                   cld
628
                   adc $0200
629
                   adc $0201
630
                   adc $0202
631
                   adc $0203
632
                   adc $0204
633
                   adc $0205
634
                   adc $0206
635
                   cmp #$FE
636
                   beq  .lab_97
637
                   lda #$77
638
                   jmp  .error
639
.lab_97            lda #$4D
640
                   sta io_base+io_gpio_0
641
                   ldx #$42
642
                   ldy #$00
643
                   stx $0200
644
                   ldx #$9F
645
                   stx $0201
646
                   ldx $0200,Y
647
                   cpx #$42
648
                   beq  .lab_98
649
                   lda #$48
650
                   jmp .error
651
.lab_98            ldx $0201,Y
652
                   cpx #$9F
653
                   beq  .lab_99
654
                   lda #$78
655
                   jmp .error
656
 
657
 
658
 
659
 
660
 
661
.lab_99            lda #$4e
662
                   sta io_base+io_gpio_0
663
                   ldy #$00
664
                   ldx #$00
665
                   lda #$00
666
                   sta c_test
667
                   sta n_test
668
                   sta v_test
669
                   sta z_test
670
                   sta pointer
671
                   lda #$ff
672
                   sta pointer+1
673
                   clc
674
.lab_100           adc (pointer,x)
675
                   bpl .lab_105
676
                   bne .lab_103
677
                   inc n_test
678
                   inc z_test
679
                   jmp .lab_110
680
.lab_103           inc n_test
681
                   jmp .lab_110
682
.lab_105           bne .lab_110
683
                   inc z_test
684
.lab_110           bcc .lab_115
685
                   inc c_test
686
.lab_115           bvc .lab_120
687
                   inc v_test
688
.lab_120           inc pointer
689
                   bne .lab_100
690
 
691
                   cmp #$07
692
                   bne .error
693
                   lda c_test
694
                   cmp #$4e
695
                   bne .error
696
                   lda n_test
697
                   cmp #$90
698
                   bne .error
699
                   lda v_test
700
                   cmp #$32
701
                   bne .error
702
                   lda z_test
703
                   cmp #$03
704
                   bne .error
705
 
706
 
707
 
708
        ;;  pass end loop
709
.good              sei
710
                   lda #$FF
711
                   sta io_base+io_gpio_0
712
                   lda #$FF
713
                   sta io_base+io_gpio_1
714
                   jmp .end_lp
715
 
716
        ;; error  & end loop
717
.error             sei
718
                   sta io_base+io_gpio_1
719
.end_lp            lda #$00
720
                   pha
721
                   plp
722
                   jmp .end_lp
723
 
724
 
725
        ;; Interrupt service routine
726
.nmi_vec           pha
727
                   txa
728
                   pha
729
                   tya
730
                   pha
731
                   tsx
732
                   inx
733
                   inx
734
                   inx
735
                   inx
736
                   lda $0100,X
737
                   sta $08
738
                   lda $04
739
                   cmp #$00
740
                   bne .nmi_001
741
                   lda #$E0
742
                   jmp .error
743
.nmi_001           sta io_base+io_tim0_end
744
                   inc $05
745
                   pla
746
                   tay
747
                   pla
748
                   tax
749
                   pla
750
                   rti
751
 
752
        ;; Interrupt service routine
753
 
754
.irq_vec           pha
755
                   txa
756
                   pha
757
                   tya
758
                   pha
759
                   lda #$10
760
                   sta io_base+io_tim0_end
761
                   lda #$30
762
.irq_001           sta io_base+io_tim0_start
763
                   inc counter0
764
                   bne .irq_002
765
                   inc counter1
766
                   bne .irq_002
767
                   inc io_base+io_gpio_1
768
.irq_002           pla
769
                   tay
770
                   pla
771
                   tax
772
                   pla
773
                   rti
774
 
775
 
776
 
777
 
778
 * = $cffa  ; vectors
779
 
780
 
781
 
782
     dw $0000          ;
783
     dw $0000                  ;
784
     dw $0000          ;
785
 
786
 
787
 
788
 
789
 
790
 code
791
 
792
 
793
 
794
 
795
 
796
 

powered by: WebSVN 2.1.0

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