x choices: ~b -b 1-b b 1+b y choices: b+res1 a+res1 a+c b+c a+b z choices: a * 1
ID: 3863350 • Letter: X
Question
x choices:
~b
-b
1-b
b
1+b
y choices:
b+res1
a+res1
a+c
b+c
a+b
z choices:
a * 15
res1 * 23
res1 * 15
b * 17
c * 23
w choices:
res2 << 5
c << 5
a >> 5
c >> 5
b >>5
Consider the following function where X, Y, Z, and W represent incomplete code int math (int a int b, int c) int res1 X; int res Y; int res Z; int res4 W; return res4; The function above is implemented in assembly code below where the function parameters a, b and c are at the effective addresses 0x8 ebp), 0xc ebp) and 0x10 ebp), respectively. mov exc (%ebp),%eax not %eax mov %eax, 0x10(%ebp) mov 0x10(%ebp),%eax ov ex8 (%ebp),%edx add %edx,%eax mov %eax, 0xc(%ebp) mov 0x10 (%ebp),%ea imul $0x17,%eax,%eax mov %eax, -0x8 (%ebp) mov 0x10(%ebp),%eax sar $0x5,%eax mov %eax, 0x4(%ebp) Choose the correct options for X, Y, Z and W to complete the function so that it corresponds with its assembly code. X is [Select Y is Select z is [Select w is SelectExplanation / Answer
The answer is
X is ~b
Y is a+c
Z is c * 23
W is c >> 5
Explanation
a. In Line 1, we are storing value of b into eax register. Then in Line-2 we are performing not(~) operation on it. Therefore X is ~b
b. In line 4&5, we are moving values of a and c, into eax and edx registers respectively. Then on the next line, we are adding them. Therefore Y = a+c
c. In line 8 we are storing value of c into eax register. Then on line 9, we are multiplying 0x17(= 23 in decimal) with eax. Therefore, Z = c*23
d. In line 11 we are storing value of c into eax register. Then on line 12, we are performing shift right operation, by offset 5. Therefore, W = c>>5
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.