User guide

2.3 The stack
This section describes how to use the stack in the base standard. See also Stack limit checking.
ATPCS specifies:
a full, descending stack
eight-byte stack alignment at all external interfaces.
2.3.1 Stack terminology
The following stack-related terms are used in ATPCS:
The stack pointer
Addresses the last value written to the stack (pushed).
The stack base
Is the address of the top of the stack, from which the stack grows downwards. The
highest location actually used by the stack is the first word below the stack base.
The stack limit
Is the lowest address on the stack that the current process is allowed to use.
The used stack
Is the region of memory between the stack base and the stack pointer. It includes the
stack pointer but not the stack base.
The unused stack
Is the region of memory between the stack pointer and the stack limit. It includes the
stack limit but not the stack pointer.
Stack frames
Are regions of memory allocated on the stack by routines for saving registers and holding
local variables.
A process might, or might not, have access to the current values of the stack base and stack limit.
An interrupt handler can use the stack of the process it interrupts. In this case, it is the responsibility of the
programmer to ensure that stack limits are not exceeded.
Figure 2-1 Stack memory layout
2.3.2 Stack unwinding
If you compile with the -g command line option, the resulting object file contains DWARF2 debug frame information.
The debuggers use this information to unwind the stack when necessary during debug. This allows you to view the
stack backtrace in a debugger
In assembly language, it is your responsibility to describe your stack frames using FRAME directives. The assembler
uses these to generate DWARF2 debug frame information. See the Writing ARM and Thumb Assembly Language,
and Directives Reference chapters in Assembler Guide.
2.3.3 Eight-byte alignment
For multiple transfers on some systems, eight-byte alignment of addresses can improve memory access speed. For
LDRD and STRD instructions on ARMv5TE processors, 8-byte alignment is required.
Compiler-generated object files preserve 8-byte alignment of the stack at all external interfaces. The compilers set a
build attribute to indicate this to the linker.
Using the Procedure Call Standard
Copyright ?1999 2001 ARM Limited 2-4