It is currently Wed Dec 13, 2017 6:19 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: 6502 PLA Test Problem
PostPosted: Sun Jan 13, 2013 5:44 pm 
Offline

Joined: Sun Jan 13, 2013 5:35 pm
Posts: 23
Hello guys, I'm working on a NES emulator. I'm now testing my implementation of the 6502 CPU and I'm using nestest (and the log from nintendulator) but I have a problem with the stack that I can't figure out. Please check this out guys:

Code:
C7E5  78        SEI                             A:00 X:00 Y:00 P:67 SP:FB CYC:181 SL:242
C7E6  F8        SED                             A:00 X:00 Y:00 P:67 SP:FB CYC:187 SL:242
C7E7  08        PHP                             A:00 X:00 Y:00 P:6F SP:FB CYC:193 SL:242
C7E8  68        PLA                             A:00 X:00 Y:00 P:6F SP:FA CYC:202 SL:242
C7E9  29 EF     AND #$EF                        A:7F X:00 Y:00 P:6D SP:FB CYC:214 SL:242               7F  ?????????????
C7EB  C9 6F     CMP #$6F                        A:6F X:00 Y:00 P:6D SP:FB CYC:220 SL:242


What the hell? I can't figure out why the accumulator is at 7F. My emulator pulls out "6F".

With PHP, the cpu pushes the flag byte (6F) into the stack. With PLA the cpu pulls that byte "6F" from the stack... :/ Guys am I'm missing something? I tried to run some test code here: "http://skilldrick.github.com/easy6502/" to simulate my problem, and it also pulls 7F.

From where is the "7" comming from? I can't figure it out, really. :/

Thank you guys!


Top
 Profile  
 
PostPosted: Sun Jan 13, 2013 5:54 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19335
Location: NE Indiana, USA (NTSC)
One thing that BRK and PHP do that /IRQ and /NMI don't is that BRK and PHP push the value of P OR #$10. In fact, that's the only way a program can tell a BRK from /IRQ.

THIS ARTICLE WILL BE FLAGGED


Top
 Profile  
 
PostPosted: Sun Jan 13, 2013 5:59 pm 
Offline

Joined: Sun Jan 13, 2013 5:35 pm
Posts: 23
Oh thank you so much! Couldn't find that info anywhere else, thanks a lot!! :)


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 5 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