pTAL Conversion Guide

Structures
pTAL Conversion Guide527302-002
11-18
Using Field Alignment
Using SHARED2 Field Alignment
The memory layout of a pTAL structure declared with FIELDALIGN(SHARED2) is the
same as the memory layout of a structure compiled by the TAL compiler. The structure
uses TNS memory optimally, but references to the structure’s fields might be slower on
native architecture than if you declare the structure with SHARED8 field alignment.
Specify FIELDALIGN(SHARED2) for structures that are shared by processes running
on TNS and native architectures and that either must preserve an already existing
layout or must use a minimum of TNS memory.
In a SHARED2 structure, all fields must begin at an even-byte address except STRING
fields, which can begin at any byte address, and UNSIGNED fields, which can begin at
any bit address except as follows:
An UNSIGNED(1-16) field cannot cross an even-byte address boundary.
An UNSIGNED(17-31) field can cross only one even-byte address boundary.
An UNSIGNED field that is not preceded by an UNSIGNED field must begin at an
even-byte address.
The address type of pointers in a SHARED2 structure must be EXTADDR,
SGBADDR, or SGWADDR:
STRUCT s FIELDALIGN(SHARED2);
BEGIN
INT .EXT i; ! OK: EXTADDR pointer
INT .SG j; ! OK: SGWADDR pointer
STRING .s; ! ERROR: BADDR pointer is invalid
END;
If the data type of a field in a SHARED2 structure is an address type, the type must
be EXTADDR, SGBADDR, or SGWADDR:
STRUCT s FIELDALIGN(SHARED2);
BEGIN
EXTADDR x; ! OK: EXTADDR field
WADDR w; ! ERROR: WADDR field is invalid
END;