x86x64 CPU architecture the stack & stack frames
Created: 2025-08-27
After the “call” instruction, the RIP is redirected to the address of the function sum().
See in context at x86/x64 CPU architecture: the stack & stack frames
Created: 2025-08-27
In sum() the very first instructions that will actually prepare the stack frame are:push rbpmov rbp, rspWhat this does is to “save” the current position of the Base Pointer (the bottom of the “current” stack frame) and replace it with the Stack Pointer (the tip/top of the stack). So the new Base Pointer is the current top of the stack.This operation of saving the old base pointer and moving it to the tip of the stack is the so-called Function Prologue.
See in context at x86/x64 CPU architecture: the stack & stack frames
Created: 2025-08-27
The stack frame is the gap between the RBP and RSP.
See in context at x86/x64 CPU architecture: the stack & stack frames
Created: 2025-08-27
After doing its job, the function sum() prepares to return to its caller (the main() function).This is called the Function Epilogue.
See in context at x86/x64 CPU architecture: the stack & stack frames
Created: 2025-08-27
EAX is the default register that holds data that a function will return.
See in context at x86/x64 CPU architecture: the stack & stack frames