Question: #include #define NOINLINE _ _ attribute _ _ ( ( noinline ) ) static NOINLINE int function 1 ( int x , int y )
#include
#define NOINLINE attributenoinline
static NOINLINE int functionint x int y
int i;
int sum;
int values;
sum ;
for i ; i ; i
valuesi i x y;
sum valuesi;
return sum;
static int NOINLINE functionint values int valuesLen
int i;
int sum;
int sum;
int v;
sum;
sum;
for i ; i valuesLen; i
v valuesi;
if v
sum v;
else
sum v;
return sum sum;
static NOINLINE int functionint x
int y;
y x ;
return y;
static NOINLINE int functionint a int b int c int d
int r;
if a b
r b;
else if a c
r a;
else if a d
r a;
else
r ;
return r;
static NOINLINE unsigned int functionunsigned int x
unsigned int x;
unsigned int x;
unsigned int x;
x x ;
x x ;
x x ;
return x x x;
int mainint argc, char argv
int i;
int j;
int k;
int values;
i ;
j ;
k functioni j;
printffunction: i d j d k d
i j k;
for i ; i ; i
valuesi i;
k functionvalues;
printffunction: k d
k;
k function;
printffunction: k d
k;
k function;
printffunction: k d
k;
k function;
printffunction: k d
k;
return ;
CODESEG
public strlen
strlen proc
buf:ptr byte
OPTION PROLOGUE:NONE, EPILOGUE:NONE
FPO
string equ esp
mov ecx,string ; ecx string
test ecx, ; test if string is aligned on bits
je short mainloop
strmisaligned:
; simple byte loop until string is aligned
mov albyte ptr ecx
add ecx,
test alal
je short byte
test ecx,
jne short strmisaligned
add eax,dword ptr ; byte nop to align label below
align ; should be redundant
mainloop:
mov eax,dword ptr ecx ; read bytes
mov edx,efefeffh
add edx,eax
xor eax,
xor eax,edx
add ecx,
test eax,h
je short mainloop
; found zero byte in the loop
mov eax,ecx
test alal ; is it byte
je short byte
test ahah ; is it byte
je short byte
test eax,ffh ; is it byte
je short byte
test eax,ffh ; is it byte
je short byte
jmp short mainloop ; taken if bits are clear and bit
; is set
byte:
lea eax,ecx
mov ecx,string
sub eax,ecx
ret
byte:
lea eax,ecx
mov ecx,string
sub eax,ecx
ret
byte:
lea eax,ecx
mov ecx,string
sub eax,ecx
ret
byte:
lea eax,ecx
mov ecx,string
sub eax,ecx
ret
strlen endp
end
Describe the stack at line return sum; The bottom of the stack is the first row below. The top of the stack will be the last item. The first few items are provided. You will probably need to add some additional rows to the table below.
Description Value
First argument to main argv
Second argument to main argc
Return address of main Callers return address
C runtime value of bp Callers bp register
Local variable i in main bp
In detail explain the code generated for line k functioni j; For this and all further questions in which you are asked to explain the code generated in detail, I expect you to copy the generated code and add a comment for each line. For example:
e CFC mov DWORD PTR ebp ; initialize i
You can also refer to WeekCAssemblygasm for examples of what you should submit.
In detail explain the code generated for functionline through
In detail explain the code generated for functionline through
The following questions should be answered using the optimized code.
In detail explain the code generated for functionline through Why does this work?
How are function calls optimized? For example, see lines and
The following questions should be answered using by comparing the unoptimized code and the optimized code.
Compare the code generated by function in the unoptimized and optimized versions. Explain the optimizations.
Bonus points
In detail explain the code generated for function This a hard. Try your best. Why is the compiler doing
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
