TAL Programmer's Guide

Accessing Structure Items
Using Structures
8–36 096254 Tandem Computers Incorporated
The following example assigns the address of a structure to structure pointers declared
in another structure:
STRUCT .s1; !Declare S1
BEGIN
INT var1;
INT var2;
END;
STRUCT .s2; !Declare S2
BEGIN
INT .std_ptr (s1); !Declare STD_PTR
INT .EXT ext_ptr (s1); !Declare EXT_PTR
END;
PROC g MAIN;
BEGIN
@s2.std_ptr := @s1[0]; !Assign standard address
! of S1 to S2.STD_PTR
@s2.ext_ptr := $XADR(s1); !Assign extended address
END; ! of S1 to S2.EXT_PTR
Accessing Data Through
Pointers in Structures
After you declare a pointer inside a structure and assign an address to it, you can use
assignment statements to access the data to which the pointer points:
INT .array[0:99]; !Declare ARRAY
STRUCT .st; !Declare ST
BEGIN
INT .std_ptr; !Declare STD_PTR
INT .EXT ext_ptr; !Declare EXT_PTR
END;
PROC h MAIN;
BEGIN
@st.std_ptr := @array[0]; !Assign word address of
! ARRAY[0] to St.STD_PTR
@st.ext_ptr := $XADR(array[1]);!Assign extended address of
! ARRAY[1] to ST.EXT_PTR
array[2] := st.std_ptr; !Assign content of
! ARRAY[0] to ARRAY[2]
st.ext_ptr := array[3]; !Assign content of ARRAY[3]
END; ! to ARRAY[1]