Where is 0x180 set to 33 on nestest.nes?

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Where is 0x180 set to 33 on nestest.nes?
by on (#104682)
I have been developing a NES-flavoured 6502 emulator.

For testing, I've been using the nestest.nes program and comparing it to sample output.

This has been working fine (I programatically check the state every instruction and compare it to the sample output) up until the 862th instruction, where the PC is at 0xCE1E. The problem is, when pulling the accumulator from memory address 0x180, I always get 0xFF (which I set most of the memory to at the beginning). The value I'm expecting is 0x33 as per the sample output (the previous value of A too).

At first, I thought it must have been because I hadn't implemented memory mirroring (because I found 0x80 to be set to 0x33). So I set up my memory writes to also write to the specified offsets. This unfortunately did not solve my problem.

So I'm wondering, in the instructions from 0xC000 - 0xCE1E, where is 0x180 set to 0x33? I have spent days trying to find this out.

Obviously, I'm quite new to emulation.

Can anyone help me out? Thanks
Re: Where is 0x180 set to 33 on nestest.nes?
by on (#104683)
alexwy wrote:
So I'm wondering, in the instructions from 0xC000 - 0xCE1E, where is 0x180 set to 0x33? I have spent days trying to find this out.

Code:
CE01  A2 80     LDX #$80                        A:FF X:FB Y:01 P:A5 SP:FB CYC: 32 SL:258
CE03  9A        TXS                             A:FF X:80 Y:01 P:A5 SP:FB CYC: 38 SL:258
CE04  A9 33     LDA #$33                        A:FF X:80 Y:01 P:A5 SP:80 CYC: 44 SL:258
CE06  48        PHA                             A:33 X:80 Y:01 P:25 SP:80 CYC: 50 SL:258
Re: Where is 0x180 set to 33 on nestest.nes?
by on (#104684)
Thanks for your reply.

Please bear with me as I'm not understanding the code quoted.

If you're referring to:

Code:
CE04  A9 33     LDA #$33                        A:FF X:80 Y:01 P:A5 SP:80 CYC: 44 SL:258


Then, isn't that just loading the accumulator with literal 0x33. The next instruction:

Code:
CE06  48        PHA                             A:33 X:80 Y:01 P:25 SP:80 CYC: 50 SL:258


Then pushes that accumulator value (0x33) onto the stack at location 0x80 right?

So, if it's placed the value at 0x80, it means I can't be read it at 0x180 (at least, to my understanding).

I'm sure I'm missing something. so please point me where I'm missing it.

Thanks again.
Re: Where is 0x180 set to 33 on nestest.nes?
by on (#104685)
alexwy wrote:
please point me where I'm missing it.

The stack is always at $0100-$01FF, the SP is just the low byte.
Re: Where is 0x180 set to 33 on nestest.nes?
by on (#104686)
Thank you, I didn't know that. :D