Aligning Data Structure Subfields

Alignment of subfields may be necessary. In some cases it is done automatically; in others, it must be done manually.

For example, when defining subfields of type basing pointer or procedure pointer using the length notation, the compiler will automatically perform padding if necessary to ensure that the subfield is aligned properly.

When defining float, integer or unsigned subfields, alignment may be desired to improve run-time performance. If the subfields are defined using length notation, you can automatically align float, integer or unsigned subfields by specifying the keyword ALIGN on the data structure definition. However, note the following exceptions:

Automatic alignment will align the fields on the following boundaries.

If you are aligning fields manually, make sure that they are aligned on the same boundaries. A start-position is on an n-byte boundary if ((position - 1) mod n) = 0. (The value of "x mod y" is the remainder after dividing x by y in integer arithmetic. It is the same as the MVR value after X DIV Y.)

Figure 53 shows a sequence of bytes and identifies the different boundaries used for alignment.

Figure 53. Boundaries for Data Alignment
This figure illustrates the boundaries for data alignment

Note the following about the above byte sequence:



[ Top of Page | Previous Page | Next Page | Contents | Index ]