It can be necessary to access unaligned data in memory, for example, when porting legacy code from a CISC architecture where instructions are available to directly access unaligned data in memory.
On ARMv4 and ARMv5 architectures, and on the ARMv6 architecture
depending on how it is configured, care is required when accessing
unaligned data in memory, to avoid unexpected results. For example,
when a conventional pointer is used to read a word in C or C++ source code,
the ARM compiler generates assembly language code that reads the
word using an
LDR instruction. This works as
expected when the address is a multiple of four, for example if
it lies on a word boundary. However, if the address is not a multiple
of four, the
LDR instruction returns a rotated
result rather than performing a true unaligned word load. Generally,
this rotation is not what the programmer expects.
On ARMv6 and later architectures, unaligned access is fully supported.