Question about nestest.nes and zeropage,x indirect

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
arcnor
Posts: 2
Joined: Mon Oct 08, 2018 4:47 pm

Question about nestest.nes and zeropage,x indirect

Post by arcnor » Mon Oct 08, 2018 4:56 pm

Hello,

I'm developing a NES emulator, and I've been using nestest.nes to do so. I've hit a roadblock with one of the instructions. I'll post what I think are the relevant instructions from the Nintendulator nestest.nes log and will expose my problem after that:

Code: Select all

// After this runs, $0200 will contain #$5A
CFC7  STA $0200 = 00                  A:5A X:55 Y:69 P:25 SP:FB
...
// After this runs, $5A will contain #$AA
D009  STA ($80,X) @ 80 = 0200 = 5A    A:AA X:00 Y:69 P:26 SP:FB
...
// After this runs, A will contain #$AA
D01C  LDA $0200 = AA                  A:AD X:00 Y:69 P:A4 SP:FB
My problem is that I don't see how the last opcode changes A to #$AA. According to that log, the location $200 contains #$5A instead, and there are no other instructions that I can see between $CFC7 and $D01C that modify $0200. #$AA is contained in $5A from what I see, not on $0200.

What am I missing?

Thanks in advance.

lidnariq
Posts: 10273
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Question about nestest.nes and zeropage,x indirect

Post by lidnariq » Mon Oct 08, 2018 5:15 pm

arcnor wrote:D009 STA ($80,X) @ 80 = 0200 = 5A A:AA X:00 Y:69 P:26 SP:FB
That means that:
$80+X is $80
The pointer in memory at $80 and $81 is $0200
The value at $0200 is $5A before the instruction runs
A is still stored to $0200 after.

arcnor
Posts: 2
Joined: Mon Oct 08, 2018 4:47 pm

Re: Question about nestest.nes and zeropage,x indirect

Post by arcnor » Mon Oct 08, 2018 10:28 pm

Ah, so I had one more indirect than needed, that makes sense now :)

Thanks!

Post Reply