- publishing free software manuals
An Introduction to GCC - for the GNU compilers gcc and g++
by Brian J. Gough, foreword by Richard M. Stallman
Paperback (6"x9"), 144 pages
ISBN 0954161793
RRP £12.95 ($19.95)

"A wonderfully thorough guide... well-written, seriously usable information" --- Linux User and Developer Magazine (Issue 40, June 2004) Get a printed copy>>>

11.3 The compiler

The next stage of the process is the actual compilation of preprocessed source code to assembly language, for a specific processor. The command-line option -S instructs gcc to convert the preprocessed C source code to assembly language without creating an object file:

$ gcc -Wall -S hello.i

The resulting assembly language is stored in the file ‘hello.s’. Here is what the Hello World assembly language for an Intel x86 (i686) processor looks like:

$ cat hello.s
    .file  "hello.c"
    .section  .rodata
    .string  "Hello, world!\n"
.globl main
    .type  main, @function
    pushl  %ebp
    movl  %esp, %ebp
    subl  $8, %esp
    andl  $-16, %esp
    movl  $0, %eax
    subl  %eax, %esp
    movl  $.LC0, (%esp)
    call  printf
    movl  $0, %eax
    .size  main, .-main
    .ident  "GCC: (GNU) 3.3.1"

Note that the assembly language contains a call to the external function printf.

ISBN 0954161793An Introduction to GCC - for the GNU compilers gcc and g++See the print edition