View previous topic :: View next topic |
Author |
Message |
theitalian
Joined: 13 Aug 2015 Posts: 2
|
decompile hex |
Posted: Thu Aug 13, 2015 4:23 pm |
|
|
Needing to decompile a hex file to C. The chip is a PIC18f2321 programmed on a ICD-U64.
Anyone have a recommendation? |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Thu Aug 13, 2015 5:15 pm |
|
|
decompile to WHAT?
and if i may ask WHY?
and did you bother to GOOGLE?
pic hex decompiler |
|
|
theitalian
Joined: 13 Aug 2015 Posts: 2
|
|
Posted: Thu Aug 13, 2015 5:23 pm |
|
|
I think it was programmed in C so I'm wanting to take hex file and convert to C if possible. as for why, want to change/add command set for hardware this is controlling. |
|
|
newguy
Joined: 24 Jun 2004 Posts: 1909
|
|
Posted: Thu Aug 13, 2015 9:43 pm |
|
|
Good luck, you'll need it.
The code burned into any processor is machine/assembly code. The code you write in C is converted to assembly by the compiler. The processor itself doesn't run on or even understand C. It understands one thing only: assembly.
It's not impossible to get an idea of what the code does by looking at the assembly, but you sure won't get C. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19549
|
|
Posted: Fri Aug 14, 2015 12:31 am |
|
|
This has been asked here before, and a search would have found the answers. Basically 'not possible'. Especially given the optimiser (that deletes code that doesn't actually 'do' anything).
De-compiling, is a lot of work, and even with the right tool (would mean writing one for the particular compiler), is never very successful. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Sat Aug 15, 2015 7:23 pm |
|
|
The quickest way to see the code is to use MPLAB and read the chip into MPLAB. No it will NOT be in 'C', rather assembler but it will all be there.
As for converting assembler into C, well, that's a challenge to say the least.
yes, it can be done, just be sure to have a few pots of coffee available and a LOT of time.
Good news is that chip only has 8K of prgm space so maybe 4k worth of instructions. If there's a lot of 0xFF then the program is smaller !
Since you already know what the program does you've got an 'edge' in decoding the code. Assuming you also have schematics, you'll also know about devices/addresses/etc. that will speed up the process.
Yes, it can be done(BTDT with the TRS80) however it might be faster/easier to cut all new code depending on your level of programming.
Jay |
|
|
|