No00b Questions

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
dxprog
Posts: 34
Joined: Thu Nov 17, 2005 2:44 pm

No00b Questions

Post by dxprog »

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 :-)
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

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.
dxprog
Posts: 34
Joined: Thu Nov 17, 2005 2:44 pm

Post by dxprog »

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?
Guest

Post by Guest »

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.
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

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).
dxprog
Posts: 34
Joined: Thu Nov 17, 2005 2:44 pm

Post by dxprog »

Ah, so that's what the parenthesis mean. Thanks a bunch. It seems the proper command would be SEI, then.
Post Reply