In the multiple data transfer (STM, LDM) of ARM instructions, it is mentioned that the Load and Store instructions of multiple registers are divided into 2 groups:
A set of data storage and reading, corresponding to IA, IB, DA, DB,
One set is used for stack operations, corresponding to FD, ED, FA, EA,
The corresponding instructions in the two groups have the same meaning.
IA: increase after; indicates that the address increases after data transmission
IB: increase before
DA: decrease after
DB: decrease before
Right now:
STMIB (address increments first and then completes the operation)
STMFA (Full Incrementing Stack)
STMIA (Complete Operation Then Increment Address)
STMEA (empty incrementing stack)
STMDB (address is reduced first and then the operation is completed)
STMFD (full decrementing stack)
STMDA (complete operation and then decrement address)
STMED (empty decrementing stack)
The two commands in the above groups have the same meaning but are applicable to different occasions. Similarly, there are:
LDMIB, LDMED;
LDMIA, LDMFD;
LDMDB, LDMEA;
LDMDA, LDMFA.
IA mode means: after each transmission, the address is increased by 4; (After Increase)
DB mode means: before each transmission, the address is -4; (Before Decrease)
There are 8 modes for multi-register load/store instructions (4 for data block transfers and 4 for stack operations)
The STMDB and LDMIA instructions are generally used in pairs. STMDB is used to push registers onto the stack, and LDMIA is used to pop registers off the stack. Their function is to save the used registers.
Example 1:
Instruction: stmdb sp!,{r0-r12,lr}
Meaning: sp = sp - 4, first press lr, sp = lr (that is, put the content in lr into the memory address pointed to by sp). sp = sp - 4, then press r12, sp = r12. sp = sp - 4, then press r11, sp = r11...sp = sp - 4, finally press r0, sp = r0.
If you want to pop out r0-r12 and lr, you can use the ldmia instruction: ldmia sp!,{r0-r12,lr}
Example 2:
STMIA, for example, if the current memory address pointed to by r0 is 0x1000, STMIA R0!,{R1-R7} means first storing r1 at 0x1000, then r2 at 0x1004, then r3 at 0x1008. If it is a 32-bit processor, 4 bytes are added each time, and r1-r7 are stored in increasing addresses. This r0! means starting from the address of r0. STMDB means that the address decreases from r0 and is stored in sequence.
Example 3:
LDMIA:LDM means multiple register access. The following parameters are separated by “,”. The first parameter is the first address; the second parameter is the register list, which is enclosed in “{}”.
LDMIA R0!, {R1-R4}; R0 represents the first address of the storage space to be operated. The number of data to be operated is determined by the register list, which is now R1 to R4, a total of 4 data (each data is 32 bits)
specific:
The data in the storage space at address R0 is assigned to R1
The data in the storage space at address R0+4 is assigned to R2
The data in the storage space at address R0+8 is assigned to R3
The data in the storage space at address R0+12 is assigned to R4
The storage space and register status of all example instructions before execution:
mem32[0x1000C] = 0x04
mem32[0x10008] = 0x03
mem32[0x10004] = 0x02
mem32[0x10000] = 0x01
r0 = 0x00010000
r1 = 0x00000000
r3 = 0x00000000
r4 = 0x00000000
After execution, the storage space remains unchanged, but the registers change:
r0 = 0x00010010
r1 = 0x01
r2 = 0x02
r3 = 0x03
r4 = 0x04
Previous article:ARM assembly: load and store instruction set (six categories)
Next article:s3c2440——implementation of simple printf function for bare metal
Recommended ReadingLatest update time:2024-11-16 13:51
- Popular Resources
- Popular amplifiers
- Introduction to Internet of Things Engineering 2nd Edition (Gongyi Wu)
- Permanent Magnet Synchronous Motor Speed Control System Control Technology (by Hou Limin and Wang Wei)
- Implementing a Deep Learning Framework with Python (Zhang Juefei, Chen Zhen)
- A Complete Illustrated Guide to Operational Amplifier Applications (Written by Wang Zhenhong)
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
- TI assembly language problem help.usect
- Proteus associated with Keil shows that the traffic light time is distorted
- What are the career development directions after learning embedded system?
- 2 Serial port printing redirection, uncheck MicroLib program does not run problem solution
- Why do we need LoRa and NB-IoT when we have GPRS?
- Terminal Software XShell Reference Manual
- EEWORLD University Hall----EE netizens DIY works: urban youth family security guards
- 1
- Detuning Effects of Wrist-Worn Antennas and Design of Custom Antenna Measurement Systems
- Blood oxygen heart rate monitoring device based on STM32F103