TAL Programmer's Guide

Accessing Operands
Using Expressions
096254 Tandem Computers Incorporated 5–29
You can use bit extraction in conditional expressions:
INT word;
STRING var;
IF word.<0:7> = "A" THEN ... ; !Check for “A” in 8-bit field
IF var.<15> THEN ... ; !Check for nonzero value
! in bit <15>
To access bits in the result of an expression, enclose the expression in parentheses:
INT result;
INT num1 := 51;
INT num2 := 28;
result := (num1 + num2).<4:7>;
Shifting Bit Fields You can shift a bit field a specified number of positions to the left or or to the right
within an INT or INT(32) expression. You can then use the result of the shift as an
operand in an expression.
To shift a bit field, specify an INT or INT(32) expression, a left or right shift operator,
and the number of positions to shift. For example, to shift the bits in an INT simple
variable named VAR two positions to the left, specify:
var '<<' 2
For an INT expression, the shift occurs within a word. An INT expression can consist
of STRING, INT, or UNSIGNED(1–16) operands.
For an INT(32) expression, the shift occurs within a doubleword. An INT(32)
expression can consist of INT(32) and UNSIGNED(17–31) operands.
Bit-Shift Operators
Table 5-19 lists the bit-shift operators you can specify.
Table 5-19. Bit-Shift Operators
Operator Function Result
'<<' Unsigned left shift through bit <0> Zeros fill vacated bits from the right
'>>' Unsigned right shift Zeros fill vacated bits from the left.
<< Signed left shift through bit <0> or
bit <1>
Zeros fill vacated bits from the right. In arithmetic
overflow cases, the final value of bit <0> is
undefined (different for TNS/R accelerated mode
than for TNS systems).
>> Signed right shift Sign bit (bit <0>) unchanged; sign bit fills vacated
bits from the left
For signed left shifts (<<), programs that run on TNS/R systems use unsigned left
shifts ('<<').