What is the purpose of the %rsp register?
%rsp is the stack pointer — it always points at the top (lowest in-use address) of the runtime stack.
The stack is the scratch area where functions keep return addresses, saved registers, and local variables, and %rsp is the single register that tracks its current top. A defining quirk of the x86 stack is that it grows downward: pushing data decreases %rsp. It's modified automatically by push, pop, call, and ret, and the calling convention requires it to be 16-byte aligned just before a call.
push %rax # %rsp -= 8, then store %rax at (%rsp)
pop %rbx # load (%rsp) into %rbx, then %rsp += 8
call func # push return address, then jump to func
ret # pop return address into %rip and jump there
Warning: never rely on data stored below %rsp (at addresses smaller than it) unless you're using the System V red zone deliberately — signals, interrupts, and called functions are free to overwrite that space.
Go deeper:
Stack register (Wikipedia) — defines the stack pointer register and its role.
Call stack (Wikipedia) — how the stack pointer and frames drive push/pop/call/ret.