Examples of alignment
Consider, for example, a structure consisting of a single character
and a fullword fixed binary item. The fullword fixed binary item has
a fullword alignment requirement; the character has a byte alignment
requirement. In PL/I, ALIGNED
is the default, and the structure is declared as follows:
DCL 1 A,
2 B CHAR(1),
2 C FIXED BINARY(31,0);
and is held like this:In COBOL, using SYNCHRONIZED, the structure would be declared as
follows:
01 A SYNCHRONIZED.
02 B PIC X DISPLAY.
02 C PIC S9(9) BINARY.
and is held like this:In COBOL, without SYNCHRONIZED, the structure would be declared
as follows:
01 A.
02 B PIC X.
02 C PIC S9(9) USAGE BINARY.
and is held like this: