It is currently Sun May 26, 2019 3:15 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: .NES to .ASM (Help)
PostPosted: Tue Dec 11, 2018 5:24 pm 
Offline

Joined: Tue Dec 11, 2018 5:13 pm
Posts: 1
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,


Top
 Profile  
 
 Post subject: Re: .NES to .ASM (Help)
PostPosted: Tue Dec 11, 2018 5:43 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 2510
Location: DIGDUG
A disassembler. None of which export to NESASM syntax.

I like frantik's disasm6.

Also available is da65, which comes with cc65.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
 Post subject: Re: .NES to .ASM (Help)
PostPosted: Tue Dec 11, 2018 5:45 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 7467
Location: Canada
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.)


Top
 Profile  
 
 Post subject: Re: .NES to .ASM (Help)
PostPosted: Tue Dec 11, 2018 5:55 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 8372
Location: Seattle
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.


Top
 Profile  
 
 Post subject: Re: .NES to .ASM (Help)
PostPosted: Tue Dec 11, 2018 8:28 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 4077
Location: A world gone mad
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 ;-) ).


Top
 Profile  
 
 Post subject: Re: .NES to .ASM (Help)
PostPosted: Tue Dec 11, 2018 8:58 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 21401
Location: NE Indiana, USA (NTSC)
Several years ago, I used da65, part of the cc65 suite, to recover my DPCM Split demo after a laptop died.

_________________
Pin Eight | Twitter | GitHub | Patreon


Top
 Profile  
 
 Post subject: Re: .NES to .ASM (Help)
PostPosted: Tue Dec 11, 2018 9:27 pm 
Offline
User avatar

Joined: Thu Mar 31, 2016 11:15 am
Posts: 514
Heh I wonder if this guy's story is legit, or if he's just trying to hack something copyrighted. :lol:

Not that I care. Hope you figure it out.


Top
 Profile  
 
 Post subject: Re: .NES to .ASM (Help)
PostPosted: Wed Dec 12, 2018 12:41 am 
Offline
User avatar

Joined: Thu Sep 15, 2016 6:29 am
Posts: 896
Location: Denmark (PAL)
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)


Top
 Profile  
 
 Post subject: Re: .NES to .ASM (Help)
PostPosted: Wed Dec 12, 2018 1:09 am 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 4077
Location: A world gone mad
Sumez wrote:
Does NESASM not output a debug file with all the labels and such?

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.

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).


Top
 Profile  
 
 Post subject: Re: .NES to .ASM (Help)
PostPosted: Wed Dec 12, 2018 5:19 am 
Offline

Joined: Sun Feb 07, 2016 6:16 pm
Posts: 668
Sumez wrote:
feels like a complete disassembly of my project (though it can be pretty funny with reused ZP variables)
Have you tried the "Source View" mode? (Right-click on code window -> Switch to source view)
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).


Top
 Profile  
 
 Post subject: Re: .NES to .ASM (Help)
PostPosted: Wed Dec 12, 2018 5:48 am 
Offline
User avatar

Joined: Thu Sep 15, 2016 6:29 am
Posts: 896
Location: Denmark (PAL)
Jesus christ, sour, your work keeps amazing me. :O


Top
 Profile  
 
 Post subject: Re: .NES to .ASM (Help)
PostPosted: Wed Dec 12, 2018 9:23 am 
Offline

Joined: Tue Aug 28, 2018 8:54 am
Posts: 143
Location: Edmonton, Canada
Sour wrote:
Have you tried the "Source View" mode? (Right-click on code window -> Switch to source view)
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).


Omg, Sour. Did I tell you that you are great and Mesen is amazing? Is there a keystroke like Ctrl+T (Visual Studio 2017) or Ctrl-P (Visual Studio Code) to type file name instead of using mouse?


Top
 Profile  
 
 Post subject: Re: .NES to .ASM (Help)
PostPosted: Wed Dec 12, 2018 5:43 pm 
Offline

Joined: Sun Feb 07, 2016 6:16 pm
Posts: 668
Sumez wrote:
Jesus christ, sour, your work keeps amazing me. :O
yaros wrote:
Omg, Sour. Did I tell you that you are great and Mesen is amazing?
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:
Is there a keystroke like Ctrl+T (Visual Studio 2017) or Ctrl-P (Visual Studio Code) to type file name instead of using mouse?
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)


Top
 Profile  
 
 Post subject: Re: .NES to .ASM (Help)
PostPosted: Wed Dec 12, 2018 6:49 pm 
Offline
User avatar

Joined: Tue Jun 24, 2008 8:38 pm
Posts: 2293
Location: Fukuoka, Japan
We are derailing the thread :lol:

@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.


Top
 Profile  
 
 Post subject: Re: .NES to .ASM (Help)
PostPosted: Wed Dec 12, 2018 6:50 pm 
Offline

Joined: Tue Aug 28, 2018 8:54 am
Posts: 143
Location: Edmonton, Canada
Banshaku wrote:
We are derailing the thread :lol:


I know...

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.

You can still use it as your C compiled to asm ".s" files has C code in comments.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

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