View previous topic :: View next topic |
Author |
Message |
surendrababu
Joined: 06 Oct 2009 Posts: 2
|
Convert hex file to c |
Posted: Tue Oct 02, 2012 6:32 am |
|
|
When we compile a c file to hex through ccs compiler, again can we convert hex file to c ? This needs somebody send the hex file only. Is it possible? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19545
|
|
Posted: Tue Oct 02, 2012 7:10 am |
|
|
No.
There are probably at least 20 possible C lines for any particular compiler output, for things like loops etc.. Then add the optimiser, and 'reverse compiling' gets more complex than writing the code in the first place.
Historically for some compilers in the early days of computers people did try to make reverse compilers. Just how successful they were is illustrated by how many exist now. A few free ones do exist for the PC, but all are 'dubious' in the quality of their output.
For a specialist compiler like CCS, the basic work is not there, and to write such a program would be many hundreds of times more complex than writing the PIC program again from scratch. Especially given how rapidly CCS changes.
Compiling is more akin to milling a piece from a lump of stock, than 'translating'. Imagine what is involved in re-creating the piece of metal from the swarf....
Best Wishes |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Tue Oct 02, 2012 7:19 am |
|
|
I made a reverse compiler for my Model III 20+ years ago and it did a fine job...done on a 'bet you can't do it'...took about 2 weeks of long, long nights (as I had a real job back then). Ah the good old dayze !
As Ttelmah points out 'reverse compiling' is a complex task and you can cut new code faster though it can be done. Most 'hobbiest' programs on PICs are not that complicated or long and can easily be 'cloned' or 'mimicked' in just a few hours. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19545
|
|
Posted: Tue Oct 02, 2012 7:27 am |
|
|
The old Tandy TRS-80.
It was easier (slightly) with older compilers, because most did not perform much if any optimisation. Now it is almost impossible to get back the 'original' code, and (of course), no comments, and variable names that have no meaning, mean it can take as long to 'interpret' the output as it took to write the program to generate it....
Best Wishes |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Tue Oct 02, 2012 10:59 am |
|
|
longer !!! sigh...... |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Tue Oct 02, 2012 1:05 pm |
|
|
You guys crack me up. Ttelmah and your "swarf" -- that's awesome.
To the poster,
Your best bet is to load it up in MPLAB and look at the assembly code (print it out or print to file) and then learn what the assembly is doing.
You're gonna be an assembly expert by the time your done!
Consider yourself lucky!
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
|