CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

De-compiler / code extraction help

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

De-compiler / code extraction help
PostPosted: Mon Mar 19, 2012 12:15 pm     Reply with quote

Hi fellow users,

I have a project that I worked on a couple years ago and have working code that's programmed into a PIC. This has been functioning beautifully since then. My problem... a few months ago I wanted to change the code a bit to try and fine tune things. Well, like a dummy, I didn't make any notes on what I changed and now the current code isn't functioning how I would like. Since I didn't make any notes or archive anything (I know, I know, not smart.... banging my head on the monitor) I'm not sure what changes I need to make to get the code back to working order.

I can read the PIC that contains the working code but I need a way to de-compile it to ASM so I can compare that code with my, currently, messed up code so I can figure out what changes need to be made.

I've never had to do this before and would like to ask for suggestions on how to get the two where I can compare them side-by-side.

Thanks,
Ronald
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 19, 2012 12:31 pm     Reply with quote

You can read the PIC's flash memory and save it as ASM source code.

1. Start MPLAB but don't open a project. Go to Configure/ Select Device
and set it for your PIC. Also go to Programmer/ Select Programmer
and seit for your programmer (ICD2, etc).

2. Go to Programmer/ Connect and "connect" your programmer to your
PIC.

3. Go to Programmer/ Read and read the PIC's Flash Memory into MPLAB.
It may give a warning dialog box about reading the whole PIC. Just click
on OK to continue.

4. Go to View/ Program Memory and it will show the ASM code of what
it just read from the PIC.

5. Right-click on the Program Memory window and select Output To File.
Give it a filename. It will be a .TXT file. Save it to your desktop.

6. Open the .TXT file in any text editor and look at the ASM code.
It has line numbers, addresses, and opcodes in it, in addition to the
ASM, but at least you now have the ASM source.

What you do with it is up to you.
temtronic



Joined: 01 Jul 2010
Posts: 9161
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Mar 19, 2012 2:02 pm     Reply with quote

All that based on you NOT setting security bits on the PIC.......
..depending on the PIC, MPLAB might not be able to correctly read the data.

Since I never set those bits, I can't be sure, but, well, you'll KNOW, soon enough.
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Mon Mar 19, 2012 6:22 pm     Reply with quote

One handy utility for comparing thing you might be interested in looking into is called "Beyond compare" and works very well for comparing text files etc. Definitely handy to have around when programming -- http://scootersoftware.com/ I have no connection with them other than as a satisfied customer. Makes it easy to identify changes made in code.

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group