Previous Topic Next topic Print topic


Aligning Data Items for Efficiency

Items should be aligned for maximum efficiency. The best alignment for data items depends on their size. Aligned data items can be handled more efficiently at machine code level; by default, the ALIGN directive will do this. See the table in the ALIGN directive for more information.

To ensure that all items in a table are correctly aligned, check that the size of an occurrence in the table is a multiple of two or four bytes as required. Pad the table as necessary. For example, in the following table, 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:

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

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

Previous Topic Next topic Print topic