eris2010

Documentation: http://frombelow.net/projects/eris2010/
Clone: git clone https://git.frombelow.net/eris2010.git
Log | Files | Refs | README | LICENSE

interrupts.asm (1725B)


      1 ;;; Copyright 2021 Gerd Beuster (gerd@frombelow.net). This is free
      2 ;;; software under the GNU GPL v3 license or any later version. See
      3 ;;; COPYING in the root directory for details.
      4 
      5 	.include "os.inc"
      6 
      7 	.dsection code
      8 
      9 .section zero_page
     10 number_of_interrupts:	.byte ?
     11 .send zero_page
     12 
     13 .section code
     14 
     15 init:
     16 	#io.SETUP
     17 	jsr timer_interrupt
     18 	jmp receiver_interrupt
     19 
     20 
     21 timer_interrupt:
     22 	.block
     23 	#io.PRINTSNL "Testing timer interrupt."
     24 	#mem.STORE_WORD isr_inc_interrupt, os.irq_vector
     25 	lda #%11000000		; Enable timer1 interrupt
     26 	sta via.ier
     27 	lda #%01000000		; Continous interrupts
     28 	sta via.acr
     29 	lda #$ff
     30 	sta via.t1cl		; Set timer1 start
     31 	sta via.t1ch		; value & start counter
     32 	lda #$00
     33 	sta number_of_interrupts
     34 loop:
     35 	lda number_of_interrupts
     36 	cmp #$10
     37 	bne loop
     38 	lda #%01111111		; Disable timer1 interrupt
     39 	sta via.ier
     40 	rts
     41 	.bend
     42 	
     43 receiver_interrupt:
     44 	.block
     45 	sei
     46 	#io.PRINTSNL "Testing ACIA receiver interrupt."
     47         jsr io.init_acia
     48 	lda #$00
     49 	sta number_of_interrupts
     50 	#mem.STORE_WORD isr_inc_interrupt, os.irq_vector
     51         ;; Receiver interrupt on
     52         lda io.acia_cmd_reg
     53         lda #%11001001
     54         sta io.acia_cmd_reg
     55         #io.PRINTSNL "Start typing ..."
     56 	cli
     57 loop:
     58 	lda number_of_interrupts
     59 	cmp #$10
     60 	bne loop
     61 	jmp ($fffc)		; Reset
     62 	.bend
     63 
     64 isr_inc_interrupt:
     65 	.block
     66 	;; Clear ACIA interrupt
     67 	lda io.acia_status_reg
     68 	;; Clear timer interrupt
     69 	lda #%01111111
     70 	sta via.ifr
     71 	lda number_of_interrupts
     72 	inc a
     73 	sta number_of_interrupts
     74 	jsr io.puth
     75 	#io.PRINTNL
     76 	rti
     77 	.bend
     78 	
     79 
     80 putc_irq:
     81 	.block
     82 	ldx #$ff
     83         sta io.acia_data_reg
     84 wait_for_transmission_finish:
     85 	;; Interrupt upon successful transmission
     86 	;; sets X to $00
     87         cpx #$00
     88         bne wait_for_transmission_finish
     89 	rts
     90 	.bend
     91 
     92 .send code