It is currently Wed Nov 14, 2018 2:57 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Thu Nov 08, 2018 11:18 pm 
Offline

Joined: Thu Nov 08, 2018 10:51 pm
Posts: 2
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.


Top
 Profile  
 
PostPosted: Fri Nov 09, 2018 2:37 am 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3676
Location: Mountain View, CA
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.


Top
 Profile  
 
PostPosted: Fri Nov 09, 2018 7:13 pm 
Offline

Joined: Thu Nov 08, 2018 10:51 pm
Posts: 2
Thanks for the information, that really helps. :D


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group