When called as a subroutine (
JSR $C000), nestest needs a bit of setup first:
- 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. - 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. - 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.