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.
This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.
ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.