|Home > armclang Integrated Assembler > Alignment directives|
The alignment directives align the current location in the file to a specified boundary.
This specifies the number of bytes that must be aligned to. This must be a power of 2.
This specifies the alignment boundary as an exponent. The actual alignment
The value to fill any inserted padding bytes with. This value is optional.
The alignment directives align the current location in the file to a specified boundary. The unused space between the previous and the new current location are filled with:
fill_value, if it is specified. The width of
fill_valuecan be controlled with the
lsuffixes, see below.
fill_valueargument is not specified.
lsuffix is not specified.
.balign directive takes an absolute number of bytes as
its first argument, and the
takes a power of 2. For example, the following directives align the current location
to the next multiple of 16 bytes:
l suffixes modify the width of
the padding value that will be inserted.
fill_valueis a 1-byte value.
wsuffix is specified, the
fill_valueis a 2-byte value.
lsuffix is specified, the
fill_valueis a 4-byte value.
If either of these suffixes are specified, the padding values are emitted as data (defaulting to a value of zero), even if following an instruction.
.align directive is an alias for
.p2align, but it does not accept the
Alignment is relative to the start of the section in which the directive occurs. If the current alignment of the section is lower than the alignment requested by the directive, the alignment of the section will be increased.
Use the alignment directives to ensure that your data and code are aligned to appropriate boundaries. This is typically required in the following circumstances:
.balign 4to ensure 4-byte alignment of an address within T32 code.
.balign 16to align function entry points on 16-byte boundaries to maximize the efficiency of the cache.
Aligning a constant pool value to a 4-byte boundary in T32 code:
get_val: ldr r0, value adds r0, #1 bx lr // The above code is 6 bytes in size. // Therefore the data defined by the .word directive below must be manually aligned // to a 4-byte boundary to be able to use the LDR instruction. .p2align 2 value: .word 42
Ensuring that the entry points to functions are on 16-byte boundaries, to better utilize caches:
.p2align 4 .type func1, "function" func1: // code .p2align 4 .type func2, "function" func2: // code