Assembler User GuidePreface Overview of the Assembler Overview of the ARM Architecture About the ARM architecture ARM, Thumb, and ThumbEE instruction sets Changing between ARM, Thumb, and ThumbEE state Processor modes, and privileged and unprivileged s Processor modes in ARMv6-M and ARMv7-M VFP hardware ARM registers General-purpose registers Register accesses Predeclared core register names Predeclared extension register names Predeclared coprocessor names Program Counter Application Program Status Register The Q flag Current Program Status Register Saved Program Status Registers ARM and Thumb instruction set overview Access to the inline barrel shifter Structure of Assembly Language Modules Writing ARM Assembly Language Condition Codes Using the Assembler Symbols, Literals, Expressions, and Operators VFP Programming Assembler Command-line Options ARM and Thumb Instructions VFP Instructions Directives Reference Via File Syntax
2.8 General-purpose registers
There are restrictions on the use of SP and LR as general-purpose registers.
With the exception of ARMv6-M and ARMv7-M based processors, there are 30 (or 32 if Security Extensions are implemented) general-purpose 32-bit registers, that include the banked SP and LR registers. Fifteen general-purpose registers are visible at any one time, depending on the current processor mode. These are R0-R12, SP, LR. The PC (R15) is not considered a general-purpose register.
SP (or R13) is the stack pointer. The C and C++ compilers always use SP as the stack pointer. Use of SP as a general purpose register is discouraged. In Thumb, SP is strictly defined as the stack pointer. The instruction descriptions mention when SP and PC can be used.
In User mode, LR (or R14) is used as a link register to store the return address when a subroutine call is made. It can also be used as a general-purpose register if the return address is stored on the stack.
In the exception handling modes, LR holds the return address for the exception, or a subroutine return address if subroutine calls are executed within an exception. LR can be used as a general-purpose register if the return address is stored on the stack.
When using the
of your data.