Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




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.

  Published under the terms of the GNU General Public License Design by Interspire