View previous topic :: View next topic |
Author |
Message |
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
De-compiler / code extraction help |
Posted: Mon Mar 19, 2012 12:15 pm |
|
|
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
|
|
Posted: Mon Mar 19, 2012 12:31 pm |
|
|
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: 9243 Location: Greensville,Ontario
|
|
Posted: Mon Mar 19, 2012 2:02 pm |
|
|
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
|
|
Posted: Mon Mar 19, 2012 6:22 pm |
|
|
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 |
|
|
|