Previous Topic Next topic Print topic


Aligning Data Items for Efficiency

Align items on even-byte boundaries. Align numeric items greater than two bytes on four-byte boundaries. Use the ALIGN"4" Compiler directive to ensure that level-01 items are always aligned on such boundaries. Use ALIGN"8" for compatibility with 64-bit systems.

To ensure that all items in a table are correctly aligned, check that the size of an occurrence in the table (the of the table) is a multiple of two or four bytes as required. Pad the table as necessary. For example:

 01 a OCCURS 10.
     03 b PIC X(4) COMP-5
     03 c PIC X.
     03 filler PIC X(3).

A three-byte filler has been added to each occurrence in the table to ensure that the numeric data item is always aligned on a four-byte boundary.

You can use the REF Compiler directive to find out how data items are aligned.

Previous Topic Next topic Print topic