assembly - How's RSP decreased here? -


Through debug, I've found that when func is passed to main ,

  (gdb:  RSP   8  to  0x7fffffe960  to  0x7fffffffe958  decreases) das assembler code for function function function: 0x0000000000400448 & lt; Function + 0> pushing;% RBP 0x0000000000400449 & lt; Event + 1>: mov% rp,% rbp 0x000000000040044c & lt; Function 4>: mov $ 0x1,% eax 0x0000000000400451 & lt; Func + 9>: leaveq 0x0000000000400452 & lt; Func + 10>: End of the Reticle Endler Dump (Gdb) main dump function of disas assembler code for main: 0x0000000000400453 & lt; 0 & gt; main + push;% RBP 0x0000000000400454 & lt; Main + 1>: mov% rp,% rbp 0x0000000000400457 & lt; Heading 4>: callq 0x400448 & lt; Function & gt; 0x0000000040045c & lt; Main + 9>: mov $ 0x6,% eax 0x0000000000400461 & lt; Main + 14>: leaveq 0x0000000000400462 & lt; Main + 15> retq   

why calla function will rsp by 8

After the

This is because the return addresses are also in 64 bits size (e.g., 0x0000000000400457 ). When you call func , that value is placed on the stack and the stack pointer is reduced from that amount.

Comments