pTAL Reference Manual (H06.08+)
Pointers
HP pTAL Reference Manual—523746-006
10-4
Declaring VOLATILE Pointers
initialization
is an expression representing a memory address. For more information about
operations on addresses, see Section 5, Expressions.
Declaring VOLATILE Pointers
Declare pointers VOLATILE if they can be accessed asynchronously by other
processes such as another process in your application or an I/O driver.
Topics:
•
Simple on page 10-4
•
Structure on page 10-5
Simple
When you declare a VOLATILE simple pointer, the value of the pointer and the data
referenced by the pointer are treated as VOLATILE and are maintained 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.
Example 10-1. Declaring VOLATILE Simple Pointers
INT i;
INT a;
INT b[0:9];
VOLATILE INT .p1 := @a;
VOLATILE INT .p2 := @b;
i := p1; ! pTAL treats pointer p1 and data p1 references,
! a, as volatile. Program reads value of pointer
! p1 each time statement executes
i := a; ! pTAL does not treat direct reference to a as
! volatile even though p1 still points to it,
! because a is not declared volatile
i := p2[a]; ! For each reference to p2[a], program:
! * Reads value of pointer p2 from memory
! * Adds value of a, which can be kept in a
! register because a is not volatile
! * Reads from memory the value referenced by
! p2[a]
i := p2[p1]; ! Data referenced by p2[p1] is the same as p2[a]
! in the preceding example, but both p1 and p2
! are volatile. Program reads from memory p1,
! p2, a, and element of array b referenced by p1










