It is currently Mon Oct 23, 2017 4:53 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Jan 09, 2013 4:24 am 
Offline
User avatar

Joined: Fri Dec 14, 2012 5:58 am
Posts: 5
Location: Australia
This question is similar to my earlier question. It'd be good to read it for some background on this one.

I've gotten stuck at another instruction in nestest.nes which doesn't seem to work in my implementation as per the sample nestest.nes output.

That instruction is 0xCFF2. It's meant to load the Accumulator with 0xFD, pulled from 0x400. From my understanding, my emulator should read bytes at 0xFF (the instruction's operand) and 0x100 (it's a 16bit read, so the following byte to 0xFF), then combine the bytes there to get a 16bit address, which should be 0x400. In my implementation, it is pulling out 0xFF00, the lower byte being correct, but the high one being incorrect (I set all memory to 0xFF on initial start up). It's worth noting in my emulator, the address 0x400 does contain the right piece of memory (0xFD).

I've logged as much as I can, but only found two writes to memory with the value 0x4, which are short lived stack write and a write to 0x0, which doesn't seem to be relevant. I've also tried to step through as much of the instructions by hand as possible, trying to figure out what I'm missing.

Is anyone able to point out where 0x4 is written to 0x100, or what I may have done wrong? Thanks.


Top
 Profile  
 
PostPosted: Wed Jan 09, 2013 6:31 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19116
Location: NE Indiana, USA (NTSC)
Indirect addressing modes involving zero page, such as (d,X) and (d),Y modes, wrap within $00xx instead of overflowing to the stack. Are you taking that into account?


Top
 Profile  
 
PostPosted: Thu Jan 10, 2013 3:39 am 
Offline
User avatar

Joined: Fri Dec 14, 2012 5:58 am
Posts: 5
Location: Australia
Of course! Why didn't I think of that? Then the next read at 0x0 would indeed grab the correct value.

Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group