Question about Nintendulator log file for nestest.rom

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Question about Nintendulator log file for nestest.rom
by on (#228672)
Hi I have been trying to develop a nes emulator for fun and I'm working on the CPU currently. I'm using the nestest.nes file and comparing against the log from Nintendulator (http://www.qmtpro.com/~nes/misc/nestest.log). I know a lot of others have also used this for testing, but I'm stuck on a few lines of the log file and I'm not seeing what I'm doing wrong.

C7E7 08 PHP A:00 X:00 Y:00 P:6F SP:FB CYC:193
C7E8 68 PLA A:00 X:00 Y:00 P:6F SP:FA CYC:202
C7E9 29 EF AND #$EF A:7F X:00 Y:00 P:6D SP:FB CYC:214
C7EB C9 6F CMP #$6F A:6F X:00 Y:00 P:6D SP:FB CYC:220

From my understanding the instruction at C7E7 pushes the processor status (6F) into the stack, then C7E8 pulls this value into the accumulator (i.e. A = 6F, but I assume the 00 value shown for A is from before this instruction is executed). Then C7E9 does a logical AND between 6F & EF (which is 6F). My question is this: why does the Nintendulator log file show an accumulator value 7F? No one else seems to have this issue so I must be wrong, but I can't figure out where.
Re: Question about Nintendulator log file for nestest.rom
by on (#228675)
1. You are correct that the values shown in registers are what are contained *before* the instruction is executed.

2. The explanation for bits 5 and 4 are described here (read, don't skim): https://wiki.nesdev.com/w/index.php/Sta ... The_B_flag

If it's not clear to you: $6f = %01101111 while $7f = %01111111 -- the difference in this case is bit 4 (the "5th bit"), or the B flag, and said link should make it clear why. It should also help explain how to properly implement how those bits, as well as other bits in P, are affected by certain instructions, vs. IRQ vs. NMI. You'll probably learn a few other things while reading that section.

Hope this helps.
Re: Question about Nintendulator log file for nestest.rom
by on (#228681)
Thanks for the information, that really helps. :D