I repeat the (summary of the) material here for review (and reminder).
Syntax Meaning of the instruction ---------------- -------------------------------------------------- ldr rN, [rM] Load 4 bytes from memory at the address given in rM into the (destination) register rN The 4 bytes are stored in the register as follows: |
Syntax Meaning of the instruction ---------------- -------------------------------------------------- str rN, [rM] Store 4 bytes from register rN to memory (consecutively) at the address given in register rM The 4 bytes are taken from the register as follows: |
Although the basic form is sufficient to access simple variable, it is not adequate when we need to compute the address of an array element using:
address of array element A[i] = base address (A) + i×size(one array element) |
Syntax and meaning of the base+offset form of the load register instruction is:
Syntax Meaning of the instruction ---------------- -------------------------------------------------- ldr rN, [rM,off] Load 4 bytes from memory at the address given by rM+off into the (destination) register rN The 4 bytes are stored in the register as follows: |
For offset, you can use:
|
How to use the base + offset form of the load instruction to access array elements:
|
Syntax and meaning of the base+offset form of the store register instruction is:
Syntax Meaning of the instruction ---------------- -------------------------------------------------- str rN, [rM,off] Store 4 bytes from register rN to memory (consecutively) at the address given by the sum rM+off The 4 bytes are taken from the register as follows: |
For offset, you can use:
|
How to use the base + offset form of the store instruction to update an array element:
|