>>-.---.--ALIGN--"integer-.-------.-"----------------->< +-/-+ +-FIXED-+ +--OPT--+
|integer||The distance from the start of one level-01 to the start of the next is a multiple of this. Can take any value from 1 to 255.|
|OPT | FIXED||
OPT aligns the 01 level item on a multiple of integer best suited for its size (see table below). This allows more optimal instructions to be used at machine code level for such data items.
Note: For managed COBOL code, OPT behaves as if FIXED is set.
FIXED aligns the 01 level item on the next multiple of integer.
IBMCOMP or NORM sets ALIGN"8 OPT" immediately.
DIALECT"RM" sets ALIGN"4 FIXED" immediately.
RM"ANSI" or RM sets ALIGN"2 FIXED" immediately.
Data items of level-01 are aligned on byte boundaries that are multiples of the value given.
This can help produce more efficient execution results but does mean more memory might be used.
The following table show the boundary on which an item will be aligned depending on their size and the directive setting
|01 level item size||ALIGN"1 OPT"||ALIGN"2 OPT"||ALIGN"4 OPT"||ALIGN"8 OPT"||ALIGN"16 OPT"|
Setting integer to a number that is not a multiple of four could impair the efficiency of the generated code. Under ALIGN(integer OPT), integer should be a power of 2, and will be increased to the next power of 2 if not (to a max value of 16).
If your program accesses data beyond the size of the 01-level item into the next or previous 01-level group, then you will need to use ALIGN(integer FIXED) to preserve the fixed alignment between 01-level items. However, such code is not ANSI Standard compliant, is not guaranteed to work in all circumstances, may interfere with some optimizations, and won't work in managed COBOL.
If the 01-level group contains the following level-78 syntax, then the 01-level item will only be aligned according to the value of the ALIGN directive and not its size:
01 grp1. 78 constant-01 value next. 78 constant-01 value start grp1.
This is because the next/start record the data address before items are aligned according to their size.