I found that some netizens are wrong about the ldr instruction in ARM.

Publisher:开元轩Latest update time:2016-07-13 Source: eefocusKeywords:ARM Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
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. For example, if you want to read data from somewhere in memory to a register, you can only use ldr, such as:

 

ldr r0, 0x12345678

 

That is, store the value at the address 0x12345678 into r0. However, mov cannot achieve this function. mov can only move data between registers, or move immediate values ​​into registers. This is the biggest difference from CISC architecture chips such as x86. There is no such instruction as ldr in x86, because the mov instruction of x86 can move data from memory to registers. There is


also 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 a value (usually an address) is written to a register, for example:
ldr r0, =0x12345678

 

 

In this way, the value 0x12345678 is written to r0. Therefore, the ldr pseudo-instruction is similar to mov. The only difference is that the mov instruction limits the length of the immediate number to 8 bits, which means it cannot exceed 512. The ldr pseudo-instruction does not have this limitation. If the ldr pseudo-instruction is used and the immediate number following it does not exceed 8 bits, then the ldr pseudo-instruction will be converted to a mov instruction during actual assembly. In fact, it is not accurate to say that the ldr instruction can load a 32-bit immediate number, because it is not actually this statement that loads a 32-bit immediate number. 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 number 0x12345678. And if this immediate number can be expressed in the form of a mov instruction, it will be actually replaced by mov by the compiler, for example:
ldr r1,=0x10
will become
mov r1,#0x10

In summary: The ldr pseudo-instruction is used to load a 32-bit immediate value or an address value into a specified register. When assembling a source program, the ldr pseudo-instruction is replaced by a suitable instruction by the compiler. If the loaded constant does not exceed the range of mov or mvn, the mov or mvn instruction is used to replace the ldr pseudo-instruction, otherwise the assembler puts the constant into a literal pool and uses a program-relative offset ldr instruction to read the constant from the literal pool. The ldr pseudo-instruction and the ldr instruction are not the same thing.
Keywords:ARM Reference address:I found that some netizens are wrong about the ldr instruction in ARM.

Previous article:Comparison of ARM and X86 architecture terminal features
Next article:How to use LDR in ARM

Recommended ReadingLatest update time:2024-11-16 16:48

Development of seismic intensity meter based on IPv6 and ARM9
Using low-power miniature capacitive tri-axial accelerometer as the sensing component, an ARM9-based embedded system with customized Linux as the master control system, and wireless communication technology that complies with the 802.11b standard as the network access method of the instrument, we have developed an SI-
[Microcontroller]
Development of seismic intensity meter based on IPv6 and ARM9
Immediate values ​​in ARM assembly
A colleague encountered such a problem: In the assembly code compiled by eVC, I saw the following statements:  mov r2, #0xFF, 28 and orr r2, r2, #0xB.  The result is r2 = #0xffb. He tried to optimize it more directly to one sentence: MOV r2, #0xffb  . But then the compilation went wrong: error A0092: no immediate
[Microcontroller]
ARM embedded development board automobile energy-saving control system
introduction   Due to various reasons, buses always repeat the process of acceleration-deceleration or parking-reacceleration. By installing this energy-saving device, when the car needs to brake, under the control of the main control unit, the huge kinetic energy of the car when driving can be converted into the po
[Analog Electronics]
ARM embedded development board automobile energy-saving control system
Keil (MDK-ARM) series tutorial (IV)_Project target option configuration (II)
II. C/C++ Options Among the following five options, C/C++ is the most important, so some functions need to be emphasized. Looking at the option title "C/C++", it is mainly aimed at C/C++, which is similar to the next option "Asm". No. 1: Preprocessor Symbols The main thing here is to predefine functions, which is eq
[Microcontroller]
Keil (MDK-ARM) series tutorial (IV)_Project target option configuration (II)
Development of uCLinux system in ARM-based embedded devices
1 Introduction Information appliances and handheld devices have greatly accelerated the development of embedded systems, and the ARM system 32-bit high-performance, low-power processor and embedded operating system Linux have undoubtedly become the best. Because the Linux source code is open and free, anyone wh
[Microcontroller]
Development of uCLinux system in ARM-based embedded devices
Design of circuit module of fingerprint attendance system based on ARM7
  The attendance system has now become a must-have equipment for many companies, but the traditional attendance system is prone to replacing punching and swiping cards. The new fingerprint attendance machine completely avoids this situation. This article introduces a solution for designing a fingerprint attendance mac
[Microcontroller]
Design of circuit module of fingerprint attendance system based on ARM7
ARM startup code principle and analysis
Contents Content keywords: Image File RO Code Snippet ZI uninitialized data segment RW data segment Load Address Execu on A ddress Stack Pointer Stack space pointer Boot related hardware • Flash Rom (can be used as bootrom storage) Boot related hardware Boot related hardware Main functions of Boot •
[Microcontroller]
ARM startup code principle and analysis
Development of a real-time simulation platform based on ARM and DSP embedded systems
introduction A large ship engine simulator contains more than 30 mathematical models of full physical processes, involving more than a thousand real-time parameters, and is usually implemented using a decentralized DCS network. Even so, individual simulation workstations are difficult to meet the requirements o
[Microcontroller]
Development of a real-time simulation platform based on ARM and DSP embedded systems
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号