5.6.2.1 .align algn[, fill[, max-skip]]

Pad the location counter (in the current subsection) to a particular storage boundary.

algn is the address alignment required. The location counter is advanced until it is a multiple of the requested alignment. If the location counter is already a multiple of the requested alignment, no change is needed or made. In a code section, an alignment of 2 is required to align to the next instruction word. The requested alignment must be a power of 2.

fill is optional. If not specified:

  • In a data section, a value of 0x00 is used to fill the skipped bytes.
  • In a code section, the last specified .fillvalue is used to fill the lower two bytes of program memory and the last specified .fillupper is used to fill the upper program memory byte.

max-skip is optional. If specified, it is the maximum number of bytes that should be skipped by this directive. If doing the alignment would require skipping more bytes than the specified maximum, then the alignment is not done at all.

Alignment within a section is required for modulo addressing. It is worth noting that the overall section alignment reflects the greatest alignment of any .align directives that are included. Further, the assembler must pad out the section length to match its alignment. This is done in order to preserve the requested alignment in case the section is combined with other sections of the same name during the link. To avoid unnecessary padding of aligned sections, use the section name *, which identifies a unique section that will never be combined.