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.
For example, 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.
LDR pseudocommands and LDR loading commands in arm
In the arm instruction set, LDR is usually used as the loading command, but it can also be used as a pseudo command.
The form of the LDR pseudo command is "ldr rn, = expr ". The following is an example to describe its usage.
Count equ 0x40003100
......
LDR R1, = count
MoV r0, #0
STR r0, [R1]
Count is a defined variable with the address 0x40003100. This definition method is very common in assembly languages. If you have used a single-chip microcomputer, you should be familiar with this usage.
LDR R1, = count is to put the address of the variable count, that is, 0x40003100 into R1.
MoV r0, #0 is to put the immediate number 0 into R0. In the last sentence, STR r0, [R1] is a typical storage command that places the value in R0 to the storage unit with the value in R1 as the address. Actually, 0 is put in the storage unit with the address 0x40003100. The three commands are used to assign values to the variable count. It seems uncomfortable to assign values to a variable using three commands. This may be related to the arm's use of RISC.
The following is an example.
; Assign the Count value to R0
LDR R1, = count
LDR r0, [R1]
LDR R1, = count: how to assign the Count address to R1? If you are interested, see the compiled result. This command is actually compiled into a LDR command and a DCD pseudocommand.
Ldr pc, = myhandleirq indicates to put the myhandleirq symbol into the PC register 2) ldr pc, myhandleirq indicates to read the value in the address indicated by the myhandleirq symbol in the memory, and the memory needs to be read once more.
In the arm instruction set, LDR is usually used as the loading command, but it can also be used as a pseudo command.
The form of the LDR pseudo command is "ldr rn, = expr ". The following is an example to describe its usage.
Count equ 0x40003100
......
LDR R1, = count
MoV r0, #0
STR r0, [R1]
Count is a defined variable with the address 0x40003100. This definition method is very common in assembly languages. If you have used a single-chip microcomputer, you should be familiar with this usage.
LDR R1, = count is to put the address of the variable count, that is, 0x40003100 into R1.
MoV r0, #0 is to put the immediate number 0 into R0. In the last sentence, STR r0, [R1] is a typical storage command that places the value in R0 to the storage unit with the value in R1 as the address. Actually, 0 is put in the storage unit with the address 0x40003100. The three commands are used to assign values to the variable count. It seems uncomfortable to assign values to a variable using three commands. This may be related to the arm's use of RISC.
The following is an example.
; Assign the Count value to R0
LDR R1, = count
LDR r0, [R1]
LDR R1, = count: how to assign the Count address to R1? If you are interested, see the compiled result. This command is actually compiled into a LDR command and a DCD pseudocommand.
Ldr pc, = myhandleirq indicates to put the myhandleirq symbol into the PC register 2) ldr pc, myhandleirq indicates to read the value in the address indicated by the myhandleirq symbol in the memory, and the memory needs to be read once more.