TAL Programmer's Guide
Declaring Arrays
Using Arrays
096254 Tandem Computers Incorporated 7–7
UNSIGNED Arrays
When you declare an UNSIGNED array, you must specify as part of the data type a
value of 1, 2, 4, or 8 that specifies the width, in bits, of the elements in the array. Here is
an example of an UNSIGNED array that has eight 4-bit elements:
UNSIGNED(4) array[0:7];
The compiler packs allocation of UNSIGNED array elements in sequential words. A
word can contain up to sixteen 1-bit elements, eight 2-bit elements, four 4-bit elements,
or two 8-bit elements in successive bit fields. For example, if you declare an array as
having six 2-bit elements, the compiler packs allocation of all six 2-bit elements in the
same word:
UNSIGNED(2) a[0:5];
0123456789101112131415
A[0] A[1] A[2] A[3] A[4] A[5]
367
The compiler always allocates the zeroth element of an UNSIGNED array at a word
boundary. For example, if you declare an UNSIGNED simple variable followed by an
UNSIGNED array having bounds of [4:7], the compiler allocates the array in the same
word as the simple variable, with the zeroth array element at bit [0]:
UNSIGNED(5) uns_var;
UNSIGNED(2) b[4:7];
368
0123456789101112131415
UNS_VAR B[4] B[5] B[6] B[7]
If you declare a STRING simple variable followed by an UNSIGNED array, the
compiler allocates the zeroth array element starting at bit [0] of the next word:
STRING str_var;
UNSIGNED(2) c[4:7];
369
0123456789101112131415
STR_VAR
C[4] C[5] C[6] C[7]C[0]