TAL Programmer's Guide
Accessing Structure Items
Using Structures
8–30 096254 Tandem Computers Incorporated
Indexing Extended Indirect Structures
The index for extended indirect structures must be a signed INT or INT(32) arithmetic
expression, depending on the size of the offset of the structure item you want to
access. The offset of a structure item is from the zeroth structure occurrence (not the
current structure occurrence).
C-Series System. If you are writing a program to run on a C-series system, you can
determine whether to use an INT index or an INT(32) index (which is slower) as
follows:
1. Compute the lower and upper byte or word offsets of the structure item whose
extended indirect structure is being indexed. (A byte-addressed structure item is
at a byte offset. A word-addressed structure item is at a word offset.)
2. If the offsets are inside the signed INT range (–32,768 through 32,767), use a signed
INT index. Usually, offsets are within the signed INT range.
3. If the offsets are outside the signed INT range, use an INT(32) index. To convert
an INT index to an INT(32) index, use $DBL, a standard function.
Whenever you increase the structure size or number of occurrences, you must repeat
the preceding sequence.
To access a structure item whose offset is inside the signed INT range, you can use an
INT index as follows:
STRUCT .EXT xstruct[0:9]; !Declare extended indirect
BEGIN ! structure; upper byte offset
STRING array[0:9]; ! is within INT range
END;
INT index; !Declare INT index
STRING var;
PROC my_proc MAIN;
BEGIN
!Code to initialize INDEX
var := xstruct[index].array[0];
END; !Generate correct offset
In the preceding example, if the default NOINHIBITXX directive is in effect, the
compiler generates efficient addressing (by using XX instructions described in the
System Description Manual for your system).
Conversely, INHIBITXX suppresses efficient addressing of extended indirect
declarations located between G[0] and G[63] of the user data segment—except when
the extended indirect declarations are declared in a BLOCK declaration with the
AT (0) or BELOW (64) option. (The BLOCK declaration is described in Section 14,
“Compiling Programs.”)