In Section 3.4.2, the x86-64 pushq instruction was described as decrementing the stack pointer and then storing the register at the stack pointer location. So, if we had an instruction of the form pushq REG, for some register REG, it would be equivalent to the code sequence:
A. In light of analysis done in Problem 4.7, does this code sequence correctly describe the behavior of the instruction pushq %rsp? Explain.
B. How could you rewrite the code sequence so that it correctly describes both the cases where REG is %rsp as well as any other register?
Ref prb:Let us determine the behavior of the instruction pushq %rsp for an x86-64 pro-cessor.We could try reading the Intel documentation on this instruction, but a simpler approach is to conduct an experiment on an actual machine. The C com-piler would not normally generate this instruction, so we must use hand-generated assembly code for this task. Here is a test function we have written (Web Aside ASM:EASM on page 178 describes how to write programs that combine C code with handwritten assembly code):
In our experiments , we find that function pushtest always returns to 0 .What does this imply about the behavior of the instruction pushq%rsp under x86-64?
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.