Nestest Accumulator missmatch

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
realoS
Posts: 3
Joined: Wed Jan 11, 2023 9:07 am

Nestest Accumulator missmatch

Post by realoS »

Hello,

I'm developing a nes emulator in c++ and recently finished my Cpu emulation.I tried running nestest in Automation mode and got it to the point where it hit the last intruction, but still has Error code 15 in $2, And when looking at the logs in winmerge i saw that the accumulator is different from the known good log, starting at ce1e.(I formatted both logs because i didn't want to adjust the logging for each intruction adding "XX XX LDA $XX")
Capture.PNG
This is because the Lda instruction loads a value from $0180 (a stack adress) which i verified in the debugger is zero at the time of execution. Now i can't figure out why because i already checked all the stack instructions before it and they all seem fine.

Has anyone else had a similar issue, or know what might solve this problem?
User avatar
Quietust
Posts: 1920
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: Nestest Accumulator missmatch

Post by Quietust »

realoS wrote: Wed Jan 11, 2023 9:20 am This is because the Lda instruction loads a value from $0180 (a stack adress) which i verified in the debugger is zero at the time of execution.
But it shouldn't be zero, because at address $CE06 (which is a PHA instruction) it gets set to #$33 (because A=$33 and SP=$80).
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.
realoS
Posts: 3
Joined: Wed Jan 11, 2023 9:07 am

Re: Nestest Accumulator missmatch

Post by realoS »

Yes, but for me it gets pulled of the stack at $CE14 (which happens in the nestest log to) before it can be loaded into the accumulator at $CE1E. This is how the stack looks after pushing the $33 to $0180 at $CE06(numbers in decimal):
stack.png
is it supposed to look like that? Unfortunately nestest doesn't provide a log of the stack at every cycle, so i can't really check.
Joe
Posts: 650
Joined: Mon Apr 01, 2013 11:17 pm

Re: Nestest Accumulator missmatch

Post by Joe »

Pulling a value from the stack doesn't change the contents of the stack memory.
realoS
Posts: 3
Joined: Wed Jan 11, 2023 9:07 am

Re: Nestest Accumulator missmatch

Post by realoS »

thanks i didn't know that, that fixed my problem!
Post Reply