65C816 Interrupt Processing Technical Article
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
65C816 Interrupt Processing Technical Article
Investigating 65C816 Interrupts. Also linked at Garth Wilson's website on his Links page.
Last edited by BigDumbDinosaur on Sun Jun 29, 2025 6:13 am, edited 1 time in total.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: 65C816 Interrupt Processing Technical Article
Wow. I guess that's my evening's reading. Thanks for all the work!
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: 65C816 Interrupt Processing Technical Article
scotws wrote:
Wow. I guess that's my evening's reading. Thanks for all the work!
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: 65C816 Interrupt Processing Technical Article
Quote:
The abort interrupt is used in systems that have specialized memory management logic to cope with unusual hardware conditions that may arise during program execution.
Given the high priority of ABORT (just below RESET, but above IRQ), would this still be possibility? I know the 65816 is not really made for serious multitasking -- no protected mode, for one -- but whereas memory stuff would need a MMU ("the required hardware logic" as I understand from the text), what else would you need for preemptive multitasking, however primitive?
Thanks again for the text, I learned a lot. The second computer will definitely be a '816.
- barrym95838
- Posts: 2056
- Joined: 30 Jun 2013
- Location: Sacramento, CA, USA
Re: 65C816 Interrupt Processing Technical Article
Thanks for a nice write-up BDD!
I stumbled across a small typo ... do a search for "already be discussed" and you'll find it.
Since you are a hardware and software guy with a lot of experience, can you provide me with any insight with regards to the edge-sensitive behavior of NMI? Why isn't it just like IRQB? It seems to me that it would be potentially more useful that way, but there could be a good reason that it is not, that I simply don't understand.
Mike
[Edit: Upon further thought, I guess that the hardware triggering the NMI would have to be designed in such a manner as to be able to de-assert itself, since the software wouldn't be able to do so, or make any headway otherwise. In that light, it would be more related to RESETB than IRQB, but could still have some interesting synchronization uses.]
I stumbled across a small typo ... do a search for "already be discussed" and you'll find it.
Since you are a hardware and software guy with a lot of experience, can you provide me with any insight with regards to the edge-sensitive behavior of NMI? Why isn't it just like IRQB? It seems to me that it would be potentially more useful that way, but there could be a good reason that it is not, that I simply don't understand.
Mike
[Edit: Upon further thought, I guess that the hardware triggering the NMI would have to be designed in such a manner as to be able to de-assert itself, since the software wouldn't be able to do so, or make any headway otherwise. In that light, it would be more related to RESETB than IRQB, but could still have some interesting synchronization uses.]
Re: 65C816 Interrupt Processing Technical Article
NMI is edge-triggered for a simple reason. If it were level-triggered, the NMI interrupt would immediately re-interrupt its own service routine after the service routine had executed its first instruction. This process would continue over and over again, locking the machine into an endless loop as the service routine would not be processed to the point where it could disable the interrupt source!
Shift to the left,
Shift to the right,
Mask in, Mask Out,
BYTE! BYTE! BYTE!
Shift to the right,
Mask in, Mask Out,
BYTE! BYTE! BYTE!
-
ElEctric_EyE
- Posts: 3260
- Joined: 02 Mar 2009
- Location: OH, USA
Re: 65C816 Interrupt Processing Technical Article
In hardware (verilog), edge-trigger makes a FF, like a 74374. A level-trigger makes a latch like a 74373.
I remember on the C-64, the certain combination keypress would trigger an NMI 'master' interrupt. IRQ's were a lesser priority.
I remember on the C-64, the certain combination keypress would trigger an NMI 'master' interrupt. IRQ's were a lesser priority.
- barrym95838
- Posts: 2056
- Joined: 30 Jun 2013
- Location: Sacramento, CA, USA
Re: 65C816 Interrupt Processing Technical Article
PaulF wrote:
... process would continue over and over again, locking the machine into an endless loop as the service routine would not be processed to the point where it could disable the interrupt source!
Mike
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: 65C816 Interrupt Processing Technical Article
PaulF wrote:
NMI is edge-triggered for a simple reason. If it were level-triggered, the NMI interrupt would immediately re-interrupt its own service routine after the service routine had executed its first instruction. This process would continue over and over again, locking the machine into an endless loop as the service routine would not be processed to the point where it could disable the interrupt source!
My earliest recollection of the use of NMI was on an ancient BASIC Four mini from the early 1970s, which received its power from a humongous UPS. When the power failed the UPS had a set of contacts that would close and pull an input on the mini to ground if power remained off for more than 10 minutes. That turned out to be an NMI that directed the computer to shut itself down. Obviously, as Paul described, if the NMI had been level-sensitive the interrupt would have kept interrupting and the shutdown would not have happened.
Last edited by BigDumbDinosaur on Wed Nov 06, 2013 3:05 am, edited 1 time in total.
x86? We ain't got no x86. We don't NEED no stinking x86!
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: 65C816 Interrupt Processing Technical Article
barrym95838 wrote:
Thanks for a nice write-up BDD!
Quote:
I stumbled across a small typo ... do a search for "already be discussed" and you'll find it.
Quote:
Since you are a hardware and software guy with a lot of experience, can you provide me with any insight with regards to the edge-sensitive behavior of NMI? Why isn't it just like IRQB? It seems to me that it would be potentially more useful that way, but there could be a good reason that it is not, that I simply don't understand.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: 65C816 Interrupt Processing Technical Article
BigDumbDinosaur wrote:
Why is it the computer won't type what I'm thinking when I'm writing this stuff? :evil:
Oh, wait, was that meant to be rhetorical? My bad. :oops:
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: 65C816 Interrupt Processing Technical Article
scotws wrote:
Quote:
The abort interrupt is used in systems that have specialized memory management logic to cope with unusual hardware conditions that may arise during program execution.
Given the high priority of ABORT (just below RESET, but above IRQ), would this still be possibility?
Code: Select all
.iirq070 bit #u92atirq ;transmitter interrupting?
beq .iirq110 ;no, goto next channel
;
ldx e32tixga ;buffer "get" index
;
.iirq080 cpx e32tixpa ;buffer "put" index
beq .iirq090 ;no data in buffer
;
lda sr_92a ;channel A status
bit #u92txdr ;FIFO full? <————————————— ABORTB IS ASSERTED HERE
beq .iirq100 ;yes, defer next datum
;
lda e32bufta,x ;no, get datum from buffer &...
sta txd_92a ;write to FIFO
txa ;current buffer position
ina ;new buffer position
and #e32xmask ;deal with wrap
sta e32tixga ;set next position
tax
bra .iirq080 ;send another byteQuote:
I know the 65816 is not really made for serious multitasking -- no protected mode, for one -- but whereas memory stuff would need a MMU ("the required hardware logic" as I understand from the text), what else would you need for preemptive multitasking, however primitive?
Oddly enough, preemptive multitasking doesn't required a protected environment. The first generation Commodore Amiga, which was powered by the MC68000, had no memory protection whatsoever, yet was a preemptive multitasking machine. However, the MC68000 does have "user" and "supervisor" modes. Therefore, as long as a user-written program wasn't allowed to wedge into the interrupt system, supervisor mode instructions could not be executed, which made it difficult, but not impossible, for one program to step on something that it shouldn't.
Later Amigas made use of the MC68851 MMU and then the 68030 and 68040 MPUs to implement a virtual memory system that created a true protected environment.
It can be done with the 65C816 by using complex logic to police memory accesses, instruction fetches and such. It's not simple.
Quote:
Thanks again for the text, I learned a lot. The second computer will definitely be a '816.
x86? We ain't got no x86. We don't NEED no stinking x86!
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: 65C816 Interrupt Processing Technical Article
ElEctric_EyE wrote:
I remember on the C-64, the certain combination keypress would trigger an NMI 'master' interrupt. IRQ's were a lesser priority.
CIA #2 was also wired to NMI, as that was how the fake RS-232 functions came about. Looking back at it, it was a house of cards, but worked reasonably well.
x86? We ain't got no x86. We don't NEED no stinking x86!
- BigDumbDinosaur
- Posts: 9428
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: 65C816 Interrupt Processing Technical Article
nyef wrote:
BigDumbDinosaur wrote:
Why is it the computer won't type what I'm thinking when I'm writing this stuff? 
Oh, wait, was that meant to be rhetorical? My bad.
x86? We ain't got no x86. We don't NEED no stinking x86!
- barrym95838
- Posts: 2056
- Joined: 30 Jun 2013
- Location: Sacramento, CA, USA
Re: 65C816 Interrupt Processing Technical Article
RE: NMI. Not to beat a dead horse, but what I'm envisioning is a device that needs to be serviced with an understandable delay, but with no jitter. I don't know if there are devices out there with synchronization needs that are so strict, but if one did exist, it could assert NMI and hold it long enough to guarantee that the processor had finished the current instruction, stacked the state, and loaded the NMI vector into PC. It would then release NMI and 'know' that the ISR would begin execution with EXACT timing precision. It would be kind of like a reset, but with an RTI available. Or like a hardware-triggered version of WAI. Am I making any sense?
Mike
Mike