Arm data stack usage rules
The data stack has two growth directions: When the memory address is reduced, it is called the descending stack; when the memory address is increased, it is called the ascending stack.
The growth direction of the data stack is the mobile Stack pointer. When the stack pointer points to the top element of the stack (the data in the last stack), it is called the full stack; when the stack pointer points to the top element of the stack (the data in the last stack) an adjacent empty data unit is called the empty stack.
Based on these two points, data stacks can be divided into the following four types.
1. FD: Full descending, full decrease.
2. ED: Empty descending, empty decreasing.
3. Fa: Full ascending, increasing at full scale.
4. Ea: Empty ascending, with null increments.
Arm's atpcs stipulate that the data stack is of the FD type and the operations on the data stack are 8-byte aligned. Use the batch dB/ldmia command to access the memory in batches to operate the FD data stack.
When you use the analytic dB command to save the content to the data stack, first decrease the SP pointer, then save the data. When you use the ldmia command to restore data from the data stack, first obtain the data and then increase the SP pointer, the SP pointer always points to the top element of the stack, which is exactly the definition of the FD stack.