Hello everyone.
I'm thinking of adding a 6522 VIA to my board. But before I can do that, I'm making sure I can do it properly in software. I want to create a "dummy" ISR for the VIA. This is a fairly basic question so I'm putting in the Newbie section. Hopefully that's correct.
Let's say there are two VIA's, with an AND gate used on the /IRQ line. The IRQ-ISR would look like:
Code:
irq_isr:
BIT via1_ifr ; test VIA1
BMI via1_isr ; if it was VIA1, branch
BIT via2_ifr ; test VIA2
BMI via2_ifr ; if it was VIA2, branch
RTI ; else, error, just exit
So I know I wouldn't *need* the second test, but just for clarity's sake let's keep it. Now to VIA1-ISR.
Code:
via1_isr:
PHA ; push A
LDA #$7F ; load %01111111
STA via_ifr ; store into IFR to 'clear flags'???
PLA ; pull A
RTI ; exit
VIA2-ISR would be similar.
So here is where the main question arises. I want a 'dummy' handler, and so I want to clear all of the interrupts and exit immediately. According the datasheet (WDC, Rockwell, etc) I am seeing that you "write 1's into the IFR to clear all interrupt flags". This seems weird because a 1 normally say "there is an interrupt here!". Am I... doing this right? Am I understanding the datasheets correctly?
I don't care which flags were set, I don't care why I'm even here. All of this is a fluke and should never happen. BUT, in the off chance, I want the computer to not glitch or infinite loop. This seems like the quickest way to exit cleanly. What do you think?
Thoughts? Experience?
Thank you everyone.
Chad