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

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
alexwy
Posts: 5
Joined: Fri Dec 14, 2012 5:58 am
Location: Australia
Contact:

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

Post by alexwy » Fri Dec 14, 2012 6:19 am

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

User avatar
thefox
Posts: 3141
Joined: Mon Jan 03, 2005 10:36 am
Location: Tampere, Finland
Contact:

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

Post by thefox » Fri Dec 14, 2012 6:26 am

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

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
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi

alexwy
Posts: 5
Joined: Fri Dec 14, 2012 5:58 am
Location: Australia
Contact:

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

Post by alexwy » Fri Dec 14, 2012 6:35 am

Thanks for your reply.

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

If you're referring to:

Code: Select all

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

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.

User avatar
tokumaru
Posts: 11521
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

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

Post by tokumaru » Fri Dec 14, 2012 6:50 am

alexwy wrote:please point me where I'm missing it.
The stack is always at $0100-$01FF, the SP is just the low byte.

alexwy
Posts: 5
Joined: Fri Dec 14, 2012 5:58 am
Location: Australia
Contact:

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

Post by alexwy » Fri Dec 14, 2012 6:52 am

Thank you, I didn't know that. :D

Post Reply