pTAL Reference Manual (H06.03+)
Structures
HP pTAL Reference Manual—523746-005
9-5
Structures Aligned at Odd-Byte Boundaries
•
Accessing data is somewhat slower if the data is not well-aligned and you
reference the data using a pointer that specifies REFALIGNED(2).
•
Accessing data is significantly slower if the data is not well-aligned, but pTAL
generates code that functions as if the data is well-aligned. In this case, your
program traps to the millicode exception handler, which completes the data access
and returns to your program.
To comply with these guidelines, some structures require that you explicitly add filler to
ensure that:
•
Each field begins at an address that is a multiple of its length.
•
The total length of a structure is a multiple of the widest field in the structure.
Structures Aligned at Odd-Byte Boundaries
If you attempt to access data at an odd-byte address, the results are undefined,
whether the data is a simple variable or a field of a structure. Your program might or
might not trap.
Overview of Field Alignment
This subsection gives you an overview of the FIELDALIGN clause and the
FIELDALIGN compiler directive, and the field alignment parameters SHARED2,
SHARED8, PLATFORM, and AUTO.
The FIELDALIGN clause specifies the alignment of a structure and of all substructures
that do not specify a FIELDALIGN clause. For details, see FIELDALIGN Clause on
page 9-20.
The FIELDALIGN compiler directive specifies the default alignment for all structures. It
includes the SHARED2, SHARED8, PLATFORM, and AUTO parameters as well as a
NODEFAULT parameter. For more information, see Section 17, Compiler Directives.
When you declare a definition or template structure, you specify (either explicitly using
a FIELDALIGN clause or implicitly according to the current setting of the FIELDALIGN
compiler directive) how you want the compiler to allocate memory for the structure. The
field alignment for each such structure is specified by one of the following parameters
to a FIELDALIGN clause or directive:
You use SHARED2 and SHARED8 field alignment for structure data used by
processes running in either pTAL or TAL. You can share data by interprocess
communication or by accessing it on a shared storage medium such as disk or tape.
Your program might use library routines that require that structure data be in a
SHARED2 or SHARED8 format. If you use library routines that include structures that
specify SHARED2 or SHARED8, you might need to declare your structures with the
same field alignment as the structures in the library.










