Application Binary Interface: designer choice to layout memory, control function calls, and passing data.
Bottom: Highest address Top: Lowest address
sub 0x08, %rsp: 8 byte
mov src, (%rsp)
(If we push 1 to stack top, the 1 bit will be at %rsp with little endian)
push %rip: push
%rip that points to the line after call, this will be the return address for after a call is finished.
When having more than 6 arguments:
7th argument is at %rsp
Frame: Function Call
local memory for variables exceeds available registers
Will function over-allocate stack? as passing 7th 8th argument? (looks like there is a 8 bit gap above 8th argument)
For alignment reasons, callee will allocate more memory than needed
We always align to 64 bits or 8 byte (
sub $0x10 $rsp)
mov $0x4030d8,%esi does it assume equal size? so 0x4030d8 will be padded with 0s?
Will zero out what's not in destination
if a function call is a tail call, does C do optimization to stack allocation in recursion?
Why do assembly generate
nop (see in assembly, not 0x00)
Why don't we
mov %rbp %rsp in 64 bit
Why would caller want to save r10 and r11 that are not arguments to callee? (they are caller-saved but not arguments)
ret, AMD processors will have branch prediction penalty. To avoid this,
rep; retis used.
mov 0x0, %eax before function call? has to do with vector?
compiler do this for debugging (reset return value before calling function
If I have 2 threads, 2 sets of registers doing different jobs?
Table of Content