pTAL Conversion Guide

pTAL Conversion Guide527302-002
5-1
5 Data Allocation
Topics:
Data Alignment on page 5-1
Reference Alignment on page 5-3
Volatile Data on page 5-5
Data Alignment
Ensuring that data is well-aligned in memory is more important in native processes
than in TNS processes. The native compilers, therefore, allocate memory such that
each data element is aligned for optimal access time. Data accessed by pointers,
however, might not be well-aligned, depending on how you declare the pointers and
the addresses you store in the pointers. In most cases the data referenced by a pointer
is well-aligned. For those cases in which the data might not be well-aligned, however,
you can use constructs described in this section to specify that the data might be
misaligned.
Topics:
Data Alignment in TNS Processes on page 5-1
Data Alignment in Native Processes on page 5-2
Data Alignment in TNS Processes
In a TNS process, you use a word address to access data in the user data segment,
except STRING data for which you use a byte address. You use a byte address to
access all data in a TNS extended memory segment, regardless of the type of the
data; however, all data in TNS memory—including data in extended memory—must
begin at an even-byte address, except STRING data, which can be allocated at any
byte address.
TAL packs UNSIGNED data into 16-bit words or 32-bit doublewords as long as each
field fits entirely within the current 16-bit word for UNSIGNED(1-16) data, or in one 32-
bit doubleword for UNSIGNED(17-31) data.
All data allocated by the compiler is aligned for fast access. You must ensure that data
you allocate—for example, data on a heap—begins at an even-byte address, except
for STRING data, which can begin at any byte address. Your program will not trap if
you access nonSTRING data at an odd-byte address, but you might not access the
data you expect.
Note. This topic explains only pointers to nonstructure data. For information about pointers to
structure data, see Section 11, Structures.