What's new

Any good ASM to C translators?

Hacktarux

Emulator Developer
Moderator
BFeely said:
Does anybody know where I can download a good, free ASM to C translator?

Your brain ?
I don't know where it's hidden but you probably know :D
 
Last edited:

blight

New member
well... there are such programs... what do you believe will the output from such a program be? the original sourcecode? *lol*
everything it output's is "ASM translated to C"... i.e. if the asm would say add eax, ebx you would as output get eax += ebx; and that's it - it's like a different way of viewing asm and when compiled again i guess it will be much slower...
 

Cyberman

Moderator
Moderator
I've done that with Z80 source and converted the useful parts to C++.

Here are things that are challenging with this:
First is the original source in C C++ purely assembly, or another language such as PASCAL etc.

It's importent to understand the nature of compilors in order to do this properly.

The original compilor VERSION and NAME is mandatory.. why? Optimizations in the compilor itself are the primary reason.

If you look at the GNU C compilor you'll see that each processor supported as 2 sections. The first section is the virtual model, the second is the optimization. Redundant translated code is removed in the optimization section. Here is an example.

long int *Str;

*Str++ = 0; // zero even locations in array
Str++; // skip odd locations

This might translate to say
mov [r0], 0
add r0,4
add r0,4

the optimizer would then make a second pass and do this.

mov [r0],0
add r0,8

This is very HARD to reverse back to the original code.

might end up being something like.
*PTR = 0;
PTR +=2;

With C++ things are a LOT more complicated.

Cyb
 

Top