Question about Nintendulator log file for nestest.rom

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
cbalen
Posts: 2
Joined: Thu Nov 08, 2018 10:51 pm

Question about Nintendulator log file for nestest.rom

Post by cbalen » Thu Nov 08, 2018 11:18 pm

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.

User avatar
koitsu
Posts: 4218
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Question about Nintendulator log file for nestest.rom

Post by koitsu » Fri Nov 09, 2018 2:37 am

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.

cbalen
Posts: 2
Joined: Thu Nov 08, 2018 10:51 pm

Re: Question about Nintendulator log file for nestest.rom

Post by cbalen » Fri Nov 09, 2018 7:13 pm

Thanks for the information, that really helps. :D

Post Reply