WCU / Cybersecurity
~/CSC 471/Class 03/KP 03
Class 03 · KP 03 / 21

push and pop: How RSP Changes

  • push rax is equivalent to:
sub  rsp, 8       ; make room (stack grows down)
mov  [rsp], rax   ; store value at new top
  • pop rax is equivalent to:
mov  rax, [rsp]   ; read value from top
add  rsp, 8       ; release the slot
  • Each slot on a 64-bit stack is 8 bytes.
  • push decrements RSP; pop increments it.