SPRUI03E June 2015 – January 2023
Align SPC on the Next Boundary
.align [size in bytes]
The .align directive aligns the section program counter (SPC) on the next boundary, depending on the size in bytes parameter. The size can be any power of 2, although only certain values are useful for alignment. An operand of 1 aligns the SPC on the next byte boundary, and this is the default if no size in bytes is given. The size in bytes must equal a power of 2; the value must be between 1 and 32,768, inclusive. The assembler assembles words containing null values (0) up to the next size in bytes boundary:
1 | aligns SPC to byte boundary |
2 | aligns SPC to halfword boundary |
4 | aligns SPC to word boundary |
8 | aligns SPC to doubleword boundary |
Using the .align directive has two effects:
This example shows several types of alignment, including .align 2, .align 8, and a default .align.
1 00000000 00000004 .byte 4
2 .align 2
3 00000002 00000045 .string "Errorcnt"
00000003 00000072
00000004 00000072
00000005 0000006F
00000006 00000072
00000007 00000063
00000008 0000006E
00000009 00000074
4 .align
5 00000008 0003746E .field 3,3
6 00000008 002B746E .field 5,4
7 .align 2
8 0000000c 00000003 .field 3,3
9 .align 8
10 00000010 00000005 .field 5,4
11 .align
12 00000011 00000004 .byte 4