|Home > Using armasm > Address alignment in A64 code|
If alignment checking is not enabled, then unaligned accesses are permitted for all load and store instructions other than exclusive load, exclusive store, load acquire, and store release instructions. If alignment checking is enabled, then unaligned accesses are not permitted.
This means all load and store instructions must use addresses that are aligned to the size of the data being accessed. In other words, addresses for 8-byte transfers must be 8-byte aligned, addresses for 4-byte transfers are 4-byte word aligned, and addresses for 2-byte transfers are 2-byte aligned. Unaligned accesses cause an alignment exception.
For any memory access, if the stack pointer is used as the base register, then it must be quadword aligned. Otherwise it generates a stack alignment exception.
If all your data accesses are aligned, you can use the
--no_unaligned_access command-line option to declare that the output
object was not permitted to make unaligned access. The linker can then avoid linking in any
library functions that support unaligned access if all input objects declare that they were
not permitted to use unaligned accesses.