nesdev.com
http://forums.nesdev.com/

Why must VECTORS be direct?
http://forums.nesdev.com/viewtopic.php?f=2&t=15593
Page 1 of 1

Author:  calima [ Tue Feb 28, 2017 9:53 am ]
Post subject:  Why must VECTORS be direct?

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:
Code:
irq:
    jmp myirq


This worked. Can anyone explain why the imported function did not work?

Author:  tepples [ Tue Feb 28, 2017 10:07 am ]
Post subject:  Re: Why must VECTORS be direct?

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?

Author:  calima [ Tue Feb 28, 2017 10:17 am ]
Post subject:  Re: Why must VECTORS be direct?

The irq handler consists of a single "rti".

Author:  tepples [ Tue Feb 28, 2017 10:25 am ]
Post subject:  Re: Why must VECTORS be direct?

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.

Author:  calima [ Tue Feb 28, 2017 11:15 am ]
Post subject:  Re: Why must VECTORS be direct?

Well, this was my mistake. When I removed the irq handler from neslib,
Code:
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.

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/