pTAL Conversion Guide

Data Allocation
pTAL Conversion Guide527302-002
5-5
Volatile Data
Volatile Data
In pTAL, a data item can be declared with the VOLATILE attribute, which means that:
Every reference to the data item accesses its value from memory, not from a
register copy of the data.
The compiler does not rewrite code such that references to the data item could
lose the meaning you intend (for example, by moving expressions or statements
outside of loops, as in Example 5-2 on page 5-6)
?REFALIGNED(2)
INT(32) .ap1; ! References to these pointers
INT(32) .ap2; ! generate conservative code
INT(32) .ap3; ! because of REFALIGNED(2)
INT(32) .ap4; ! directive
?REFALIGNED(8)
INT(32) .ap11; ! These pointers do not cause
INT(32) .ap21 REFALIGNED(2); ! exceptions because the
INT(32) .ap31; ! pointers that are unaligned
INT(32) .ap41 REFALIGNED(2); ! specify REFALIGNED(2) clause
PROC p;
BEGIN
@p1 := @ap1 := @ap11 := @str[0]; ! Points to "ABCD"
@p2 := @ap2 := @ap21 := @str[2]; ! Points to "CDEF"
@p3 := @ap3 := @ap31 := @str[4]; ! Points to "EFGH"
@p4 := @ap4 := @ap41 := @str[6]; ! Points to "GHIJ"
i1 := p1; ! Uses fast code - access OK
i2 := ap1; ! Uses conservative code
i3 := ap11; ! Uses fast code - access OK
i4 := p2; ! Uses fast code - causes exception
i5 := ap2; ! Uses conservative code
i6 := ap21; ! Uses conservative code
i7 := p3; ! Uses fast code - access OK
i8 := ap3; ! Uses conservative code
i9 := ap31; ! Uses fast code - access OK
i10 := p4; ! Uses fast code - causes exception
i11 := ap4; ! Uses conservative code
i12 := ap41; ! Uses conservative code
END;
Example 5-1. Reference Alignment (page2of2)