Closed mooinglemur closed 3 months ago
I'm not too happy with the instruction cycle cost this adds to NMI, but it's sadly necessary, and the instruction cost will be alleviated with another low RAM jump like discussed in Discord a month ago anyway.
Most of the cycle cost is avoided by the user changing what innmi
points to. The code at c816_nmib
(the ROM vector) is simply rep #$30
jmp (innmi)
. We could take out the rep #$30
and put the onus on the user but I can't imagine a scenario where anyone would want that. I can't claim to anticipate what people want though.
jmp (abs)
costs 5 cycles, just two more than jmp abs
. If we added a jump to RAM, they would probably have to immediately jmp somewhere else since the area of RAM being pointed to won't have room for code, ultimately costing a total of 6 cycles rather than the 5 we have now.
This change causes the default native NMI indirect vector target to switch to emulation mode while setting up an RTI stack frame, giving an emulation NMI handler that is 65C816-unaware the ability to return back into native code.
Removed the explicit jump from one of the irq handling macros to make them more general so that the routine could be reused.