Watch the stack pointers move

main calls add(2, 3). Press Next to run one instruction at a time. The stack hangs from the ceiling and grows downward, so higher addresses are at the top.

rsp top of the stack. Moves on every push, pop, call and ret. rbp this function's bookmark. Set once at the start, put back at the end. rip the next instruction to run.

Keys: ← →

C++

    Assembly

      The stack (memory)

      ↑ higher addresses
      ↓ lower addresses (the stack grows this way)
      main's area add's area free (below rsp) 5 old value left behind

      Registers (inside the CPU)

      Addresses here are short made-up numbers. Real stack addresses look like 0x7ff7bfeff6a8.

      The -O0 version is built with -mno-red-zone so add makes room the normal way. In asmview, a function that calls nothing (like add) often skips sub rsp and uses the space below rsp directly. That shortcut is called the red zone.