nestest question - DCP Illegal opcode

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
teaguecl
Posts: 211
Joined: Thu Oct 21, 2004 4:02 pm
Location: San Diego

nestest question - DCP Illegal opcode

Post by teaguecl »

I'm having a tough time running nestest. If I just load it and run, it reports all OK on both sets of tests. However, if I force it to start at $C000 as the documentation indicates for automation - it crashes with an illegal opcode 0x32. I tried running it in Nintendulator and forcing it to start at $C000 using the debugger and it spits out lots of errors, and eventually halts the cpu. Has anyone else had that problem?

Any advice on why running nestest from C000 doesn't seem to work on Nintendulator? I also ran it on Nestopia with weird results. It beeped once (I assume that's the success indicator) but didn't show anything on the screen (which is probably normal?). However, it then hung and had to be force killed.
User avatar
Quietust
Posts: 1920
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: nestest question - DCP Illegal opcode

Post by Quietust »

If you run nestest by starting at $C000, it crashes at the end by underflowing the stack - for whatever reason, it ends with an (unmatched) RTS instruction rather than an infinite loop.
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: nestest question - DCP Illegal opcode

Post by tepples »

When called as a subroutine (JSR $C000), nestest needs a bit of setup first:
  1. The stack pointer needs to be set to a reasonable value (e.g. $F0-$FF).
    Otherwise, you may experience undefined behavior during the stack test.
  2. The emulator needs to detect when the test has completed, by either loading a special return address onto the stack before jumping to $C000 or comparing the stack pointer after each instruction.
    Otherwise, you will experience undefined behavior once the test completes and underflows the stack, as Quietust mentioned.
  3. To run the last third of the test, the emulator needs to support the most predictable unofficial opcodes.
    Otherwise, you will experience undefined behavior once that portion of the test begins.
User avatar
teaguecl
Posts: 211
Joined: Thu Oct 21, 2004 4:02 pm
Location: San Diego

Re: nestest question - DCP Illegal opcode

Post by teaguecl »

Thank you so much for the assistance. To stop nestest when it's done I simply put a breakpoint at C66E which seems to work fine. I am still seeing behavior that I can't understand - maybe I'm not using the test rom correctly?
My emulator currently does not support opcode 0xE7 (ISB/ISC) and it will crash if it tries to execute one. Not surprisingly, when I run nestest in automation (starting from 0xC000) my emulator crashes on opcode E7. However, if I run nestest normally it runs fine and reports OK for everything. Specifically I select "Run all tests" from the main screen and get all OK. Then I press SELECT to get to the "Invalid Ops!" menu and again select "Run all tests" which tells me all those are OK. It never executes an opcode E7 during either suite of tests.

Am I missing something, or does nestest do a different set of tests when run from C000 than can be done manually? If so, that is definitely not mentioned in it's documentation.
Post Reply