29.1k views
3 votes
Your task is to fill in the missing parts of the C code to get a program equivalent to the generated assembly code. Recall that the result of the function is returned in register %eax. You will find it helpful to examine the assembly code before, during, and after the loop to form a consistent mapping between the registers and the program variables.

User Dmarvs
by
5.3k points

1 Answer

4 votes

Answer:

See Explaination

Step-by-step explanation:

//Function

long loop (long x, long n)

{

//Declare a variable named result and initialize it to zero

long result = 0;

//Declare a variable named mask

long mask;

//For loop

for(mask = 1; mask != 0; mask = mask << (n & 0xFF))

= (x&mask);

//Return result

return result;

}

User MhagnumDw
by
5.7k points