MoV assigns an immediate number to a register, but it requires a range of immediate numbers. It can only be the number of 8-bit continuous valid bits that can be obtained through an even number of shifts. If the number of values exceeds the value range, an mov command cannot be used to assign values to the Register.
In addition to normal reading, LDR also provides the function of assigning an immediate number to the Register.
You only need to write LDR r0, = 0 xabcdef
It has no limit on the number range. This is a pseudo command. If the immediate number is within the mov requirement, it will be implemented using an assembly. If it is not within the mov range, it is implemented in other ways, such as converting it into two commands, or reading a 32-digit register from the PC offset address.
MoV is transmitted from a register or a shift register or an immediate number value to another register.
In essence, it is the transfer of registers to registers. Why is there an immediate number? In fact, there are limits on the immediate number. Not all immediate numbers can be passed.
The immediate number must conform to the value of an 8-digit loop with an even number shifted to the right.
The reason is that mov itself is a 32bit command. Apart from the instruction code itself, it cannot contain a number that can represent 32bit. Therefore, it uses 12bit to represent the immediate number, here, 4-bit indicates the number of digits to be shifted (cyclic right shift, and the value is x2), and 8-bit indicates a base number to be shifted.
Another point is about LDR. In fact, it is not accurate to say that LDR can load a 32bit immediate number, because this statement does not actually load a 32bit immediate number, such
LDR R1, = 0x12345678
In fact, the real CompilationCodeIs to pass the value of an address to R1, that is, an address needs to store the immediate number 0x12345678, which can be considered as a pseudo command.
And if the immediate number can be expressed in the form of mov commands, it will be replaced by mov In the compiler.
For example:
LDR R1, = 0x10
Will become
MoV R1, #0x10
The arm is a hierarchical structure. The movement of data from memory to CPU can only be completed through the L/s command, that is, the LDR/STR command. To read data from somewhere in the memory to a register, you can only use LDR. For example:
LDR r0, 0x12345678
Store the value in 0x12345678 to R0.
But mov cannot do this job. mov can only move data between registers, or move the immediate number to the Register, which is the most different from the chip of the CISC architecture such as x86. There is no LDR command in x86, because the mov command of X86 can move data from memory to registers.
The other is the LDR command. Although the LDR command is similar to the arm's LDR command, it does not play the same role. The LDR pseudo command can add = before the immediate number to write an address to a register. For example:
LDR r0, = 0x12345678
In this way, the address 0x12345678 is written to R0. Therefore, LDR pseudo commands are similar to mov commands. However, the mov command limits the length of the immediate number to 8 bits, that is, it cannot exceed 512. The LDR Directive does not have this restriction. If the number of immediate digits following the LDR command does not exceed 8 bits, the LDR command is converted to mov command during actual compilation.
The LDR Directive and the LDR directive are not the same thing.