Write a C function func that performs the actions of the following assembly code
ID: 3751517 • Letter: W
Question
Write a C function func that performs the actions of the following assembly code. Your function must be named func. The function takes four arguments passed in registers %edi, %esi, %eax and %rcx. The function returns a single argument in %eax func: movi %edi, %eax L3 : mov sq cmp! je addl %eax, %esi, %rdi (%rcx , %rdi,4) L2 $1, %eax j1 movl -1, eax L3 ret For example Test Result test (1,target1) oK1 Answer: (penalty regime: 10, 20, 96) 1 long func (long a,long b,long c, long long d)f long x-a; return x 7 8while(xExplanation / Answer
int func(int a,int b,int c,long d){
int ret = a;
long *pointer;
do{
a = ret;
pointer = (d + ((long)a * (long)4));
if(b == (int)*pointer){
return ret
}
ret = ret + 1
}while(c<ret);
ret = -1;
return ret;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.