TAL Programmer's Guide
Accessing Operands
Using Expressions
5–28 096254 Tandem Computers Incorporated
Using a variable in two different ways can make your program more difficult to
understand and maintain. The following example:
Changes the data located at the address stored in VAR by using the dereferencing
operator
Changes the address stored in VAR by omitting the dereferencing operator
INT i; !G[0]; declare I
INT a := 5; !G[1]; declare A and initialize it with 5
INT var; !G[2]; declare VAR
var := @a; !Assign 1 (the address of A) to VAR
i := .var; !Assign 5 (the content of A to which
! VAR points) to I
i := var; !Assign 1 (the content of VAR or the
! address of A) to I
Extracting Bit Fields You can access a bit extraction field in an INT expression without altering the
expression. (Do not use a bit extraction field to compress data. Instead, declare an
UNSIGNED variable, specifying the appropriate number of bits in the bit field.)
To access a bit extraction field, specify an INT expression followed by a period (.) and
a bit-extraction field enclosed in angle brackets. For example, to access bit <5> of an
INT variable named VAR, specify the following construct with no intervening spaces:
var.<5>
To access bits <2> through <11> of VAR, specify the following construct with no
intervening spaces:
var.<2:11>
Specify the leftmost and rightmost bits of the field as INT constants. The constant
specifying the rightmost bit must be equal to or greater than the constant specifying
the leftmost bit.
The INT expression in a bit extraction operation can consist of STRING, INT, or
UNSIGNED(1–16) operands. The system stores a STRING value in the right byte of a
word and treats it as a 16-bit value, so you can access only bits <8> through <15> of
the STRING value. For example, to access bits <11> and <12> of a STRING simple
variable named BYTE_VAR, specify:
byte_var.<11:12>
You can assign the bits extracted from an array element as follows:
LITERAL len = 8;
STRING right_byte;
INT array[0:len - 1];
right_byte := array[5].<8:15>;