6502 PLA Test Problem

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
miguelfsp
Posts: 23
Joined: Sun Jan 13, 2013 5:35 pm

6502 PLA Test Problem

Post by miguelfsp » Sun Jan 13, 2013 5:44 pm

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: Select all

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!

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

Re: 6502 PLA Test Problem

Post by tepples » Sun Jan 13, 2013 5:54 pm

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

miguelfsp
Posts: 23
Joined: Sun Jan 13, 2013 5:35 pm

Re: 6502 PLA Test Problem

Post by miguelfsp » Sun Jan 13, 2013 5:59 pm

Oh thank you so much! Couldn't find that info anywhere else, thanks a lot!! :)

Post Reply