There are two separate interrupts: maskable and non-maskable. The 6502 will sample these one cycle before the end of each instruction.
If the NMI line has become active (it's edge triggered) then it will perform the NMI routine after this operation completes.
Otherwise, if the IRQ line is active (it's level triggered) and the interrupt disable flag isn't set then it will perform the IRQ routine after this operation completes.
In both cases it'll read the jump vector, push the current program counter and status register to the stack, set the interrupt disable bit and jump to wherever the vector indicated. From memory, that all takes seven cycles.
As well as pushing the status register there's a difference in who is considered responsible for incrementing the the program counter so you use RTI
to return from an interrupt handler rather than RTS
.
The NMI vector is read from FFFA/FFFBh, IRQ from FFFE/FFFFh. The reset vector is between and you could, at a distance, view reset as a kind of NMI that you can't return from.
BRK
is supposed to sort of simulate an IRQ but doesn't do it very well.
So the intended arrangement is: NMIs for anything that should always be serviced now. IRQs for anything that's fine to wait a while. Quite a lot of micros don't wire up NMI at all because then you've always got to have a working handler, but that's far from universal.