Skip to content

Instantly share code, notes, and snippets.

@ryu10
Last active November 20, 2022 17:56
Show Gist options
  • Save ryu10/09fa3c8761d9c3d0c8e87e8476d58c3a to your computer and use it in GitHub Desktop.
Save ryu10/09fa3c8761d9c3d0c8e87e8476d58c3a to your computer and use it in GitHub Desktop.
MC6821 PIA CA1 Interrupt test program
***
* PIA - CA1 Interrupt
*
* RyuStudio Nov. 2022
***
*
* Lambda-2022 PIA Adrs
p0da equ $f008 ; PIA0 DA
p0ca equ p0da+1 ; PIA0 CA
p0db equ p0da+2 ; PIA0 DB
p0cb equ p0da+3 ; PIA0 CB
p1da equ $f010 ; PIA1 DA
p1ca equ p1da+1 ; PIA1 CA
p1db equ p1da+2 ; PIA1 DB
p1cb equ p1da+3 ; PIA1 CB
*
* MikBug NIO Adrs
nio equ $a606
* pdata1 entry
pdata1 equ $f17e
*
org $8000
*
start jsr initpia0 ; set all ports on PA and PB to inputs
ldx #ca1handler
stx nio
ldaa #$01 ; configure CA1 interrupt;
staa p0ca
endl bra endl
*
ca1handler tst p0ca ; check bit7 of PIA0 CA
bpl notca
ldx #camesg
jsr pdata1
bra endhandl
notca ldx #ncamesg
jsr pdata1
endhandl swi ; force quit; clear stack data
*
camesg fcb $0d, $0a
fcc 'INTERRUPT VIA PIA0 CA'
fcb $0d, $0a, 4
ncamesg fcb $0d, $0a
fcc 'INTERRUPT SOURCE UNKNOWN'
fcb $0d, $0a, 4
*
initpia0 ldx #p0da
jsr initport
ldx #p0db
initport clra
staa 1,X ; reset Cx, select DDRx
staa 0,X ; set DDRx ; all output
ldaa #4
staa 1,X ; select PRx
rts
initpia1 ldx #p1da
jsr initport
ldx #p1db
bra initport
*
end
@ryu10
Copy link
Author

ryu10 commented Nov 20, 2022

This is a test for MikBug NMI handler NIO.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment