pTAL Reference Manual (H06.03+)

Structures
HP pTAL Reference Manual523746-005
9-21
SHARED2 Parameter
The address type of pointers in a SHARED2 structure must be EXTADDR,
SGBADDR, or SGWADDR; for example:
STRUCT s FIELDALIGN(SHARED2);
BEGIN
INT .EXT i; ! OK: EXTADDR pointer
INT .SG j; ! OK: SGWADDR pointer
STRING .s; ! ERROR: BADDR pointer is not valid
END;
If the data type of a field in a SHARED2 structure is an address type, the type must
be EXTADDR, SGBADDR, or SGWADDR; for example:
STRUCT s FIELDALIGN(SHARED2);
BEGIN
EXTADDR x; ! OK: EXTADDR field
WADDR w; ! ERROR: WADDR field is not valid
END;
If you include a FIELDALIGN(SHARED2) compiler directive, include a
REFALIGNED(2) compiler directive as well. The default for the REFALIGNED
compiler directive is 8. With field alignment SHARED2, pTAL can allocate a 32-bit
or 64-bit field at any even-byte address. pTAL generates optimal code for data
references that use a pointer whose reference alignment is 8. If the pointer is used
to reference 32-bit or 64-bit data that is not well-aligned, each reference to the data
will be slow. By default, pTAL generates conservative code when you reference
data using a pointer that specifies REFALIGNED(2). The REFALIGNED(2)
directive ensures that pTAL generates conservative code for pointers that do not
specify a REFALIGNED clause.
Example 9-12. FIELDALIGN(SHARED2) and REFALIGNED(2) Directives
?FIELDALIGN(SHARED2)
?REFALIGNED(2)
INT(32).ptr; ! Global pointer
PROC p;
BEGIN
@ptr := @str.F32; ! str.F32 might or might not be aligned
! at a 32-bit address. REFALIGNED
... := ptr + 3D; ! directive ensures that pTAL
! generates conservative code for
END; ! references to ptr.