tags:

views:

113

answers:

3

Is there a program that will convert assembly to C or C++? I did a lot of searching but I could not find anything that works. There is a program called "Boomerang"; it looks great and just want I wanted, but it's very unstable and crashes when I try to use it. (boomerang)

Are there any other free programs that will do that?

A: 

This is not possible.

It cannot be done.

It is beyond the grasp of mortals.

Well, unless the C code uses embedded assembly. But even there it's a little iffy.

Note that a decompiler does not "convert assembly to C". A decompiler attempts to approximate a program's original source code. The mapping is not necessarily perfect, and not possible for arbitrary assembly (again, unless you use inline assembly in the resulting C).

Borealid
Eh? No... it won't be perfect, but getting it to be at least a little bit higher level so it's easier to work with is still a good start.
Mark
-1 The maintenance of the decompiled code can be difficult but it can be done.
zoli2k
@zoli2k: no, for arbitrary assembly, it cannot be done. The capabilities of C are not a loose superset of those of assembly language. For example, let's say my assembly consists of "TST %r1". This instruction causes the processor step counter to go up by 1, but if I don't use the result, has no other effect. There is no C code which equates to this lone instruction. There are many other examples - reading processor internal registers, writing to I/O devices directly, even the HLT instruction. What I said was correct.
Borealid
@Borealid, in sample conversions of Regolix there are also converted TST instructions. I absolutely agree with you, that writing that ASM is a different level of control over the hardware than C and some instructions can not be directly converted to C. On the other hand, if a tool is able to convert only 90% of the ASM code to C, that is already a lot of saved time. I will remove -1 if you add your examples with HLT and TST to the answer.
zoli2k
@zoli2k: An easy example is a function which consists of 10 HLT instructions. This has no C equivalent. Ditto one consisting of 10 "TST %r1". Or, for instance, a program with no functions at all (see http://www.muppetlabs.com/~breadbox/software/tiny/teensy.html ). Just because the disassembler can find equivalents for *some* code containing the instructions does not mean it can do so for *all* uses of the instructions. And what the poster asked for was a converter - i.e. an invertible mapping.
Borealid
Can you add this to your answer so I can remove the vote down?
zoli2k
The funny thing is, for the game Transport Tycoons Deluxe (aka TTD), this very thing was done. Yes, it contained tons of `TST %r1` instructions. So? That just meant the decompiler emitted a macro.
MSalters
+1  A: 

There are few tools able to do the conversion like Regolix translator from ASM to C and Datatek converting ASM to C/C++/Cobol/C#. However, I think the maintenance of the converted code can be problematic.

zoli2k
yea i looked at both of thoses Relogix i don't understand i think it's built in and idk how to use it. and datatek you have to pay for it. i looked but i did not see anything about downloading you have to call them to talk about buying.
blood
+1  A: 

What you're looking for is a decompiler.

You will end up with something not really much better than the ASM source, and I'm pretty sure you're going to end up with C, not C++ anyway.

thomasfedb
i don't think i want a decompiler, i have the assembly code but i want it turned into c++.
blood