Reputation: 143
I am reading a source code and find the instructions below but I don't understand what it does. Could someone please help me to understand it?
stp x19, x20, [x8], #16
If only stp x19, x20, [x8]
I can understand.
Upvotes: 9
Views: 18602
Reputation: 23870
It's called the "post-index" variant, and it modifies the address after storing.
The following two are equivalent:
stp x19, x20, [x8], #16
stp x19, x20, [x8]
add x8, x8, #16
There is also a pre-index variant that modified the address before storing.
Again, these two are equivalent:
stp x19, x20, [x8, #16]!
add x8, x8, #16
stp x19, x20, [x8]
In my experience, this is most commonly used for pushing and popping stack frames like so:
some_func:
stp x29, x30, [sp, #-0x10]!
// ...
ldp x29, x30, [sp], #0x10
ret
Most forms of single-register ldr
and str
also have these variants, for more information see section C1.3.3 ("Load/Store addressing modes") in the ARMv8 Reference Manual.
Upvotes: 18