Architects· 64-bit
Every function call gets a frame on a stack. Recursion is a function stacking up frames of itself.
When a function is called, the processor jumps to its code. But when the function finishes, how does it know where to go back to, especially if it was called from ten different places?
Before jumping, the program writes down three things in a block of memory called a stack frame: the return address, the function's parameters, and room for its local variables. Frames are piled on a call stack. The newest is always on top, and it is the first to be removed: last in, first out.