What does the exclamation mark mean in the end of an A64 instruction?

Serge Rogatch picture Serge Rogatch · Sep 29, 2016 · Viewed 8k times · Source

The documentation for LDP and STP gives an example instruction with an exclamation mark in the end:

LDP X8, X2, [X0, #0x10]!

Also the documentation about porting A32 PUSH/POP instructions into A64 gives the following examples:

PUSH {r0-r1} ---> STP X0, X1, [SP, #-16]!
POP {r0-r1}  ---> LDP X0, X1, [SP], #16

Neither of the pages explains what the exclamation mark in the end of the instructions means. What does it?

Answer

Dric512 picture Dric512 · Sep 30, 2016

The ! means "Register write-back": the base register is used to calculate the address of the transfer, and is updated.

In your example:

LDP X8, X2, [X0, #0x10]!

X0 modified so that after the operation:

X0 = X0 + 0x10

If you do not put the !, X0 is not modified by the operation.

On the second example concerning PUSH/POP, the difference is when the increment is done:

STP X0, X1, [SP, #-16]! stores at address SP-16, and SP is decremented in the same way

LDP X0, X1, [SP], #16 loads from address SP, and after the transfer is performed, stores SP+16 to SP.