just incase you really wanted to know rojash here the first part of the question.
Consider the following function that forms part of a C program that has been written to measure the execution time of a simple arithmetic statement like sum = sum + increment;
long sumLoop(long increment, long iterations)
{
long i, sum=0;
for (i=0 ; i < iterations ; i++) {
sum = sum + increment;
}
return (sum);
}
The following (numbered) lines of IA-32 (in GAS format) assembly language corresponding to the above function have been generated when the C program was compiled without optimisation:
10 sumLoop:
11 pushl %ebp
12 movl %esp, %ebp
13 subl $8, %esp
14 movl $0, -8(%ebp)
15 movl $0, -4(%ebp)
16 .L7:
17 movl -4(%ebp), %eax
18 cmpl 12(%ebp), %eax
19 jl .L10
20 jmp .L8
21 .L10:
22 movl 8(%ebp), %eax
23 leal -8(%ebp), %edx
24 addl %eax, (%edx)
25 leal -4(%ebp), %eax
26 incl (%eax)
27 jmp .L7
28 .L8:
29 movl -8(%ebp), %eax
30 leave
31 ret
Where appropriate please refer to these corresponding line number(s) in your answers to the following questions: