1. Register R13 is often used as a stack pointer in ARM instructions
2. For the R13 register, it corresponds to 6 different physical registers, one of which is shared by the user mode and the system mode, and the other 5 physical registers correspond to the other 5 different operating modes. The following symbols are used to distinguish different physical registers:
R13_
Among them, mode is one of the following modes: usr, fiq, irq, svc, abt, und.
3. Register R13 is often used as a stack pointer in ARM instructions, but this is just a customary usage. Users can also use other registers as stack pointers. In the Thumb instruction set, some instructions require the use of R13 as a stack pointer. Since each operating mode of the processor has its own independent physical register R13, in the initialization part of the user application, it is generally necessary to initialize R13 in each mode to point to the stack space of the operating mode. In this way, when the program enters the exception mode, the registers that need to be protected can be placed in the stack pointed to by R13, and when the program returns from the exception mode, it is restored from the corresponding stack. This method can ensure the normal execution of the program after the exception occurs.
4. There are four types of stacks: A stack is a data structure that works in a First In Last Out (FILO) manner, using a special register called the stack pointer to indicate the current operation position. The stack pointer always points to the top of the stack.
When the stack pointer points to the last data pushed into the stack, it is called a full stack, and when the stack pointer points to the next empty location where data will be placed, it is called an empty stack.
At the same time, according to the way the stack is generated, it can be divided into ascending stack and descending stack. When the stack is generated from low address to high address, it is called ascending stack, and when the stack is generated from high address to low address, it is called descending stack. In this way, there are four types of stack working modes, and ARM microprocessors support these four types of stack working modes, namely:
◎ Full descending full descending stack
The stack header is a high address, and the stack grows toward lower addresses. The stack pointer always points to the last element of the stack (the last element is the last data pushed in).
The ARM-Thumb procedure call standard and the ARM and Thumb C/C++ compilers always use a Full descending type stack.
◎ Full ascending full increment stack
The stack header is a low address, and the stack grows toward higher addresses. The stack pointer always points to the last element of the stack (the last element is the last data pushed in).
◎ Empty descending empty descending stack
The stack starts at a low address and grows toward higher addresses. The stack pointer always points to the next empty location where data will be placed.
◎ Empty ascending empty ascending stack
The stack head is a high address, and the stack grows toward lower addresses. The stack pointer always points to the next empty location where data will be placed.
5. Assembly instructions for operating stacks Stack type Push instructions Pop instructions
Full descending STMFD (STMDB) LDMFD (LDMIA)
Full ascending STMFA (STMIB) LDMFA (LDMDA)
Empty descending STMED (STMDA) LDMED (LDMIB)
Empty ascending STMEA (STMIA) LDMEA (LDMDB)
example:
STMFD r13!, {r0-r5} ; Push onto a Full Descending Stack
LDMFD r13!, {r0-r5} ; Pop from a Full Descending Stack.
Previous article:ARM v7 Cortex A8 based development platform
Next article:ARM+DSP dual-core processor application strategy
Recommended ReadingLatest update time:2024-11-16 22:25
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- What exactly is the UWB "One-Finger Connection" technology released by Xiaomi? What is its use?
- 【PLC based on IoT】---Burn IIOT OS for PLC master control
- Friends who want to switch from industry to finance and invest in semiconductors, please read this
- switch
- Practical book "Design and Application of Switching Power Supply"
- The clock configured by STM32CubeMX is inaccurate?
- Get a 2,000 yuan ticket for free! Exclusive benefits for EEWorld netizens
- About GRBL host computer transmission protocol
- MicroPython now supports Ethernet peripherals on ST development boards
- Double gift for appointment viewing: In-depth analysis of network analyzer calibration basics and professional tips