This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Convert Assembly code to Keil C

Amount line code about 300. So that, you could help me by indicate some ebook step by step to solve this case.


If anyone can help me to convert,i'm very happy.


Plz mail victorvn2003@yahoo.com
MJ,


Many thanks.

  • You are going to have to do this manually - there is no automated tool.

    There is no magic - it's just pure hard work.

    You need to understand what the assembler is doing, and then re-implement that in 'C'.

    Thus you need a thorough understanding of the microcontroller, the rest of the target system, assembler programming, and 'C' programming.

    What I have done in the past is to write comments in C-like syntax alongside the assembler, and then use these as the basis for the 'C' re-implementation.

  • Oh, yeah, thanks. But you can tell me about some book that help me to convert assem to Keil C

  • There are attempts at tools to do this task called "decompilers". (Ask Google about them.) I've never used one professionally, and am not convinced they're really industrial-strength tools. The source code produced (that I've seen) tends to be not significantly more readable than the assembler code, especially when presented with optimized code to decompile. (For instance, you'll get a fairly literal translation of the common subexpression elimination as function calls with automatically generated names about as informative as "?CO?COM047".)

    If you have the assembler source, and that's good quality, then you should have documentation on the inputs, outputs, and purpose of a function. In some cases it will be easier to code a corresponding function in C than to scrutinize the assembler to translate it.

    If you're trying to reverse engineer a product with nothing but the disassembled binary, then you have to figure out what the sections of code actually do first. As Andy says, that's just plain hard work. No tool can generate informative function and variable names that match the purpose of the code just from the binary image, and so recasting a DJNZ loop into a do/while probably won't add much understanding.

  • "you can tell me about some book that help me to convert assem to Keil C"

    I doubt very much indeed that such a book exists.

    What exactly is your problem?

    Do you not understand how an 8051 works?

    Do you not understand assembler?

    Do you not know how to write 'C' for the 8051?

    You will find plenty of references covering each of these topics but, as I just said, I doubt you'll find much (if anything) on going from assembler to 'C'

    One might also ask why you need to do this - do you have legitimate rights to the code?