[floss-cec] Re: Assembling using gcc.

  • From: "Binulal N Achary" <binulal@xxxxxxxxx>
  • To: floss-cec@xxxxxxxxxxxxx
  • Date: Sat, 27 Jan 2007 21:42:44 +0530

cool! Ssso,

binulal@binoos:~> cat test.c
int main()
{
 return 0;
}
binulal@binoos:~> cat test.s
       .file   "test.c"
       .text
.globl main
       .type   main,@function
main:
       pushl   %ebp
       movl    %esp, %ebp
       subl    $8, %esp
       andl    $-16, %esp
       movl    $0, %eax
       subl    %eax, %esp
       movl    $0, %eax
       leave
       ret
.Lfe1:
       .size   main,.Lfe1-main
       .ident  "GCC: (GNU) 3.2.2"
binulal@binoos:~>

Yuck... Ugly code! anyone to explain what on earth this means????

Thank you
Binulal

On 1/27/07, Vimal Joseph <vimalekm@xxxxxxxxx> wrote:

On 1/26/07, Binulal N Achary <binulal@xxxxxxxxx> wrote:
>
> Qn: How do we get the assembled code for any program from gcc?
>

http://www.delorie.com/djgpp/v2faq/faq8_20.html says:

Use the -S (note: capital S) switch to GCC, and it will emit the
assembly code to a file with a .s extension. For example, the
following command:

  gcc -O2 -S -c foo.c

will leave the generated assembly code on the file foo.s.

If you want to see the C code together with the assembly it was
converted to, use a command line like this:

gcc -c -g -Wa,-a,-ad [other GCC options] foo.c > foo.lst

which will output the combined C/assembly listing to the file foo.lst.

~vimal
_______________________________________
FLOSS Cell Mailing List
College of Engineering Chengannur
floss-cec@xxxxxxxxxxxxx
http://www.freelists.org/list/floss-cec

--
The more "why"s I ask about my self, the more mysterious it becomes.

Binoooooooo

Other related posts: