pTAL Reference Manual (G06.24+, H06.09+, J06.03+)

! are volatile. Program reads from memory p1,
! p2, a, and element of array b referenced by p1
Structure
When you declare a VOLATILE structure pointer, the compiler generates code that maintains the
value of the pointer in memory, not in a register. Each reference to a VOLATILE data item causes
the data item to be read or written to memory even when code is optimized. Based on the order
of reads and writes in the source code, VOLATILE also causes that precise order of memory
references to be preserved, again, when code is optimized.
You must specify the VOLATILE attribute on each field that you want to be volatile.
Example 102 Declaring VOLATILE Structure Pointers
INT i;
STRUCT s;
BEGIN
INT m; ! Field m is never treated as volatile
VOLATILE INT n; ! Field n is always treated as volatile
END;
VOLATILE INT .s1(s) := @s;
INT .s2(s) := @s;
i := s1.m; ! Value of pointer s1 is read from memory on
! every reference, but value of field s1.m
! might be maintained in a register
i := s1.n; ! Value of pointer s1 is read from memory on
! every reference, as is value of s1.n
! because field n specifies VOLATILE
i := s2.n; ! Value of pointer s2 might or might not be
! from memory, but having read the pointer,
! the field s2.n is always read from memory
Address Types
pTAL address types control the addresses you store into pointers. A 32-bit address can reference
data anywhere in memory with optimal performance. The hardware does not require programs
to specify an addressing type or memory storage area.
The compiler determines the address type of a pointer from the pointer declaration. You cannot
explicitly declare a pointer’s address type.
Address types are used primarily to describe the addresses that you assign to a pointer, not the
data your program is processing.
Only operations that are meaningful for addresses are valid on address types.
A pointer is associated with two data types:
DescriptionData Type
Data type of the objects that the pointer can referenceObject data type
Data type of the addresses that you can store in the pointerAddress data type
164 Pointers