LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   some tool to convert C code to x86 (https://www.linuxquestions.org/questions/programming-9/some-tool-to-convert-c-code-to-x86-305504/)

rmanocha 03-24-2005 10:26 AM

some tool to convert C code to x86
 
I was wondering if there is any program/tool which can convert C code into the corresponding x86 code for me?? I dont know if gcc does this...I have never written C code in unix (or in ne other OS for that matter) and hence am very new to this.
Please let me know if u know some.

rshaw 03-24-2005 10:29 AM

moving to programming

jtshaw 03-24-2005 10:32 AM

"gcc -S -o test.S test.c" will create a file test.S that contains the assembly version of test.c. If you are using either an gcc-x86 cross compiler or are on an x86 compiling natively these assembly instructions will be x86 assembly.

I think this is what your asking for... if not, let us know.

rmanocha 03-25-2005 01:27 AM

Quote:

Originally posted by jtshaw
"gcc -S -o test.S test.c" will create a file test.S that contains the assembly version of test.c. If you are using either an gcc-x86 cross compiler or are on an x86 compiling natively these assembly instructions will be x86 assembly.

I think this is what your asking for... if not, let us know.

that is exactly what i was looking for. thanks a lot...I really appreciate it.

rmanocha 03-26-2005 12:18 PM

If I may, can i also ask if there is any way to convert perl code into assembly?? I am basically trying to get spamassasin code in assembly. I thought i could use perlcc to convert from perl to C and then the gcc command to convert to assembly but it seems like perlcc does not work on any of the perl files in the spamassasin code base.
thanks

BoldKiller 03-26-2005 12:50 PM

That is more tricky.

Perl is interpreted, not compiled. So there is no assembly version of it (at least strictly speaking). At best, you will get assembly listing of your code interpreted by the perl engine. So the assembly will be a mixture of your code and of the perl engine code.

Why do you want to have the assembly? I mean, perl can run on an x86, so you can run spamassassin on that platform. Its the point of writing a program in a language like perl.

rmanocha 03-26-2005 12:54 PM

Quote:

Originally posted by BoldKiller
That is more tricky.

Perl is interpreted, not compiled. So there is no assembly version of it (at least strictly speaking). At best, you will get assembly listing of your code interpreted by the perl engine. So the assembly will be a mixture of your code and of the perl engine code.

Why do you want to have the assembly? I mean, perl can run on an x86, so you can run spamassassin on that platform. Its the point of writing a program in a language like perl.

I have an assingment to do in which i am supposed to examine code from an anti-spam/anti-virus/anti-spyware program and then optimise the hardware of a pentium m processor to run on it (and i have been assigned spamassasin). hence i need to look at the assembly code to figure out which parts of the processor can be optimised given the algorithms in the code being analysed.

BoldKiller 03-26-2005 01:11 PM

Ouch! That is going to be some assignement!!

If you were assigned Spamassassin by the teacher, you should check with him if he is aware that spamassassin is in perl. In other words in an interpreted language. Because to do what you are talking about, you will need to actually optimize both Spanassassin AND the perl framework!

If you still need to do it, I would say the best way is to try to make perlcc work with your code. Then fallow your original idea.

The other way to go would be to run Spamassassin in a debugger, and make a memory dump of the code. I used something like that once, but I dont remember the name of the software. BUT be warned that you will get the instructions of SpammAssassin, the Perl framework AND the instructions of the librairy and kernel calls being made!
This is going to be even bigger. I doubt your assignement is to optimize the way the recv() fonction for the sockets works.

Good luck


All times are GMT -5. The time now is 04:49 PM.