Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

4.8. Linux .s files

One of the intermediate steps that gcc uses in the translation of a C source program into an a.out file is an assembly language file. This file is the output of the compiler proper and the input to the assembler, gas. To see these assembler files, one can direct gcc to output the assembler file once this stage is reached using the -S switch. This output has a .s file extension. Consider for example the following C program, mult.c:

Program 4.7.

main()
{
    int x, y;
    register int a, b, c;
    printf("Enter a number:   ");
    scanf("%d", &x);
    printf("Multiply it by what number?  ");
    scanf("%d", &y);


     a = x;
     b = y;
     c = 0;


     while (b != 0)
    {
         c = c + a;
         b = b − 1;
    }

     printf ("The result is %d.\n.",c);
}


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint