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
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
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
.LC0:
    .string  "Hello, world!\n"
    .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  $.LC0, (%esp)
    call  printf
    movl  $0, %eax
    leave
    ret
    .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