Domanda

So what I am looking for is not finding a assembly emulator.

Basically what I am trying to do is translation assembly to c,

Although I have a IDA pro with the "F5" dis-compile function, but generally I am trying to do a simulation approach.

I made this examples by hand to demonstrate my idea:

mov %eax, 10
add %eax, 5
jmp foo

I want to directly translate it into a simulated c procedure like this

unsigned v_eax = 0;
v_eax = 10;
v_eax += 5;
goto foo;

I think this is pretty like a assembly simulator, which has the process like

assembly --> running in a CPU simulator in C --> output the results

But what I am trying to do is like this

assembly --> translate into a c source code --> compile --> run to get the results

After a quick search, I think this paper has an approach which is similiar to what I am trying to do (however I don't any analysis work, just translation of some simple assembly code)

Could anyone give some help on this issue..?

Thank you!

È stato utile?

Soluzione

What help are you looking for? If you have specific questions, ask those questions.

It looks like you've already got the general idea: Set up a bunch of variables to represent the registers, set up a large array to represent the memory, implement either subroutines or macros (chunks of code generated in-line) that represent each instruction and do the Right Thing with those resources, implement additional macros or subroutines which are wrappers for or equivalent to every operating system call or external library function which the programs might invoke (I/O most importantly), write a "loader" for the executable file, then go through the program converting instructions to those macros. Be sure to fix up goto/call addresses properly, and hope like heck that the programmers kept data blocks and code blocks distinct. Get it all debugged, and it should work. Extremely slowly, but that's what you've asked for.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top