In the book CSAPP, 3.7.5 Local Storage in Registers, there is a calling function:
long P(long x, long y)
{
long u = Q(y);
long v = Q(x);
return u + v;
}
and the Generated assembly code for the calling function is:
P:
pushq %rbp
pushq %rbx
subq $8, %rsp Align stack frame
movq %rdi, %rbp
movq %rsi, %rdi
call Q
movq %rax, %rbx
movq %rbp, %rdi
call Q
addq %rbx, %rax
addq $8, %rsp
popq %rbx
popq %rbp
ret
I can't understand Line 3 subq $8, %rsp
. The book says it is used to align stack frame. Why the machine align stack frame here?