LDR (load Register) instruction loads the contents of memory into the general register
The STR (store register) instruction stores the register contents in memory space
#define GPJ0CON 0xe0200240
_start:
Ldr R0, =0x11111111 // will immediately count/illegal immediate number, assigned to R0
LDR R1, =gpj0con // assigns Gpj0con address to R1
STR r0, [R1] // Register Indirect addressing. Writes the number in the R0 to the number in the R1 address in memory
LDR R0,[R1] //assigns the value of R1 to R0,arm is a RISC structure, and the movement of data from memory to CPU can only be done by LDR/STR instructions. But to read the data from somewhere in memory to register, only use LDR, MOV can only move data between registers, or move the number of immediate to register, such as mov r0, #0是将立即数0放到r0中
1, LDR and MOV different: Ldr can read the data from memory to the CPU, or read from memory somewhere in the register, and MOV can only move data between registers, or to move the number of immediate to register, such as mov r0, #0是将立即数0放到r0中;
2, MOV is from a register or a shift register or the value of the immediate number of the transfer to another register. But not all immediate numbers can be passed, the immediate number to match the value of a 8-digit cyclic right-shift even digit. The reason is that the Mov itself is a 32bit instruction, in addition to the instruction code itself, it is not possible to carry a number that can represent 32bit, so the 12bit is used to represent the immediate number, where 4bit represents the number of bits shifted (loop right shift, and the value is multiplied by 2), The 8bit is used to represent a cardinality to be shifted. For LDR Pseudo-instructions, you can add = before the immediate number, to indicate that an address is written to a register, such as: Ldr R0, =0x12345678 So, 0x12345678 this address is written to R0. LDR pseudo-directives and mov are more similar, but the MOV directive limits the length of the immediate number to 8 bits, which means that no more than 512. The LDR pseudo-directive does not have this limitation. If the LDR pseudo-directive is used and the immediate number followed is not more than 8 bits, then the LDR pseudo-directive is converted to the MOV instruction at the time of the actual assembly.
3. The method of addressing the LDR directive is classified as:
LDR R0,[R1]//read-in register of data with memory address R1 R0
LDR R0,[R1,R2]//read-in register of data with memory address R1+R2 R0
LDR r0,[r1, #8]//read-in register of data with memory address r1+8 R0
LDR R0,[R1],R2//reads the data from the memory address R1 into the register R0 and stores the R1+R2 value in R1
LDR R0,[R1], #8//Read the memory address R1 data into the register R0 and save the R1+8 value R1
LDR r0,[r1,r2]! Reads the data of the memory address R1+R2 into the register R0 and stores the value of R1+R2 in R1
LDR R0,[R1,LSL #3]//read-in register of data with memory address r1*8 R0
LDR R0,[R1,R2,LSL #2]//read-in register of data with memory address r1+r2*4 R0
LDR R0,[R1,,R2,LSL #2]! Reads the data of the memory address r1+r2*4 into the register R0 and stores the value of r1+r2*4 in R1
LDR R0,[R1],R2,LSL #2//reads the memory address R1 data into the register R0 and stores the r1+r2*4 value in R1
LDR R0,label//label is a program designator and the label must be within the -4~4KB range of the current directive
LDR, str instructions