pTAL Conversion Guide

Equivalenced Variables
pTAL Conversion Guide527302-002
12-17
Using the FIELDALIGN Clause
Using the FIELDALIGN Clause
You can include a FIELDALIGN clause in an equivalenced structure declaration.
The FIELDALIGN clause specifies the alignment of the fields of a structure and the
alignment of the structure itself in memory. You can use an equivalenced declaration to
create two layouts for the same area, one of which is optimized for pTAL programs
running as TNS processes, the other optimized for pTAL programs running as native
processes. Declare the native structure first, as in Example 12-15 on page 12-17.
In Example 12-15 on page 12-17, structures a and b declare the same fields but a
specifies FIELDALIGN(SHARED8), the optimal alignment for native architecture,
whereas b specifies FIELDALIGN(SHARED2), the alignment used by the TAL
compiler. The native compiler generates fast code for references to a.i, but
conservative code for references to b.i.
See Section 5, Data Allocation, for more information about alignment, and Section 11,
Structures, for more information about using the FIELDALIGN clause.
Declaring Address-Based Equivalenced
Variables
TAL
You can declare SG-relative pointers that refer to data in system globals:
INT .i = 'SG' + 0;
INT .EXT j = 'SG' + 0;
TAL allows the preceding declarations but generates the same object code for
references to i and j, and compiles them as if they were entered as follows:
INT .SG i = 'SG' + 0;
INT .SG j = 'SG' + 0;
Example 12-15. Equivalenced Structure Declaration With FIELDALIGN Clause
STRUCT a FIELDALIGN(SHARED8);
BEGIN
INT i;
INT j;
END;
STRUCT b FIELDALIGN(SHARED2) = a;
BEGIN
INT i;
INT j;
END;