.NES to .ASM (Help)
Moderator: Moderators
.NES to .ASM (Help)
Hi guys,
I'm seeking for help because I made a big mistake. Long story short, I was using NESASM Assembly to make a NES game and I accidentally deleted for good my .ASM file (I was deleting a bunch of stuff for clarity & same with my bin however I had put it in... such a rookie mistake).
I often compiled so I have a .NES of my advancements. Is there any way that I could retrieve my .ASM from that .NES ?
Thanks,
I'm seeking for help because I made a big mistake. Long story short, I was using NESASM Assembly to make a NES game and I accidentally deleted for good my .ASM file (I was deleting a bunch of stuff for clarity & same with my bin however I had put it in... such a rookie mistake).
I often compiled so I have a .NES of my advancements. Is there any way that I could retrieve my .ASM from that .NES ?
Thanks,
Re: .NES to .ASM (Help)
A disassembler. None of which export to NESASM syntax.
I like frantik's disasm6.
Also available is da65, which comes with cc65.
I like frantik's disasm6.
Also available is da65, which comes with cc65.
nesdoug.com -- blog/tutorial on programming for the NES
- rainwarrior
- Posts: 8732
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: .NES to .ASM (Help)
You can use a disassembler to recover some of the assembly code:
https://wiki.nesdev.com/w/index.php/Tools#Disassemblers
Unfortunately, all the label and variable names can't be recovered, because they are discarded when assembled into the .NES file.
If you can remember some of the names, with some disassemblers there is a way to feed your reconstructed labels and their addresses to the disassembler so it can apply them instead of just giving a number instead. You'll probably need to do this in several passes. Something like this:
1. Run disassembler.
2. Look for anonymous addresses, and think about what name they used to have.
3. Add address names to the list.
4. Repeat 1 until you've added everything you can manage.
You'll also need to tell the disassembler what parts are code, and what parts are just data, otherwise the data parts will come out as nonsense instructions. With most disassemblers that's done through a similar mechanism as giving it labels.
(Not sure which disassembler to suggest, but I like da65 that comes with the cc65 tools.)
https://wiki.nesdev.com/w/index.php/Tools#Disassemblers
Unfortunately, all the label and variable names can't be recovered, because they are discarded when assembled into the .NES file.
If you can remember some of the names, with some disassemblers there is a way to feed your reconstructed labels and their addresses to the disassembler so it can apply them instead of just giving a number instead. You'll probably need to do this in several passes. Something like this:
1. Run disassembler.
2. Look for anonymous addresses, and think about what name they used to have.
3. Add address names to the list.
4. Repeat 1 until you've added everything you can manage.
You'll also need to tell the disassembler what parts are code, and what parts are just data, otherwise the data parts will come out as nonsense instructions. With most disassemblers that's done through a similar mechanism as giving it labels.
(Not sure which disassembler to suggest, but I like da65 that comes with the cc65 tools.)
Re: .NES to .ASM (Help)
Bisqwit's nescom includes clever-disasm which will automatically do its best to trace execution and distinguish between data and code. I've found that it does a pretty good job... but you're still not getting names out of it.
Re: .NES to .ASM (Help)
https://wiki.nesdev.com/w/index.php/Tools#Disassemblers may help you. Another (interactive) disassembly not mentioned there is is IDA Pro, but it's commercial and *very* expensive.
YMMV with every single disassembler listed there. Do not expect any of them to give you "original source" quality of output -- you will be expected to do a lot of clean-up (and fix many, many, many mistakes -- particularly for data vs. code) yourself; the simpler the game and mapper, the better (i.e. if your game was NROM with basic CHR-ROM, you should be able to get some tolerable code back, enough to let you rebuild stuff from scratch probably within a few hours of dedication). Whether or not it's better than starting over from scratch varies per project/game/thing.
I do not share lidnariq's opinion of clever-disasm, and I spent several hours with it, plus poked Bisqwit about it (WRT bugs/issues I found), but I was also working on a highly complex and large (256KB) commercial MMC1 title. I do like disasm6, but it has problems/quirks too (I've discussed those with franktik in PM recently). That is all I'm going to say because don't want to off-topic the thread. The point is that the tool may vary for the job, and everyone has their own opinion/preference as to what they like (I'm probably the odd man out in the sense that I don't really like any of them, and I even wrote one ;-) ).
YMMV with every single disassembler listed there. Do not expect any of them to give you "original source" quality of output -- you will be expected to do a lot of clean-up (and fix many, many, many mistakes -- particularly for data vs. code) yourself; the simpler the game and mapper, the better (i.e. if your game was NROM with basic CHR-ROM, you should be able to get some tolerable code back, enough to let you rebuild stuff from scratch probably within a few hours of dedication). Whether or not it's better than starting over from scratch varies per project/game/thing.
I do not share lidnariq's opinion of clever-disasm, and I spent several hours with it, plus poked Bisqwit about it (WRT bugs/issues I found), but I was also working on a highly complex and large (256KB) commercial MMC1 title. I do like disasm6, but it has problems/quirks too (I've discussed those with franktik in PM recently). That is all I'm going to say because don't want to off-topic the thread. The point is that the tool may vary for the job, and everyone has their own opinion/preference as to what they like (I'm probably the odd man out in the sense that I don't really like any of them, and I even wrote one ;-) ).
Re: .NES to .ASM (Help)
Several years ago, I used da65, part of the cc65 suite, to recover my DPCM Split demo after a laptop died.
Re: .NES to .ASM (Help)
Heh I wonder if this guy's story is legit, or if he's just trying to hack something copyrighted.
Not that I care. Hope you figure it out.
Not that I care. Hope you figure it out.
Re: .NES to .ASM (Help)
Does NESASM not output a debug file with all the labels and such?
ca65's .dbg file is super useful, especially wih Mesen's label import feature - feels like a complete disassembly of my project (though it can be pretty funny with reused ZP variables)
ca65's .dbg file is super useful, especially wih Mesen's label import feature - feels like a complete disassembly of my project (though it can be pretty funny with reused ZP variables)
Re: .NES to .ASM (Help)
Like with most (but not all) assembers, such file generation (equates/labels, symbols, and/or a listing) is usually not the default for performance reasons.Sumez wrote:Does NESASM not output a debug file with all the labels and such?
For nesasm 2.x and 3.x, use of the -l (dash-lowercase-ELL) flag or pseudo-op LIST in source will generate a listings file, and -s (basic info) or -S (more info) will display ROM layout/bank usage details (possibly to stdout, not sure).
Re: .NES to .ASM (Help)
Have you tried the "Source View" mode? (Right-click on code window -> Switch to source view)Sumez wrote:feels like a complete disassembly of my project (though it can be pretty funny with reused ZP variables)
This will load up your assembly source files into Mesen's debugger and allow you to debug using them rather than the disassembly (which as you say, ends up randomly one of the labels defined for any memory address).
Re: .NES to .ASM (Help)
Jesus christ, sour, your work keeps amazing me. :O
Re: .NES to .ASM (Help)
Sumez wrote:Jesus christ, sour, your work keeps amazing me. :O
Thanks! ... And I guess this means that this particular feature could really use a bit more visibility beyond a right-click option in the code window.yaros wrote:Omg, Sour. Did I tell you that you are great and Mesen is amazing?
Not at the moment, but being an abusive user of Ctrl+T myself (can't remember the last time I looked at the project tree to find a file), that's definitely something that would be worth implementing. Could also be used to navigate to a label's definition, too (rather than just limiting it to file names)yaros wrote:Is there a keystroke like Ctrl+T (Visual Studio 2017) or Ctrl-P (Visual Studio Code) to type file name instead of using mouse?
Re: .NES to .ASM (Help)
We are derailing the thread
@sour
only asm code can be mapped in the viewer, right? Now that I'm using a mix of the 2 and didn't know about that feature, I want to see how I can use it.
@sour
only asm code can be mapped in the viewer, right? Now that I'm using a mix of the 2 and didn't know about that feature, I want to see how I can use it.
Re: .NES to .ASM (Help)
Both C and assembly files should work, although it can be somewhat unintuitive to step through the C code (since you'll have to step multiple times to reach the next statement, etc) and there is no syntax highlighting, etc.Banshaku wrote:only asm code can be mapped in the viewer, right? Now that I'm using a mix of the 2 and didn't know about that feature, I want to see how I can use it.
Re: .NES to .ASM (Help)
Edit: I'm not a spambot. The question mark blocks in SMB are 16*16 pixels.
Have you tried a file recovery program (like Recuva)?skillZz wrote:accidentally deleted