pTAL Conversion Guide

Data Allocation
pTAL Conversion Guide527302-002
5-2
Data Alignment in Native Processes
Data Alignment in Native Processes
In a native process, data can begin at any byte address. Data access is most efficient,
however, when the byte address of the data is an integral multiple of the width of the
data. For example, access to an INT(32) value is most efficient if the address of the
data is an integral multiple of four. Similarly, access to a REAL(64) value is most
efficient if the address of the data is an integral multiple of eight.
The data type of each data item determines the memory address at which the compiler
allocates the data. The compiler allocates each data item such that it can use optimal
native object code to access the data. Data that is aligned for most efficient access is
said to be well-aligned.
When a native compiler allocates memory for simple data items and arrays of simple
data items, the native compiler adds filler items where necessary to ensure that each
data item—whether global or local—is well-aligned.
Table 5-1. Alignment of pTAL Variables in a Native Process
Data Type Alignment Notes
STRING 1
INT 2
USIGNED(1-16) 2 Multiple UNSIGNED fields can be packed in a word
or doubleword.
.SG pointers 2 .SG pointers are 16 bits on TNS and native
architectures.
.SGX pointers 4 Allowed in structures only with AUTO field alignment
.
Other 16-bit pointers 4 Allowed in structures only with AUTO field alignment
.
32-bit pointer 4
INT(32) 4
REAL 4
UNSIGNED(17-31) 4 Multiple UNSIGNED fields can be packed in a
doubleword.
FIXED 8
REAL(64) 8
Notes:
In a TNS process, the alignment of all address types is 2. In a native process, the
alignment of all address types is 4, except SGBADDR and SGWADDR addresses for
which the alignment is 2.
The alignment of an array is the alignment of its element type.
See Section 11, Structures, for a discussion of structure alignment.