LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-24-2005, 11:26 AM   #1
rmanocha
Member
 
Registered: Oct 2003
Location: Austin,TX
Distribution: Debian SID-->fully content-->Love APT,kernel 2.6.4
Posts: 327

Rep: Reputation: 30
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.
 
Old 03-24-2005, 11:29 AM   #2
rshaw
Senior Member
 
Registered: Apr 2001
Location: Perry, Iowa
Distribution: Mepis , Debian
Posts: 2,692

Rep: Reputation: 45
moving to programming
 
Old 03-24-2005, 11:32 AM   #3
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 66
"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.
 
Old 03-25-2005, 02:27 AM   #4
rmanocha
Member
 
Registered: Oct 2003
Location: Austin,TX
Distribution: Debian SID-->fully content-->Love APT,kernel 2.6.4
Posts: 327

Original Poster
Rep: Reputation: 30
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.
 
Old 03-26-2005, 01:18 PM   #5
rmanocha
Member
 
Registered: Oct 2003
Location: Austin,TX
Distribution: Debian SID-->fully content-->Love APT,kernel 2.6.4
Posts: 327

Original Poster
Rep: Reputation: 30
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
 
Old 03-26-2005, 01:50 PM   #6
BoldKiller
Member
 
Registered: Apr 2002
Location: Montreal, Quebec
Distribution: Debian, Gentoo, RedHat
Posts: 142

Rep: Reputation: 15
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.
 
Old 03-26-2005, 01:54 PM   #7
rmanocha
Member
 
Registered: Oct 2003
Location: Austin,TX
Distribution: Debian SID-->fully content-->Love APT,kernel 2.6.4
Posts: 327

Original Poster
Rep: Reputation: 30
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.
 
Old 03-26-2005, 02:11 PM   #8
BoldKiller
Member
 
Registered: Apr 2002
Location: Montreal, Quebec
Distribution: Debian, Gentoo, RedHat
Posts: 142

Rep: Reputation: 15
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help!:ImageMagik convert tool very very slow James_dean Linux - Software 2 10-14-2005 12:09 AM
How to convert Assembly code to "C" source code ssg14j Programming 2 08-01-2005 01:48 PM
Convert a dll code to linux EvilLinux Programming 5 12-08-2004 10:51 AM
is there any tool avilable to convert java/sql code into asp.net/sql2000 rddreamz Programming 1 11-08-2004 03:16 PM
how to convert C executable into Assembly Code indian Programming 4 10-04-2004 05:56 PM


All times are GMT -5. The time now is 01:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration