Continue to Site

Welcome to

Welcome to our site! 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.

How to convert Hex -> Asm -> C

Not open for further replies.


Newbie level 4
Dec 31, 2005
Reaction score
Trophy points
Activity points
convert 00bf to hex

I recently work with Cygnal's uC and use uVision or Silabs IDE to write code. I find a firmware of a device that I want to study more deeply but the firmware is in BIN format that I can easily convert in HEX. But I don't know how to convert it in ASM format and more preferably in C. I used the disassembler D51 to get ASM format from HEX but there are variables like rb0r4,rb2r1,acc etc. that the compiler doesn't recognize.

So how to get easily readable code?

convert hex to asm

There is barely any '51 assembler which does not recognize ACC... Or you forgot to include a header file with the standard SFRs definition, if such is required.

Also you can include an another definition file, defining the directly addressed registers, e.g.
rb0r4 equ 04h
rb2r1 equ 11h

But those memory locations are most probably used as variables, so you are better off using the control file of d52 to define "legible" names for these memory locations, according to their function in the mentioned code.

Finally, although some sort of formal translation into C is definitively possible (formally it is possible to translate from any language into any other language), it is impossible to recover the original structure of the high level language, so it would have no real meaning... It is much better to study the asm version.


how to convert a .hex file back into .c? atmel

OK here is some extract from the D52. Would you discribe what stands for t3, r6 or acc.7. Give some tips how to read it.

           org       0abh
           ljmp      X043f          ; 00ab       02  04  3f     ..?
X00ae:     mov       t3,#0deh       ; 00ae       75  ff  de     u.^
           mov       t3,#0adh       ; 00b1       75  ff  ad     u.-
           mov       0b1h,#67h      ; 00b4       75  b1  67    u1g
X00b7:     mov       a,0b1h         ; 00b7       e5  b1         e1
           jnb       acc.7,X00b7    ; 00b9       30  e7  fb     0g{
           clr       a              ; 00bc       e4               d
           mov       r7,a           ; 00bd       ff                 .
           mov       r7,a           ; 00be       fe                ~
X00b7:     inc       r7             ; 00bf       0f                 .

convert 43 to hex

Dear stefan_d6,

Please don't feel offended but you perhaps need to do some basic '51 asm reading.

org 0abh the following code will be translated from address 0abh on
ljmp X043f ; 00ab 02 04 3f ..? long jump to label X043f (at address 043fh)
X00ae: mov t3,#0deh ; 00ae 75 ff de u.^ mov to SFR t3 (at address 0FFh) immediate value 0deh - the function of this SFR depends on the particular '51 derivative you are using (and it's name might be different, not t3), this is not a standard '52 SFR
mov t3,#0adh ; 00b1 75 ff ad u.-see above
mov 0b1h,#67h ; 00b4 75 b1 67 u1gmov to SFR at address B1h immediate value 67h - again, the meaning of this SFR depends on your '51 derivative
X00b7: mov a,0b1h ; 00b7 e5 b1 e1 read value from SFR at address 0B1h into accumulator
jnb acc.7,X00b7 ; 00b9 30 e7 fb 0g{if bit 7 of accumulator is zero, jump to label X00b7 (in other words, the last 2 lines mean: loop until bit 7 of SFR 0B1 gets set)
clr a ; 00bc e4 d clear accumulator (set to 0)
mov r7,a ; 00bd ff .move content of accumulator into register r7
mov r7,a ; 00be fe ~ditto

Of course, this might be (and most likely is - based on the weird content) a piece of data, table or something similar - that's exactly the "meaning" which cannot be reconstructed into the "high level" automatically...


PS. Which version of d52 are you using?

hex to asm

i think you are referring to a "decompiler". Some projects for exe->c for x86 machines exist out there. I haven't seen anything for 8051 though.
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to