TAL Programmer's Guide
Using Simple Pointers
Using Pointers
096254 Tandem Computers Incorporated 9–11
The index represents an element offset from the address stored in the simple pointer;
that is, from the address of a simple variable, array, or structure item. The element
offset yielded by an index depends on the data type of the simple pointer:
Data Type Element Offset
STRING Byte
INT Word
INT(32) or REAL Doubleword
REAL(64) or FIXED Quadrupleword
For example, you can initialize an INT simple pointer with the address of an INT(32)
array. You can then append an index to the simple pointer and assign a value to the
last word of the array:
PROC z MAIN;
BEGIN
INT(32) dbl[0:4] := [1D, 2D, 3D, 4D, 0D];
INT .p := @dbl; !View DBL as single words
p[9] := 5; !Last word of DBL is at a 9-word
END; ! offset from P[0]
Figure 9-2 shows how the compiler allocates a doubleword for each element of the
INT(32) array declared in the preceding example. The figure shows how INT pointer
P can access each word of each element and how the assignment to P[9] changes the
value stored in the last word of the array to 5.
Figure 9-2. Indexing Simple Pointers
P[0]
P[1]
P[2]
P[3]
P[4]
P[5]
P[6]
P[7]
P[8]
P[9]
0
1
2
3
4
5
0
0
0
0
DBL[0]
DBL[1]
DBL[2]
DBL[3]
DBL[4]
0
1
2
3
4
0
0
0
0
0
Before assignment After assignment
398