pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
Example 133 Memory Usage for Structured Equivalenced Variables (Correct)
STRUCT b FIELDALIGN(AUTO);
BEGIN
INT i;
STRING j; ! pTAL adds a byte after the declaration of j
END;
STRUCT a FIELDALIGN(SHARED2) = b;
BEGIN
STRING i;
STRING j;
STRING k;
END;
FIELDALIGN Clause
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 optimized for TAL programs on TNS architecture and the other optimized for pTAL
programs on TNS/R or TNS/E architecture. Declare the pTAL structure first.
Example 134 FIELDALIGN Clause in Structured Equivalenced Variables
STRUCT a FIELDALIGN(SHARED8);
BEGIN
INT i;
INT j;
END;
STRUCT b FIELDALIGN(SHARED2) = a;
BEGIN
INT i;
INT j;
END;
In Example 134 (page 193), structures a and b declare the same fields, but a specifies
FIELDALIGN(SHARED8), the optimal alignment for pTAL, whereas b specifies
FIELDALIGN(SHARED2), the alignment for TAL. pTAL generates fast code for references to a.i,
but conservative code for references to b.i
For more information about using the FIELDALIGN clause, see Chapter 9 (page 114).
System Global Equivalenced Variable Declarations
NOTE: Only procedures that operate in privileged mode can access system global data.
System global equivalencing associates a global, local, or sublocal identifier with a location that
is relative to the base address. You can declare the following equivalenced variables for either
system global ('SG') or extended system global ('SGX') addresses:
• Equivalenced Simple Variable (page 193)
• Equivalenced Definition Structure (page 194)
• Equivalenced Referral Structure (page 195)
• Equivalenced Simple Pointer (page 196)
• Equivalenced Structure Pointer (page 197)
Equivalenced Simple Variable
An equivalenced simple variable declaration associates a simple variable with a location that is
relative to the 'SG' base address.
System Global Equivalenced Variable Declarations 193