Consider the following assembly code for a function F2 with three integer argume
ID: 3917530 • Letter: C
Question
Consider the following assembly code for a function F2 with three integer arguments: Fl: push EBE mov EBP, ESP mov ECX, DWORD PTR [ebp+16] mov EDX, DWORD PTR [ebp+12] mov EAX, DWORD PTR [ebp+8] add EAX, EDX sal EAX, 2 sub EAX , ECX mov DWORD PTR [ebp-4], EAX mov ESP, EBP pop EBP # setup stack #EAX #EAX # ignore for now # cleanup stack ret To the right of each instruction, show the contents of the register whose value changes as a result of executing that instruction, then fill in the blanks in the corresponding C source code below int F2 (int x, int y, int z) int result; result- return result;Explanation / Answer
Answer:
Result = (x+y)/4 - z;
Explanation:
EAX contains x; EDX contains y; EXC contains z;
For the instruction
Add EAX, EDX; x = x+y
Sal EAX, 2; x= (x+y)/4
Sub EAX, ECX = (x+y)/4 - z
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.