Data alignment

The computer holds information in multiples of units of 8 bits. Each 8-bit unit of information is called a byte. The computer accesses bytes singly or as halfwords, words, or doublewords. Byte locations in storage are consecutively numbered starting with 0; each number is the address of the corresponding byte.

A halfword is 2 consecutive bytes. A fullword is 4 consecutive bytes. A doubleword is 8 consecutive bytes. Halfwords, words, and doublewords are addressed by the address of their leftmost byte.

Your programs can execute faster if halfwords, words, and doublewords are located in main storage on an integral boundary for that unit of information. That is, the unit of information's address is a multiple of the number of bytes in the unit, as can be seen in Table 1.

Table 1. Alignment on integral boundaries of halfwords, words, and doublewords
ADDRESSES IN A SECTION OF STORAGE
5000 5001 5002 5003 5004 5005 5006 5007
byte byte byte byte byte byte byte byte
halfword halfword halfword halfword
fullword fullword
doubleword

PL/I allows data alignment on integral boundaries. However, unused bytes between successive data elements can increase storage use. For example, when the data items are members of aggregates used to create a data set, the unused bytes increase the amount of auxiliary storage required. The ALIGNED and UNALIGNED attributes allow you to choose whether or not to align data on the appropriate integral boundary.