|
When an NMI/IRQ occurs, the currently executing code will be interrupted, and resumes only when you issue an RTI instruction. In your case, the code being interrupted by the NMI already would be the infinite loop that you enter after setting up the PPU. At the end of the NMI routine, the RTI instruction ends NMI/IRQ processing, and returns to your infinite loop automatically to wait for the next NMI/IRQ.
Think of NMI/IRQ as kind of an "invisible JSR" that is executed only by the hardware, and can happen at any time. Thus, when you are done handling NMI, you'll want to return to whatever code was executing before by using an RTI instruction.
Note that the "happen at any time" part is why we and steer clear from CLI, which enables IRQs, which means we would have 2 possible interruptions to deal with, which could possibly interrupt each other, etc, ad interruptum. : ) It is also why we disable PPU NMI's whenever we are initializing; a zen that I have had to reflect on as recently as this past weekend, as Memblers knows. ; )
Phoenix
|