Category:6502 Assembly: Difference between revisions

m
m (Put Structs and Arrays in the proper section)
Line 56:
 
==Interrupts==
The 6502 has two interrupt types: <code>NMI</code> (Non-Maskable Interrupt) and <code>IRQ</code>(Interrupt Request). 6502 machines use the last 6 bytes of their address space to hold a vector table containing (in order) the addresses of the NMI routine, the program's start, and the IRQ routine. On most computers this is defined by the firmware, but on the NES or other similar embedded hardware you will need to declare these locations yourself.
 
As the name implies, the Non-Maskable Interrupt is one that can occur regardless of whether the processor has interrupts disabled. In other words, the <code>SEI</code> and <code>CLI</code> commands <i>cannot enable or disable the NMI</i>. The name "Non-Maskable" is a bit of a misnomer; while it's true that the 6502 cannot prevent <code>NMI</code> from occurring, the source of the <code>NMI</code> signal can still be disconnected, effectively preventing its occurrence. For example, on the NES, the <code>NMI</code> occurs every 1/60th of a second and only if bit 7 of memory address $2000 is set. If this bit is clear, no <code>NMI</code>. For a given hardware, the <code>NMI</code> comes from exactly one source, since an <code>NMI</code> cannot be detected during an <code>NMI</code>.
1,489

edits