PLEASE FILL IN THE COMMENTS ONLY ON PAGE 2 AND PLEASE COMPLETE PAGE 3 THANK YOU
ID: 3910787 • Letter: P
Question
PLEASE FILL IN THE COMMENTS ONLY ON PAGE 2 AND PLEASE COMPLETE PAGE 3 THANK YOU VERY MUCH IN ADVANCE!!!
(10 pts) CS 3843 Computer Organization I-Recitation #05-abc123/Name _ - _ Due Fri Jul 6 2018 - Electronic Turn-In 1. The following assembly code includes a call to the function "funFunc" and the content of that same function. a. Comment each 1ine as to what it is doing. The comment should be in plain English as discussed in class b. Give a description as to what the function does. Include any pertinent details. c. What is the return address of "funFunc" d. on the lastpage, show the state of the stack inside funFunc at the point indicated. e. Indicate how many bytes are in each instruction? 004014FF push OFFFF8000h push -32768, the 2nd parameter of "funFunc" NOTE: "push 0xFFFF8000 to the stack" is not a good comment 00401601 push 00401603 l unFunc 00401608 add esp, 8 0040160B mov 2018 06 CS 3843 Computer Organization - Recitation Practice Page 1Explanation / Answer
Find the comments for each instruction. I have given instruction address and the corresponding comment in front of it in bold.
00401601 Pass the first parameter with value -1 to funFunc
00401608 Call to funFunc which will add the return address of funFunc in the stack. Return address is the next instruction address.
00401608 restoring esp at address before the parameters. Adding 8 will allow the next use of esp to overwrite on the location of parameters of funFunc.
0040160B This will put the result in ax register at the given location. As the location of ebp is unknown it will store it in the location by ebp - 4 bytes.
funFunc
00401020 Store the previous value of ebp as we will be modifying the value. esx = 0x187F4
00401021 Comment already given. ebp = 0x187F4
00401023 Store the previous value of ecx as we will modify the register.
00401024 Move the first parameter into register eax. The first parameter is at address 0x187FC which is at difference of 8 from ebp.
00401028 Move the second parameter into register ebx. The second parameter is at address 0x187800 which is at difference of 12 from ebp.
0040102C Add the result and store the value in eax. Thus eax = -32768 + -1 = -32769. Hexadecimal value will be FF 7F FF FF
0040102E It will store ax at location 0x187F0. ax is the lower 16 bits of eax. Therefore we 0xFF7F stored at location 0x187F0. Value store will be FF 7F 00 00
00401031 Again get the value from the store location back in ax.
00401034 Move the stack pointer back to where ebp is stored.
00401036 ebp will be restored by pop operation and esp will be incremented by 4 bytes. It is now pointing to return address.
00401037 esp will be added by 4 more bytes and the control will return to the next instruction of calling function.
Answer to PAGE3
The stack content will remain the same. Only at location 0x187F0 we will update the value as
FF 7F 00 00
Rest the stack contents will remain the same.
Thanks.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.