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

Why must VECTORS be direct?

Why must VECTORS be direct?
by on (#190151)
I wanted to put my IRQ handler in a separate file, so in crt0.s I put "import irq" at the top, and "export irq" at the top of the separate file. The resulting ROM did not boot.

Then I renamed it, and put a stub in crt0.s:
    jmp myirq

This worked. Can anyone explain why the imported function did not work?
Re: Why must VECTORS be direct?
by on (#190152)
When I see something that won't boot, I usually open the ROM in a debugging emulator and put a breakpoint somewhere. If you suspect that the IRQ handler may be at fault, put the breakpoint at the start of the IRQ handler.

Unfortunately, the most popular debugging emulators use either 32-bit Wine (FCEUX) or Mono (Mesen) rather than Qt, GTK+, or SDL. If you lack the space to install the libraries needed to run 32-bit or CLR executables, you could check the FCEUX (SDL) source code out of FCEUX SVN and add an execution logging feature that writes each executed instruction to a file. Or have you tried building NESICIDE?
Re: Why must VECTORS be direct?
by on (#190153)
The irq handler consists of a single "rti".
Re: Why must VECTORS be direct?
by on (#190155)
In order to guess the cause without access to a debugger, such as a bug that occurs only on hardware and not in a debugging emulator, I would need to see the rti in context. In particular, what is the source of this IRQ? Is it something that needs a few cycles to self-acknowledge? Which mapper is this program using? Or are you instead using the APU Frame Counter IRQ or DMC IRQ, which are built into the CPU? These need to be acknowledged explicitly or they'll just recur.
Re: Why must VECTORS be direct?
by on (#190157)
Well, this was my mistake. When I removed the irq handler from neslib,
irq: rti

I didn't see it was also used as the NMI's end rti, being separated by several newlines from the nmi code. Neslib and its optimized ways, sigh.

So, without its end rti, the NMI continued to random code, reaching a rts, wrapping around the stack and jumping to random places.