In calculating which word of memory is to be accessed, the ARM adds together the contents of the base and offset registers. It is sometimes useful to retain this newly calculated address for future use. In pre-indexed addressing, this is done by using the ARM's 'write back' facility.
Write back is specified with the '!' suffix.
Examples:
LDR R0,[R1,R2]! Load R0 from address R1+R2 : R1=R1+R2
STR R3,[R5,#10]! Store R3 at address R5+R10 : R5=R5+10
LDR R7,[R3,R8,LSL#2]! Load R7 from address R3+R8*4 : R3=R3+R8*4
When the ARM executes the instruction, it will perform the usual addition of the base and offset fields. It will then access the data at the newly calculated address. Finally, as write back is selected, it will store the newly calculated address back into the base register.
Write back is particularly useful when accessing a sequence of memory locations, e.g., to access consecutive memory words we can use 'LDR R0,[base,#4]!'. Write back hence allows the easy creation and access of arrays.
|
|
|