Where to find the instruction pointer in NES roms? Thanks!

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
happymaomao
Posts: 5
Joined: Tue Oct 27, 2009 8:52 am

Where to find the instruction pointer in NES roms? Thanks!

Post by happymaomao » Tue Oct 27, 2009 8:58 am

I've been troubled by this problem a long time. I searched the web and some one said the starting value can be found at 0xfffe. However it's already out of the rom size (the size of rom is only 24k).

So can anyone help to tell me where to find this starting value in roms?

Thanks for your help!!

:D :D

User avatar
Rid
Posts: 66
Joined: Sun May 10, 2009 4:06 am

Post by Rid » Tue Oct 27, 2009 9:22 am

When the guy said you to look à 0xFFFE, I think I was weaning an CPU address and not a ROM offset.

In other word, just look at the adresse $FFFE in debug mode, when playing your ROM with FCEUXD SP :)

happymaomao
Posts: 5
Joined: Tue Oct 27, 2009 8:52 am

Post by happymaomao » Tue Oct 27, 2009 9:26 am

Thx, my friend~! I took it wrongly.

If the PRG rom is only 16k, it would be saved at both $8000 and $c000

So I can find the instruction pointer at $FFFE.

However, I saw some of the code do this at $FFFC. Is there any difference between these two ways?

Thanks again!!

User avatar
Rid
Posts: 66
Joined: Sun May 10, 2009 4:06 am

Post by Rid » Tue Oct 27, 2009 9:35 am

I'm not an expert but I think that the CPU reserved three adresses :
$FFFA : NMI vector - address to go when NMI (Non Maskable Interrupt) occurs
$FFFC : RESET vector - address to go when starting or resetting the NES
$FFFE : IRQ/BRK vector - don't know when it is useful

Anyway, you shall look at the Nesdev Wiki to find your answer, and more specifically here to see the NES architecture.

happymaomao
Posts: 5
Joined: Tue Oct 27, 2009 8:52 am

Post by happymaomao » Tue Oct 27, 2009 9:38 am

Thanks my friend. Thanks for your patience. :-}

Two great helpful pages!!

Thanks again!

User avatar
Zepper
Formerly Fx3
Posts: 3192
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post by Zepper » Tue Oct 27, 2009 3:06 pm

- Nope. Firstly, you must know the mapper number and which PRG banks are loaded at CPU 8000-FFFF on startup. Once you know the PRG number at E000-FFFF (an 8k page), so yes, use FFFC and FFFD as the RESET address, or entry point as you asked.

User avatar
Rid
Posts: 66
Joined: Sun May 10, 2009 4:06 am

Post by Rid » Tue Oct 27, 2009 4:41 pm

As the game has only 16Ko of PRG, I thought there was no mapper...

tepples
Posts: 21841
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples » Tue Oct 27, 2009 5:05 pm

If the PRG ROM is 16 KiB, then I'm 99% sure the board is NROM. But check bits 7-4 of bytes 6 and 7 of the header to be sure.

happymaomao
Posts: 5
Joined: Tue Oct 27, 2009 8:52 am

Post by happymaomao » Wed Oct 28, 2009 8:12 am

The size of rom is only 24k, and here is the header
78 69 83 26 1 1 0 0 0 0 0 0 0 0 0 0

So, I think no mapper.. :oops:

I just want to start with a simple rom so I use battle city as it. ^__^

tepples
Posts: 21841
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples » Wed Oct 28, 2009 8:44 am

happymaomao wrote:The size of rom is only 24k, and here is the header
78 69 83 26 1 1 0 0 0 0 0 0 0 0 0 0
78 69 83 26: Present at start of all headers
1: 1*16384 byte PRG
1: 1*8192 byte CHR
0 0: If both of these are under 16, you're right that you have a board with no mapper, such as NROM.

happymaomao
Posts: 5
Joined: Tue Oct 27, 2009 8:52 am

Post by happymaomao » Wed Oct 28, 2009 8:53 am

Thanks tepples :D

I'm just a newbie of emu but loving NES very much. So I determine to implment a simple NES emulator using java. I may get lots of questions future. Thanks for helps from every superior in advanced.

^___^

Post Reply