understanding of the arm stack
Stacks are strictly supposed to be called stacks, and stacks are linear tables that limit the insertion or deletion of an operation at one end. Therefore, for the stack, one end of the insert or delete operation can be called the top of the stack, and accordingly, the other end is called the bottom of the stack (bottom). Empty tables that do not contain elements are called empty stacks. Since the stack is only allowed to operate at one end, it operates in the principle of LIFO (Lifo-last in First out).
From the definition of the top of the stack, the position of the top of the stack is variable. Empty stack, stack top and bottom overlap, when full stack, the top of the stack is farthest from the bottom of the stack. ARM provides hardware support for the stack, which uses a dedicated register (stack pointer) to point to the stack's top. and 7 modes have their own stack pointers, which are separate stack spaces. But here the stack and the Uc/os operating system task stack is different, uc/os each task has its own stack, if the Uc/os ported to arm, you can use arm's stack pointer to achieve. The memory stack can be divided into two types:
Grow up: Grow to high address direction, called increment stack
Grow down: Grow to a low address direction, called descending stack
The stack pointer points to a valid data item for the last pressed stack, called a full stack , and a stack pointer to the next empty position to be placed, called an empty stack . Thus there are 4 types of stacks representing the various combinations of incrementing and decreasing full stacks and empty stacks.
Full increment : The stack grows upward by increasing the address of the memory, and the stack pointer points to the highest address that contains the valid data item. Directives such as LDMFA,STMFA.
empty increment : The stack grows upward by increasing the address of the memory, and the stack pointer points to the first empty position on the stack. Directives such as Ldmea,stmea.
full decrement : The stack grows downward by decreasing the address of the memory, and the stack pointer points to the lowest address that contains the valid data item. Directives such as LDMFD,STMFD.
NULL decrement : The stack grows downward by decreasing the address of the memory, and the stack pointer points to the first empty position under the stack. Directives such as ldmed,stmed.
Why say "grow up" and "Grow downward"? It is thought that the general picture of the stack diagram is to draw the low address below, high-address painting on top. The following figure.
It is important to note that although the ARM processor core is supported for both the stack of growth modes, the C language compiler of ads only supports one way, that is, from the top down, and must be a full descending stack. So stmfd and other commands are used most.