TAL Programmer's Guide

Using Structure Pointers
Using Pointers
9–14 096254 Tandem Computers Incorporated
You can initialize standard structure pointers with the addresses of structure items by
using:
The $OFFSET standard function, which returns an item’s byte offset from the
zeroth occurrence of the encompassing structure
An unsigned operator such as '+' to append an offset in the range 0 through 65,535
to a standard pointer
Bit-shift operations ('>>' 1 or '<<' 1) to convert a byte address to a word address or
vice versa
For example, the following initializations store addresses of structure items
SUBSTRUC and VAR_A in standard structure pointers:
STRUCT .struc; !Declare STRUC
BEGIN
STRUCT substruc; !Declare SUBSTRUC
BEGIN
INT var_a; !Declare VAR_A
INT var_b;
END;
END;
INT .word_ptr_a (struc):= @struc '+'
$OFFSET(struc.substruc) '>>' 1;
!Declare WORD_PTR_A; initialize
! it with converted word address
! of STRUC.SUBSTRUC
INT .word_ptr_b (struc) := @struc '+'
$OFFSET(struc.substruc.var_a) '>>' 1;
!Declare WORD_PTR_B; initialize
! it with converted word address
! of STRUC.SUBSTRUC.VAR_A
STRING .byte_ptr (struc) := @struc '<<' 1 '+'
$OFFSET(struc.substruc);
!Declare BYTE_PTR; initialize
! it with converted byte
! address of STRUC.SUBSTRUC
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.