How to Best Disassemble NES PRG-ROM

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

Post Reply
snazzyhoppy
Posts: 10
Joined: Tue Aug 27, 2013 3:12 pm
Contact:

How to Best Disassemble NES PRG-ROM

Post by snazzyhoppy »

Currently I am disassembling the PRG-ROM data of an NES ROM file by reading the file in a hex editor, pasting the values into a text editor, and using a table of 6502 operands to translate the values into the corresponding 6502 instructions. The results appear accurate, but it takes a long time even when starting out with NROM games.

an example:
20 20 C1 = jsr $C120
A9 00 = lda #$00

What disassembly programs are available that might speed this up a bit? I don't mind tweaking the output a little bit if the results aren't 100% accurate. Besides data tables, disassembly is fairly straightforward going sequentially from one instruction to the next. I would prefer a program that can output to a text file or ideally a file that can be used with one of the available NES assemblers.

If there is a better approach to NES disassembly, please direct me. Thanks in advance for any suggestions.
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: How to Best Disassemble NES PRG-ROM

Post by rainwarrior »

FCEUX will let you create a code-data log that maps which part of a ROM are data and which are code. Turn on logging, and play through the game to map as much of the code/data as you can.

Next use a disassembler (e.g. da65) to do the actual disassembly, don't translate it by hand except where you have to. What I like to do is create an disassembly info file for da65, starting with information from the code-data log, but then slowly add labels to it as I figure out what various bits of code are for. Every time I add a few labels, I re-disassemble to have those labels appear in the disaasembly. Eventually I end up with something pretty comprehensive, at which point I might stop messing with da65 and just hand-edit the disassembly file until it looks nice.

I have an example here, from my last disassembly project, if it helps: http://rainwarrior.ca/projects/nes/star ... ic_fix.zip
User avatar
Movax12
Posts: 541
Joined: Sun Jan 02, 2011 11:50 am

Re: How to Best Disassemble NES PRG-ROM

Post by Movax12 »

You could also load the ROM into YY-CHR and pan through the data to see if anything looks like graphics. This would only apply to games that use CHR RAM in the case of the NES, but this helped me a lot on a non-NES disassembly.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: How to Best Disassemble NES PRG-ROM

Post by lidnariq »

Bisqwit's project nescom contains "clever-disasm", which is a tracing disassembler. It does a nice job, and can use a configuration file that allows you to hand-guide it through the places it can't figure out.

There's also "disasm6", which is uses FCEUX's CDL files, but doesn't handle PRG banking. (But that means it's fine for NROM, CNROM, and the 32 KiB MMC1 games)
Post Reply