It is currently Sun Oct 22, 2017 1:53 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Tue Feb 28, 2017 9:53 am 
Offline

Joined: Tue Oct 06, 2015 10:16 am
Posts: 558
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?


Top
 Profile  
 
PostPosted: Tue Feb 28, 2017 10:07 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19115
Location: NE Indiana, USA (NTSC)
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?


Top
 Profile  
 
PostPosted: Tue Feb 28, 2017 10:17 am 
Offline

Joined: Tue Oct 06, 2015 10:16 am
Posts: 558
The irq handler consists of a single "rti".


Top
 Profile  
 
PostPosted: Tue Feb 28, 2017 10:25 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19115
Location: NE Indiana, USA (NTSC)
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.


Top
 Profile  
 
PostPosted: Tue Feb 28, 2017 11:15 am 
Offline

Joined: Tue Oct 06, 2015 10:16 am
Posts: 558
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group