Stack is a region of memory, which is used to store the
register values of the processor, whenever the program needs to
change its context.
For example if a running program is interrupted by an interrupt, the
processor will jump to another memory location, where the code
related to the interrupt is stored, and start executing that.
However, the processor will return to where it left from when it is
done with executing the interrupt code or the Interrupt service
routine as it is called technically. When the processor returns to
the point where it was before it made a jump to the interrupt code,
it would want to have same values/contents in its registers, as it
had before jumping. These register values are also called 'context'.
So that the processor is able to restore its context, the entire
context is stored in some memory location before the jump
instruction is executed. This memory location is called 'stack
memory' or just a 'stack'. This is a region of the memory which a
user must reserve for this purpose.
All ARM processors have a 'Stack-Pointer' Register, which points to
the 'stack' region as defined by the user.
The stack pointer always points to the memory location at the 'top'
of the stack, and it decrements as the values are 'pushed' on to the
stack memory locations.
While the main purpose of the 'stack' is defined above, the 'stack'
may also be used for other purposes.
For example, the 'stack' memory is also used for storing local
variables. Tutorial 2,
explains the storage of local variables.