Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

reading program from PIC16F877A

Status
Not open for further replies.

sana_akhtar

Member level 2
Member level 2
Joined
Apr 21, 2012
Messages
47
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,606
Hey

I am trying to read a program from PIC16F877A. My programmer (Genius 540) is reading ti in Hex file. Can I convert it back in C language in which it was originally written. Any programmer which can do this?

Thanks
 

No, it isn't possible to recover the source code after it has been compiled. The best you might manage is to view it as disassembled machine code and manually recognize some of the fragments of code. You would never recover things like variable names or comments as these are only used in the original compiling process.

Brian.
 

It is possible, however the c code will not look the same. This is call reverse engineering, in particular decompiling, and a lot of people are trying to figure it out. Since the code on the processor is assembly you can recover that very easy. Converting assembly to C code or even objects is hard. The reason is due optimization and name resolution during the compilation process of the c compiler. So yes in theory it is possible to sit down and figure out what this block of instruction is doing, and then write equivalent c code.

However some of the information is lost. The resulting code will look kind of like C/assembly hybrid. Things like variable names are not recorded in assembly code.

These reverse engineering tools are a tightly guarded secret and expensive to make. Many companies are trying to find ways to protect their code from these devices by scrambling the assembly in such a way that it still works yet is not easily read by these tools. This why some companies guard their code in secret facilities and use processors that cannot be read after assembly. (Very custom manufacturing.)
 

I'm not sure a processor as simple as the 16F877A would even have room for an internal decrypter but the important point is that the numbers ulimately stored in the processors program memory are the result of several stages of conversion and packaging. What the hex file represents is the machine instruction equivalent of the source code but not the source code itself. Betwen source and PIC there is a compiling process, possibly library code added, possibly optimization and finally linking all of them together and arranging them to fit in the available memory space. Functionally, it does what the source code was written to do but even the order of instructions from start to finish may be competely different to the top and bottom of the original source file.


Brian.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top