Suppose we want to generate assembly code for the following C function: int shift_left2_rightn(int x, int n){
Fantastic news! We've Found the answer you've been seeking!
Question:
Suppose we want to generate assembly code for the following C function:
int shift_left2_rightn(int x, int n){
x<<= 2;
x>>= n;
return x;
}
The code that follows is a portion of the assembly code that performs the actual shifts and leaves the final value in register %eax. Two key instructions have been omitted. Parameters x and n are stored at memory location with offsets 8 and 12, respectively, relative to the adress in register %eb
1. movl 8(%ebp), %eax Get x
2. _____ x <<=2
3. movl 12(%ebp), %ecx Get n
4. _____ x>>=n
Fill in the missing instructions, following the annotations on the right. The right shift should be performed arithmetically.
Related Book For
Posted Date: