push, pop, and RSP
- The stack is a LIFO region;
RSPalways points at the current top (lowest in-use address). pushdecrementsRSPby 8, then stores.poploads, then incrementsRSPby 8.
push rax ; RSP = RSP - 8 ; [RSP] = rax
pop rbx ; rbx = [RSP] ; RSP = RSP + 8
Key Takeaway
Because the stack grows DOWN, a buffer that is written UPWARD (like a string copy) overruns toward higher addresses — straight into saved RBP and the saved return address.