This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

should the I flag be set while processing an interupt?

should the I flag be set while processing an interupt?
by on (#225259)
I have been asking a question in another thread about the scanline counter and one thing that is required to be done for it to work is that the I flag be removed (CLI). Now that I will be starting to write the interrupt code and may need to chain them, there is one point that is maybe not specific to the MMC3 and decided that it would be better to make a different thread about it.

When the code for an interrupt is executed, since some of them will be chained and the code is not reentrant, do you need to set the I flag at the beginning of the task to avoid another interrupt to be called (and remove the flag at the end)?

In the case of the MMC3 you have to acknowledge the IRQ, is it something common in most IRQ system? Should the acknowledgement be done at the beginning or end of the IRQ?
Re: should the I flag be set while processing an interupt?
by on (#225260)
The IRQ itself automatically sets the interrupt flag, along with pushing the return address and flags to the stack. There is no need to set it, it is already set by the time you enter the IRQ handler. (Similarly, it's automatically cleared by RTI when it pops the flags from the stack.)
Re: should the I flag be set while processing an interupt?
by on (#225262)
oh, that's good to know. My concerns were founded but it's already handled by the system. In the case of the MMC3 acknowledgement, I don't need to worry when to do it since the flag is set and another IRQ wont be triggered.

I think that conclude that thread, that was a fast one. Thanks!
Re: should the I flag be set while processing an interupt?
by on (#225267)
See the 6502 interrupts article at http://wilsonminesco.com/6502interrupts/ , especially starting with 1.3 at the subtitle "GETTING TO THE NUTS AND BOLTS." Oh, and uh... Enjoy my outdated cartoons.
Re: should the I flag be set while processing an interupt?
by on (#225292)
When I was searching about interrupt for the 6502 this is maybe the first page I found ;) I will check it in more details later then. thanks!