Reputation: 41
What's the result of these instructions? (Any suggestions how I could answer this myself by just running my code?)
STR.W R8, [R3], #4
STR.W R8, [R3], #4
STR.W R8, [R3], #4
STR.W R8, [R3], #4
STR.W R8, [R3], #4
STR.W R8, [R3], #4
STR.W R8, [R3]
I know that each instruction would load a value of R3 into R8 make an increment by 4 to R3 but what I am confused is that at the end of these instuctions what's the value containing in R8?
Is it [R3 + 16]? or it is [R3+4], [R3+8], ..., [R3+16]?
Upvotes: 0
Views: 5728
Reputation: 1879
what's the value containing in R8?
Always the same value, you didn't change it. You're always changing the memory value pointed by R3.
Reviewing the code:
STR.W R8, [R3], #4 /* *r3 ← r8 then r3 ← r3 + 4 */
Just as ARM documentation says:
STR{type}{cond} Rt, [Rn], #offset ; post-indexed
Another thing would be:
STR.W R8, [R3, +#4] /* *r3 ← r8 + 4 */
STR{type}{cond} Rt, [Rn {, #offset}] ; immediate offset
At last:
STR.W R8, [R3, #4]! /* r3 ← r3 + 4 then *R3 ← R8 */
STR{type}{cond} Rt, [Rn, #offset]! ; pre-indexed
I hope your doubt were on this direction.
Regards.
Upvotes: 0
Reputation: 8116
STR.W R8, [R3], #4
This instruction stores the 32-bit value held in r8
to the address held in r3
. It then adds the immediate value 4
to r3
.
A8.6.195 STR (register)
Store Register (register) calculates an address from a base register value
and an offset register value, stores a word from a register to memory. The
offset register value can optionally be shifted. For information about memory
accesses see Memory accesses on page A8-13.
Encoding T2 ARMv6T2, ARMv7
STR<c>.W <Rt>,[<Rn>,<Rm>{,LSL #<imm2>}]
STR<c><q> <Rt>, [<Rn>], <Rm>{, <shift>} Post-indexed: index==FALSE, wback==TRUE
Upvotes: 6