Special variables: Difference between revisions

(added 6502 and z80)
Line 11:
 
In addition, the last 6 bytes of the address space contain the NMI, Reset, and IRQ vectors, respectively. These values are pointers to functions, which get called when the associated pins are pulled low. In the case of the NMI and IRQ lines, the CPU will automatically push the program counter and the flags, and effectively execute <code>JMP ($FFFA)</code> for NMI and effectively <code>JMP ($FFFE)</code> for IRQ. A reset doesn't push the flags or program counter.
 
<lang 6502asm>;DEFINING INTERRUPT VECTORS ON THE NES
org $FFFA
dw #### ;address of your NMI handler goes here (you can use labels for each of these for your convenience)
dw #### ;address of your Reset handler goes here
dw #### ;address of your IRQ handler goes here.</lang>
 
Depending on the hardware, programming the NMI, Reset, and IRQ routines may not be your responsibility. On the NES, nothing is done for you and you'll have to create both the routines for each of these labels and store their memory locations at the end of the address space.
1,489

edits