TAL Programmer's Guide

Using Structure Pointers
Using Pointers
9–16 096254 Tandem Computers Incorporated
You can initialize a local or sublocal extended structure pointer with the address of an
extended indirect structure:
STRUCT .EXT ext_struct[0:2]; !Declare EXT_STRUCT
BEGIN
INT array1[0:7];
END;
INT .EXT ext_ptr (ext_struct) := @ext_struct[0];
!Declare EXT_PTR; initialize it
! with address of EXT_STRUCT[0]
You can initialize an extended structure pointer with the 32-bit byte address returned
by the $XADR standard function for a structure that has a 16-bit word address:
STRUCT std_struct[0:2]; !Declare STD_STRUCT
BEGIN
INT array1[0:7];
END;
INT .EXT ext_ptr (std_struct) := $XADR(std_struct[0]);
!Declare EXT_PTR; initialize it
! with converted 32-bit byte
! address of STD_STRUCT[0]
Allocating
Structure Pointers
The compiler allocates a word of storage for each standard pointer and a doubleword
for each extended pointer, as shown in Figure 9-1 earlier in this section.
The compiler does not allocate space for the data to which the pointer points. You
normally store the addresses of previously declared structures in structure pointers.
Assigning Addresses to
Structure Pointers
Once you have declared a structure pointer, you can store a memory address in it by
using an assignment statement (even if you initialized the pointer with an address
when you declared it).
To assign an address to a pointer, prefix @ to the pointer identifier on the left side of
the assignment operator, and specify an arithmetic expression that represents a
memory address. On the left side of the assignment operator, @ changes the content of
the pointer (that is, the address contained in the pointer), not the value of the item to
which the pointer points.
You can also prefix @ to a variable identifier on the right side of the assignment
operator. If the variable is a pointer, @ returns the address contained in the pointer. If
the variable is not a pointer, @ returns the address of the variable.