a.) Given that a procedure A calls procedure B in Intel 64-bit architecture, for
ID: 3606613 • Letter: A
Question
a.) Given that a procedure A calls procedure B in Intel 64-bit architecture, for each task below involved in the call and execution of procedure B, indicate whether the task is performed by the assembly code for procedure A or procedure B by writing “in A” or “in B” for each part below.
i) transferring control back to procedure A when procedure B is finished
ii) transferring control from procedure A to procedure B code when procedure B is called
iii) preparing the stack for the execution of procedure B
iv) preparing the stack for return to procedure A
v) saving the location where execution resumes in procedure A
b.) Assume procedure A calls procedure B as in part (a) above. For each item below, indicate whether the information will likely reside in the procedure A stack frame, the procedure B stack frame, both stack frames, or neither stack frame, by writing one of “in A,” “in B,” “in both” or “in neither” next to each part. Indicate the best choice based on what must be true.
i) actual arguments in excess of 6 passed to procedure B
ii) procedure A resume location
iii) value of %ebp for procedure A while in procedure B
iv) procedure B’s final return value (if any)
v) the size (in number of bytes) of the procedure A stack frame
Explanation / Answer
a.
i) in B. It is so because the Assembly Code in procedure B will transfer the control to procedure A.
ii) in A. As it is Assembly Code in procedure A will invoke the procedure B.
iii) in A. As it is the Assembly Code in procedure A that will prepare the stack for the target address which is of Procedure B.
iv) in B. As it is the Assembly Code in procedure B that will update the stack to return the address of Procedure A.
v) in A. As the code specifying return address of procedure A will be executed in Procedure A itself.
b.
i) in neither. As per statement it is obvious that the valid number of arguments is 6. Any arguments passed excess of it results in stack overflow.
ii) in A. As the return address of the Caller Procedure is stored in the stack of Caller Procedure (which is Procedure A here) itself.
iii) in both. As the saved value of the frame pointer is stored in both Caller and Callee’s stack (which is Procedure B here).
iv) in A. After the Callee has finished the procedure, it must clean up its frame and restore the Caller's frame by copying final return value into Caller saved register %eax.
v) in neither. Stack size is not saved in either Caller or Callee stack.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.