It is currently Sun Oct 22, 2017 6:53 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: No00b Questions
PostPosted: Thu Nov 17, 2005 2:58 pm 
Offline

Joined: Thu Nov 17, 2005 2:44 pm
Posts: 34
As you all probably have figured I'm writing an NES emulator (as a personal learning project). I haven't gotten very far and I've already run into a possible hitch.

You should know I'm using nestest.nes as my test ROM. My emulator currently loads the PRG-ROM data into address $8000 (and again into $C000 for ROMs with one bank of PRG-ROM, if I'm wrong on that please let me know) and I set the program counter to begin executing at $8000 (also unsure on that point). I disassembled nestest, using NES DeCompose and another NES disassembler, to see if I was interpreting instructions correctly. Both disassemblers came back with different results.

The first three bytes of nestest are 4C F5 C5 which I would interpert as JMP #C5F5. NES decompose has these on .db line while the other disassembler has JMP #C5F5 preceeded by a bunch of other stuff. Which one is right and how would I tell? Am I right by setting to execute at $8000? Are there other instructions that need to be executed (BIOS) before running ROM data? I hope all that made sense because I've never done any programming this low-level (which is why I'm doing this). Thanks for any kind of help you can provide :-)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 3:10 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19115
Location: NE Indiana, USA (NTSC)
The Famicom has no BIOS.

But on the Famicom, NES, Atari 2600, Commodore 64, Apple II, or any other 6502 based system, you don't just start running at $8000. Instead, always execute the instruction JMP ($FFFC) first.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 4:17 pm 
Offline

Joined: Thu Nov 17, 2005 2:44 pm
Posts: 34
Okay, I adjusted to start program execution at $FFFC (unless the JMP instruction is imperitive) and it came back with opcode 4 which is non-existant (at least according the doc I'm looking at). Am I doing something wrong or is my documentation incomplete?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 4:59 pm 
You start executing at the address pointed to by $FFFC-FFFD. $FFFC is the least significant byte of the starting address, and $FFFD is the most significant byte of the starting address. For example, if $FFFC has the value $5A and $FFFD has the value $C3, you would start executing at address $C35A.


Top
  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 5:09 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19115
Location: NE Indiana, USA (NTSC)
Correct. That's the difference between JMP $FFFC (absolute address, and not what you want) and JMP ($FFFC) (absolute-indirect address, which is close to what the NES does on reset).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 17, 2005 11:49 pm 
Offline

Joined: Thu Nov 17, 2005 2:44 pm
Posts: 34
Ah, so that's what the parenthesis mean. Thanks a bunch. It seems the proper command would be SEI, then.


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 6 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