1.Offset form: Immediate value as the offset 偏移形式:将立即数作为偏移
Addressing mode: Offset 寻址模式:偏移寻址
Addressing mode: Pre-indexed 寻址模式:先索引寻址
Addressing mode: Post-indexed
寻址模式:后索引寻址
2.Offset form:Register as the offset
偏移形式:将寄存器作为偏移
Addressing mode: Offset
寻址模式:偏移寻址
Addressing mode: Pre-indexed 寻址模式:先索引寻址
Addressing mode: Post-indexed
寻址模式:后索引寻址
3.Offset form:Scaled register as the offset 偏移形式:将移位寄存器作为偏移
Addressing mode: Offset
寻址模式:偏移寻址
Addressing mode: Pre-indexed 寻址模式:先索引寻址
Addressing mode: Post-indexed 寻址模式:后索引寻址
Generally, LDR is used to load something from memory into a register, and STR is used to store something from a register to a memory address.
LDR operation: loads the value at the address found in R0 to the destination register R2.
STR operation: stores the value found in R2 to the memory address found in R1.
This is how it would look like in a functional assembly program:
When we load something into a register, the brackets ([ ]) mean: the value found in the register between these brackets is a memory address we want to load something from.
When we store something to a memory location, the brackets ([ ]) mean: the value found in the register between these brackets is a memory address we want to store something to.
The next STR operation uses the pre-indexed address mode. You can recognize this mode by the exclamation mark (!). The only difference is that the base register will be updated with the final memory address in which the value of R2 will be stored. This means, we store the value found in R2 (0x3) to the memory address specified in R1 (0x1009c) + the offset (#4) = 0x100A0, and update R1 with this exact address.
The last LDR operation uses the post-indexed address mode. This means that the base register (R1) is used as the final address, then updated with the offset calculated with R1+4. In other words, it takes the value found in R1 (not R1+4), which is 0x100A0 and loads it into R3, then updates R1 to R1 (0x100A0) + offset (#4) = 0x100a4.