The 65xx family of microprocessors, consisting of the MOS Technology 6502 and its derivatives, the WDC 65C02, WDC 65C802 and WDC 65C816, and CSG 65CE02, all handle interrupts in a similar fashion. There are three hardware interrupt signals common to all 65xx processors and one software interrupt, the BRK instruction. The WDC 65C816 adds a fourth hardware interrupt—ABORT, useful for implementing virtual memory architectures—and the COP software interrupt instruction (also present in the 65C802), intended for use in a system with a coprocessor of some type (e.g., a floating-point processor).
Interrupt types
The hardware interrupt signals are all active low, and are as follows:
RESET a reset signal, level-triggered NMI a non-maskable interrupt, edge-triggered IRQ a maskable interrupt, level-triggered ABORT a special-purpose, non-maskable interrupt (65C816 only, see below), level-triggered The detection of a RESET signal causes the processor to enter a system initialization period of six clock cycles, after which it sets the interrupt request disable flag in the status register and loads the program counter with the values stored at the processor initialization vector ($00FFFC–$00FFFD) before commencing execution. If operating in native mode, the 65C816/65C802 are switched back to emulation mode and stay there until returned to native mode under software control.
The detection of an NMI or IRQ signal, as well as the execution of a BRK instruction, will cause the same overall sequence of events, which are, in order:
The processor completes the current instruction and updates registers or memory as required before responding to the interrupt. 65C816/65C802 when operating in native mode: The program bank register (PB, the A16-A23 part of the address bus) is pushed onto the hardware stack. The most significant byte (MSB) of the program counter (PC) is pushed onto the stack. The least significant byte (LSB) of the program counter is pushed onto the stack. The status register (SR) is pushed onto the stack. The interrupt disable flag is set in the status register. 65C816/65C802: PB is loaded with $00. PC is loaded from the relevant vector (see tables). The behavior of the 65C816 when ABORT is asserted differs in some respects from the above description and is separately discussed below. Note that the processor does not push the accumulator and index registers on to the stack—code in the interrupt handler must perform that task, as well as restore the registers at the termination of interrupt processing, as necessary. Also note that the vector for IRQ is the same as that for BRK in all eight bit 65xx processors, as well as in the 65C802/65C816 when operating in emulation mode. When operating in native mode, the 65C802/65C816 provide separate vectors for IRQ and BRK. When set, the interrupt request disable flag (the I bit in the status register) will disable detection of the IRQ signal, but will have no effect on any other interrupts (however, see below section on the WAI instruction implemented in WDC CMOS processors). Additionally, with the 65(c)02 or the 65C816/65C802 operating in emulation mode, the copy of the status register that is pushed on to the stack will have the B flag set if a BRK (software interrupt) was the cause of the interrupt, or cleared if an IRQ was the cause. Hence the interrupt service routine must retrieve a copy of the saved status register from where it was pushed onto the stack and check the status of the B flag in order to distinguish between an IRQ and a BRK. This requirement is eliminated when operating the 65C802/65C816 in native mode, due to the separate vectors for the two interrupt types.
ABORT interrupt The 65C816's ABORTB interrupt input is intended to provide the means to redirect program execution when a hardware exception is detected, such as a page fault or a memory access violation. Hence the processor's response when the ABORTB input is asserted (negated) is different from when IRQB and/or NMIB are asserted. Also, achieving correct operation in response to ABORTB requires that the interrupt occur at the proper time during the machine cycle, whereas no such requirement exists for IRQB or NMIB. When ABORTB is asserted during a valid memory cycle, that is, when the processor has asserted the VDA and/or VPA status outputs, the following sequence of events will occur:
The processor completes the current instruction but does not change the registers or memory in any way—the computational results of the completed instruction are discarded. An abort interrupt does not literally abort an instruction. The program bank (PB, see above) is pushed to the stack. The most significant byte (MSB) of the aborted instruction's address is pushed onto the stack. The least significant byte (LSB) of the aborted instruction's address is pushed onto the stack. The status register is pushed onto the stack. The interrupt disable flag is set in the status register. PB is loaded with $00. The program counter is loaded from the ABORT vector (see tables). As the address pushed to the stack is that of the aborted instruction rather than the contents of the program counter, executing an RTI (ReTurn from Interrupt) following an ABORT interrupt will cause the processor to return to the aborted instruction, rather than the next instruction, as would be the case with the other interrupts. In order for the processor to correctly respond to an abort, system logic must assert (negate) the ABORTB input as soon as a valid address has been placed on the bus and it has been determined that the address constitutes a page fault, memory access violation or other anomaly (e.g., attempted execution of a privileged instruction). Hence the logic must not assert ABORTB until the processor has asserted the VDA or VPA signals. Also, ABORTB must remain asserted until the fall of the phase-two clock and then be immediately released. If these timing constraints are not observed, the abort interrupt handler itself may be aborted, causing registers and/or memory to be changed in a possibly-undefined manner.
… excerpt ends here. Continue reading the full article.