using nes test ROM to test 6502 CPU

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
Posts: 1
Joined: Fri Feb 14, 2020 9:00 am

using nes test ROM to test 6502 CPU

Post by LuckyLuke » Fri Feb 14, 2020 9:09 am

Hi, I'm writing my own NES emulator in C++, trying to make it work on Windows and (if all goes well) I'll port it to some MCU platform (AVR/Microchip or ARM). I'm doing this as a learning experience.

I wrote the CPU part, and I'm using nestest.nes to test the instructions, but I don't have graphics capabilities as of now so I just shoved the ROM contents at address 0x8000 and 0xC000 of my RAM array, and reset the PC to 0xC000.

For each instruction I log the status of my CPU (registers and all) and I compare it to a log that I found on the internet. Everything goes fine (I already spent a few hours debugging instructions and/or addressing modes), but then I arrive at invalid opcodes (opcodes representing undocumented operations), program counter is at 0xC6BD (I think I'm more than halfway through the test).
Now I don't know how to go on. I don't want to spend time on the PPU implementation unless I'm certain that my CPU works fine, so what should I do now?

Thanks a lot for your help, I hope my question is correct and that someone here can help me out!


Posts: 21839
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)

Re: using nes test ROM to test 6502 CPU

Post by tepples » Fri Feb 14, 2020 1:24 pm

Starting at $C6BD, nestest.nes indeed tests the behavior of those unofficial 6502 instructions that are stable. However, only about a dozen pre-1997 licensed and unlicensed games rely on them. If you're that far, you can stop and begin the PPU if you wish.

Further reading: CPU unofficial opcodes; Programming with unofficial opcodes

Post Reply