Keil Logo


5.11 Alignment

Data and code must be aligned to appropriate boundaries.

For example, The T32 pseudo-instruction ADR can only load addresses that are word aligned, but a label within T32 code might not be word aligned. You must use an alignment directive to ensure four-byte alignment of an address within T32 code.

An alignment directive aligns the current location to a specified boundary by padding with zeros or NOP instructions.


The integrated assembler sets a minimum alignment of 4 bytes for a .text section. However, if you define your own sections with the integrated assembler, then you must include the .balign directive to set the correct alignment. For a section containing T32 instructions, set the alignment to 2 bytes. For a section containing A32 instructions, set the alignment to 4 bytes.

armasm syntax

armasm syntax assembly provides the ALIGN n directive, where n specifies the alignment boundary in bytes. For example, the directive ALIGN 128 aligns addresses to 128-byte boundaries.

armasm syntax assembly also provides the PRESERVE8 directive. The PRESERVE8 directive specifies that the current file preserves eight-byte alignment of the stack.

GNU syntax

GNU syntax assembly provides the .balign n directive, which uses the same format as ALIGN.

Convert all instances of ALIGN n to .balign n.


GNU syntax assembly also provides the .align n directive. However, the format of n varies from system to system. The .balign directive provides the same alignment functionality as .align with a consistent behavior across all architectures.

Convert all instances of PRESERVE8 to .eabi_attribute Tag_ABI_align_preserved, 1.

Non-ConfidentialPDF file icon PDF version100068_0616_01_en
Copyright © 2014–2021 Arm Limited or its affiliates. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.