TAL Reference Manual
Pointers
TAL Reference Manual—526371-001
9-8
Examples of Structure Pointer Declarations
STRUCT .st; !Definition structure
BEGIN
INT j;
STRUCT ss (t);
END;
INT .ip := @st '+' $OFFSET (st.j) '>>' 1;
!Simple pointer
INT .stp (t) := @st '+' $OFFSET (st.ss) '>>' 1;
!INT structure pointer
STRING .sstp (t) := @st '<<' 1 '+' $OFFSET (st.ss);
!STRING structure pointer
2. A standard STRING structure pointer can access the following structure items
only-a substructure, a STRING simple variable, or a STRING array-located in the
lower 32K-word area of the user data segment. The last declaration in the
preceding example shows a STRING structure pointer initialized with the converted
byte address of a substructure. Here is another way to access a STRING item in a
structure. You can convert the word address of the structure to a byte address
when you initialize the STRING structure pointer and then access the STRING
item in a statement:
STRUCT .astruct[0:1];
BEGIN
STRING s1;
STRING s2;
STRING s3;
END;
STRING .ptr (astruct) := @astruct[1] '<<' 1;
!Declare STRING PTR; initialize
!it with converted byte
!address of ASTRUCT[1]
ptr.s2 := %4; !Access STRING structure item
3. This example declares a structure and a structure pointer at the local level. The
structure pointer is initialized to point to the second occurrence of the structure:
PROC my_proc MAIN;
BEGIN
STRUCT my_struct[0:2]; !Structure
BEGIN
INT array[0:7];
END;
INT .struct_ptr (my_struct) := @my_struct[1];
!Structure pointer contains
END; ! address of MY_STRUCT[1]