Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
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:
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);
}
|