In addition to normal reading, LDR also has the function of assigning immediate values to registers.
You just need to write LDR R0, = 0xabcdef
It has no immediate range limit because it is a pseudo instruction. If the immediate value is within the requirements of MOV, it can be implemented in one assembly. If it is not within the range of MOV, it can be implemented in other ways, such as turning it into two instructions, or reading a 32-bit number from the PC offset address to a register.
MOV is to transfer the value of a register or shift register or immediate value to another register. It
is essentially a transfer from register to register. Why is there an immediate value? In fact, there are also limited immediate values. Not all immediate values can be transferred.
This immediate value must conform to the value of an 8-bit number that is circularly shifted right by an even
number of bits. The reason is that MOV itself is a 32-bit instruction. In addition to the instruction code itself, it is impossible to carry a number that can represent 32 bits, so 12 bits are used to represent the immediate value, of which 4 bits represent the number of bits to be shifted (circularly shifted right, and the value is x2), and 8 bits are used to represent a base number to be shifted.
Another point about ldr is that it is not accurate to say that ldr can load a 32-bit immediate value, because it is not actually this statement that loads a 32-bit immediate value. For example,
ldr r1, =0x12345678.
In fact, the real assembly code is to pass the value of a certain address to r1, which means that an address is needed to store the immediate value 0x12345678. It can actually be regarded as a pseudo instruction.
And if this immediate value can be expressed in the form of a mov instruction, it will be replaced by mov by the compiler.
For example:
ldr r1, =0x10
will become
mov r1, #0x10
ARM is a RISC structure. The movement of data from memory to CPU can only be completed through L/S instructions, that is, ldr/str instructions. If you want to read data from somewhere in memory to a register, you can only use ldr. For example:
ldr r0, 0x12345678
That is to store the value at the address 0x12345678 in r0.
But mov can't do this job. It can only move data between registers or move immediate data into registers. This is the biggest difference from CISC architecture chips like x86. There is no ldr instruction in x86, because the mov instruction of x86 can move data from memory to register.
There is also another one, the ldr pseudo-instruction. Although the ldr pseudo-instruction is very similar to the ARM ldr instruction, its function is slightly different. The ldr pseudo-instruction can add = before the immediate value to indicate that an address is written to a register, for example:
ldr r0, =0x12345678
In this way, the address 0x12345678 is written to r0. Therefore, the ldr pseudo-instruction is similar to mov. However, the mov instruction limits the length of the immediate value to 8 bits, that is, it cannot exceed 512. The ldr pseudo-instruction does not have this limitation. If the ldr pseudo-instruction is used and the immediate value following it does not exceed 8 bits, then the ldr pseudo-instruction will be converted to the mov instruction during actual assembly.
The ldr pseudo-instruction and the ldr instruction are not the same thing.
Previous article:What is the difference between mov and ldr in arm instructions
Next article:The difference between ARM instruction set and Thumb instruction set
Recommended ReadingLatest update time:2024-11-16 15:01
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
- [In-depth] Design of a low-cost transceiver system for multi-function radar
- EEWORLD University Hall----RF Analog Circuits Yang Yumei, University of Electronic Science and Technology of China
- The zigbee terminal and the router cannot communicate with each other, but the coordinator can communicate with them
- [NXP Rapid IoT Review] + Unfortunately, connection failed
- After using MAX735 to convert +5V to -5V, the dual-power op amp is powered and -5V is pulled down to 0V
- Wi-Fi Solutions for IoT Wireless Designs
- Practical Applications of IoT
- MP28GA five-wire four-phase stepper motor debugging
- Adjustment of lv space usage in linux system lvm
- PCAD/AD library file conversion KiCad tool