[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"
.globl main
       .type   main,@function
       pushl   %ebp
       movl    %esp, %ebp
       subl    $8, %esp
       andl    $-16, %esp
       movl    $0, %eax
       subl    %eax, %esp
       movl    $0, %eax
       .size   main,.Lfe1-main
       .ident  "GCC: (GNU) 3.2.2"

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

Thank you

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.

FLOSS Cell Mailing List
College of Engineering Chengannur

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


Other related posts: