Question: Consider the two c procedures on the left below and their corresponding assembly code on the right below. Note that one procedure ends with a
Consider the two c procedures on the left below and their corresponding assembly code on the right below. Note that one procedure ends with a leave macro which is the same as:
movq %rbp, %rsp popq %rbp
but the other one ends with only popq %rbp. Briefly explain why this is.

int compute(int a, int b) f compute: return a b; pushq movq movl movl movl movl addl popg ret %rbp %rsp, %edi ,-4(%rbp) %esi,-8(%rbp) -4(%rbp), %edx -8(%rbp), %eax %edx , % rbp %rbp %eax int proc (int x, int y) int templx, temp2-y, result; resultcompute (x, Y)i return result; proc: pushq movq subq movl movl movl movl movl movl movl movl erbp %rsp, $24,%rsp %edi ,-20(8rbp) %esi,-24(%rbp) -20(%rbp), %eax %eax,-12 ( %rbp) -24 ( %rbp), %eax %eax ,-8(%rbp) -24 ( %rbp), %edx -20 ( %rbp ) ,%eax %edx, %esi %eax, compute %eax ,-4(8rbp) -4(%rbp), %eax %rbp v1 movl call movl movl leave ret %edi
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
