- The caller pushes each of the function’s arguments on the stack one by one, normally using the
push x86 instruction.
- Arguments are pushed in right-to-left order. The stack grows downward: each push decrements the stack pointer, then stores into the location it now points to, like the C expression
*(--sp) = value.
- The caller pushes the address of its next instruction (the return address) on the stack and jumps to the first instruction of the callee. A single 80x86 instruction,
call, does both.
- The callee executes. When it takes control, the stack pointer points to the return address, the first argument is just above it, the second argument is just above the first argument, and so on.
- If the callee has a return value, it stores it into register
- The callee returns by popping the return address from the stack and jumping to the location it specifies, using the 80x86
- The caller pops the arguments off the stack.