risc-v

Definition

sp ( RISC-V)

sp is the RISC-V integer register x2, designated as the stack pointer. It holds the address of the current stack frame’s top, pointing to the most recently pushed element on the call stack.

The stack grows downward in memory (toward lower addresses). The push operation (implemented via a store instruction decrementing sp) and the pop operation (implemented via a load instruction incrementing sp) maintain the stack. sp must be correctly initialised at program entry and preserved across function calls according to the RISC-V calling convention.