PDA

View Full Version : HEX to C ???



nchinoy
05-20-2005, 04:18 PM
Hello people,


Can anyone tell me if any of you would know how to convert a HEX file (for a PIC16c73) to C code ???

I have used dis-assemblers before.... which give you the asm form of a HEX file... but i would like to know if this can be further transfered to C code....

I have a working peice of software which displays ALARM conditions in ITALIAN.... i want to convert these error readings to ENGLISH.... the translation is known and so are the ALARM conditions ... but what i dont know is how to convert this HEX file to C so that i can simply edit the ALARM texts to ENGLISH ones....

Any clues ???

Cheers;)

Nimesh

vikas
05-20-2005, 08:55 PM
Well most ASCII chars are stored as as 8 bit bytes and simply use a HEX editor which shows the ASCII of the HEX also ( edit where you see italien ) simple .

Dissassembly to c usually does not yeild code which can be easily used .

05-20-2005, 09:05 PM
I dont think u can get the original C source from hex or asm. coz there are n ways to write a C code which would generate the same assembly code.

check out the asm codes generated by different compilers, they have a typical way of substituting loops, if else statements,switches, etc. with standard asm code blocks.
see what gets comiled to what and eventually u'll be able figure out the C equivalent of given asm code

priyank

yogi
05-21-2005, 12:40 AM
what abt AVR

Tell me whether following conversions are possible and the compiler for it

from .hex to .asm
or .c to .asm
.hex to .c

jack
05-21-2005, 11:31 PM
Disassembler can convert your hex back into asm. C compiler for AVR can convert you C file into asm. Unfortunately here is no way to convert hex into C file, I would love to see this one....

nchinoy
05-23-2005, 11:44 AM
Well most ASCII chars are stored as as 8 bit bytes and simply use a HEX editor which shows the ASCII of the HEX also ( edit where you see italien ) simple .

Dissassembly to c usually does not yeild code which can be easily used .

Well its not as easy to use the HEX code and determine what part is actually the CHARACTER to display and what part is the code....

Then again it also depends if they are using a 4 bit or a 8 bit model to communicate with the LCD... well in case of a 4 bit they need to break down the 8 bit data into high nibble and low nibble and then send it one after the other...

I used a dis-assembler to convert the HEX file into assembly and checked out the code... It turned out that there was another possibility ... They used an external EEPROM to store the display characters ... which could be refered as a look up table... So i went through the HEX code of that display table EEPROM... Wallah... I found that they have used a 4 bit interface with the LCD ... So went ahead and programmed another HEX file with the ENGLISH version .... Seems to work just fine now .... Thanks for your replies...

I guess this is a good thing that i learnt ... If you want to make your code generic to inputs and outputs atleast if the display is to change for the given input.... Make a lookup table and put it in a external EEPROM... This way you can change the eeprom and get a new set of program and data that you want ... you dont need to change the actual PROGRAM :)

Cheers;-)

Nimesh

05-24-2005, 08:11 PM
what abt AVR

Tell me whether following conversions are possible and the compiler for it

from .hex to .asm
or .c to .asm


for hex to asm use avr studio
for c to asm or c to hex there are many compilers
codevision avr, winavr, iar's c compiler, avr-gcc, ImageCraft's c compiler...

priyank

yogi
03-30-2006, 04:33 AM
use disavr for .hex to.asm
you can use avrstudio to dissemble also


Bibin John
www.bibinjohn.tk

nmittal
03-30-2006, 08:15 PM
Hi,
Ther is no way out through which you can get the original C code out of your assembly or hex code. Assembly and hex are just another representation of one another, but when it comes to C its just not possible.

docel
03-30-2006, 10:25 PM
hi.

All of which amounts to the simple ethics:
1. WRITE YOUR OWN CODE- easier.
2. If the hex code writer wanted you to use his codem, he would have given you the asm or the .c.
3. Stick to asm. This will prevent you from relying on free samples/ restricted use etc.,
4. Why must you on a translator when you can learn the straight language yourself.

Moral: Rely on your own self!

thevikas
04-25-2006, 02:30 PM
rec is the answer you need.

-Reverse Engineering Compiler-
www.backerstreet.com/rec/rec.htm

And sure this works nicely if you know how to play with it.
I want to decompile a firmware of my digicam but i never suceeded in that yet. Rec can decompile lots of binary compiled files to C.[/url]