• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

how to convert a hex code file to c codes ?

qwertyqwq

New Member
hello everyone.
I have a very old EPROM. I could get the hex codes inside of it . the problem is , i don't know how to convert these hex codes into other programming languages (c etc.) .

Can you help me if you guys have any knowledge about this topic?
Thanks in advance :)
 

Les Jones

Well-Known Member
You should be able to find a disassembler for the processor type which will give you the code is assembler. You will then have to work through the assembler code to understand exactly what it is doing. You will then have to write the program in "C" It is very unlikely that your "C" program will compile to give exactly the same hex file when compiled but you should be able to get it to function in the same way. I did this for a PIC16F876 except for converting it to "C". (I find "C" very difficult compared with assembler.) It took me a few months to disassemble it and modify it to run on a PIC18F2525.

Les.
 

qwertyqwq

New Member
You should be able to find a disassembler for the processor type which will give you the code is assembler. You will then have to work through the assembler code to understand exactly what it is doing. You will then have to write the program in "C" It is very unlikely that your "C" program will compile to give exactly the same hex file when compiled but you should be able to get it to function in the same way. I did this for a PIC16F876 except for converting it to "C". (I find "C" very difficult compared with assembler.) It took me a few months to disassemble it and modify it to run on a PIC18F2525.

Les.
Hmm . thanks for quick reply..

do you know any software to convert it through the assembler language ? or do you have any advice to me cause i dont know anything about converting ! :(
 

Les Jones

Well-Known Member
If you don't know which processor the code in the EPROM is for then you have no chance of disassembling it. Can you not identify the processor in the unit it was removed from ?

Les
 

Nigel Goodwin

Super Moderator
Most Helpful Member
i have no idea :(( i asked company they dont know too. cause the eprom used in 1970s or 1980s ..
Well if you don't know what the processor is, then presumably you don't know what the hardware is either?, so you haven't much hope of disassembling it.

Assuming you can identify the processor, then you should be able to find a dis-assembler for it, and generate crude assembler source code.

I included a dis-assembler in PicProg and WinPicProg, long ago, but PIC assembler been RISC is fairly easy to dis-assemble.

As it's such an old EPROM (and the fact it's an EPROM at all) it's probably for a micro-processor rather than a micro-controller, but there's a vast number of processor options - Z80 might be worth trying?.

As others have said, you can't generate C code from it, and it probably wasn't written in C anyway depending how old it is?

What are you trying to do anyway?
 

qwertyqwq

New Member
If you don't know which processor the code in the EPROM is for then you have no chance of disassembling it. Can you not identify the processor in the unit it was removed from ?

Les
i contact to customer service and they said its M2732A which maded by SGS-THOMSON MICROELECTRONICS .
and i found the datasheet, its here.
thanks for all reply.. :)
 

qwertyqwq

New Member
Well if you don't know what the processor is, then presumably you don't know what the hardware is either?, so you haven't much hope of disassembling it.

Assuming you can identify the processor, then you should be able to find a dis-assembler for it, and generate crude assembler source code.

I included a dis-assembler in PicProg and WinPicProg, long ago, but PIC assembler been RISC is fairly easy to dis-assemble.

As it's such an old EPROM (and the fact it's an EPROM at all) it's probably for a micro-processor rather than a micro-controller, but there's a vast number of processor options - Z80 might be worth trying?.

As others have said, you can't generate C code from it, and it probably wasn't written in C anyway depending how old it is?

What are you trying to do anyway?
i need to get that information inside of EPROM. the company which was using it , they said how to get code inside of it.. i made all of steps and i got hex code . now need to convert it assembler or etc . :(

by the way : i really liked your web site :) . i tried your software and it didnt work. cause there was no M2732A .
 

Les Jones

Well-Known Member
If when you say "company" you mean the EPROM manufacturer then they will have no idea what it has been used for. In the past I think I have used UV erasable EPROMs for character generators. (For CRT displays) The total lack of information you have (Or are prepared to disclose to us.) on the device means it could contain something other than firmware to run on some unknown microprocessor.

Les.
 

Nigel Goodwin

Super Moderator
Most Helpful Member
i need to get that information inside of EPROM. the company which was using it , they said how to get code inside of it.. i made all of steps and i got hex code . now need to convert it assembler or etc . :(

by the way : i really liked your web site :) . i tried your software and it didnt work. cause there was no M2732A .
2732 is the number of the EPROM, NOT the processor - you could probably have read that off the chip.
 

ronsimpson

Well-Known Member
Most Helpful Member
Here is a picture of a "2732 eeprom". It stores information. There is no thinking involved here.
1549470975320.png
If I had the memory IC I could read it. You don't have the tools to read it. If you could this is typical. On the left side is the address of each 16 bytes.
1549471317715.png
It is common to find some text you can read in the data. "EAGLE3.TXT" In this case. Most of the data is for the computer but some small pieces are for a human.
1549471526972.png
(see above picture) Each type of computer thinks very differently. The "78" instruction is very different in each of 100s of different types of computers.
Some computers think "78" is one instruction but some will use "78 56" as one instruction and others need "78 56 34 12". So we don't know how big a word is.
We don't really know if it is computer code or data, or both mixed together.
 

sagor1

Active Member
The answer definitely depends on what CPU was reading the EPROM. Most "hobby" 8 bit CPUs of the 70's and early 80's were usually 8080 ,8085, z80 and some systems used the 6502, like Apple and Commodore.
A Z80 disassembler can handle 8080 and 8085 code as well as Z80. A disassembler for 6502 will be a different product.

There were other CPUs of that era, including the 6800 and a few others.

All these different vendor processors use different binary codes (hex codes), hence you need to identify the CPU somehow....
 

Pommie

Well-Known Member
Most Helpful Member
If you post the first 16 hex values then someone may recognize which processor it belongs to.

Mike.
 

sagor1

Active Member
Agree with Pommie, if you post 16 (or 32) bytes of the hex code, someone may be able to see if it fits a pattern related to some specific CPU code.
 

Les Jones

Well-Known Member
Even if you can identify which type of processor the code is for it is going to be almost impossible to make the disassembled into something you can understand without knowing what the code is supposed to do and what is connected to the processor to create I/O ports and how these ports are mapped to memory space.
If you gave some background information so we have some idea why you want to disassemble the code in a ROM from some unknown source someone may come up with some more help.

Les
 

Pommie

Well-Known Member
Most Helpful Member
If it's that old you can probably replace the main processor board with a modern micro-controller or even an Arduino.

Mike.
 

qwertyqwq

New Member
If you post the first 16 hex values then someone may recognize which processor it belongs to.

Mike.
its here :

Code:
:20040000383838383838282828282828282A2A2A2A2A2A2B2B2B2B2B2B2B2B2B2B23232361
:200420002323232323232323232323232323232323232323232323232323232323030303BC
:2004400038383838383838382828282A2A2A2A2A2A2A2A2A2A2A2B2B2B2B23232323232318
i hope you guys can figure it out cause i have no idea about it !
thanks for all kind helps..
have a great day :)
 

Nigel Goodwin

Super Moderator
Most Helpful Member
That looks to be data rather than machine code.

What are you actually trying to do anyway? - are you trying to replicate the device?, modify the device?, make a completely new board for the device?.
 

Latest threads

EE World Online Articles

Loading

 
Top