Keil™, An ARM® Company

RealView Compiler User's Guide

Alignment support

4.8.2. Alignment support

By default, the compiler uses ARMv6 unaligned access support to speed up access to packed structures, by allowing LDR and STR instructions to load from and store to words that are not aligned on natural word boundaries.

You can control alignment support in ARMv6 directly from the processor core using the U and A bits in CP15 register 1. Four combinations are possible:

U=0, A=0 in CP15 register 1

Enables legacy or pre-ARMv6 alignment mode, where unaligned loads rotate loaded values.

This mode of operation is supported in RVCT only when the device you select on the compiler command line option is based on the ARM v5TE architecture.

Note

When compiling for devices based on the ARM v5TE architecture, be aware that ARMv6 instructions cannot be used.

U=0, A=1 in CP15 register 1

Enables modulo eight alignment checking without unaligned accesses.

This mode of operation is not supported by the RVCT toolset.

U=1, A=0 in CP15 register 1

Enables unaligned support on the ARM core. Alternatively, you can enable unaligned accesses from reset by tying the UBITINIT input to the core HIGH.

Note

Code compiled using the default options for ARMv6 only runs correctly if unaligned support is enabled on the ARM core.

U=1, A=1 in CP15 register 1

Enables modulo four alignment checking on an ARMv6 target without unaligned accesses.

When modulo four alignment checking is enabled, your must compile your code using the appropriate option:

  • --memaccess -UL41 for RVCT 2.x

  • --no_unaligned_access for RVCT 3.0 and later.

Note

The --memaccess option is deprecated and will be removed in a future release.

For more information see:

Copyright © 2007 ARM Limited. All rights reserved.ARM DUI 0375A