TAL Programmer's Guide
Accessing Operands
Using Expressions
5–30 096254 Tandem Computers Incorporated
Number of Positions to Shift
Specify the number of bit positions to shift as an INT expression. A value greater than
31 gives undefined results (different on TNS and TNS/R systems).
Effect on Hardware Indicators
The bit-shift operation sets the condition code indicator, described under “Testing
Hardware Indicators” earlier in this section.
Bit-Shift Operations
Bit-shift operations include:
Operation User Action
Multiplication by powers of 2 For each power of 2, shift the field one bit to the left. (Some
data might be lost.)
Division by powers of 2 For each power of 2, shift the field one bit to the right (Some
data might be lost.)
Word-to-byte address conversion Shift the word address one bit to the left, using an unsigned
shift operator.
To multiply by powers of two, shift the field one position to the left for each power
of 2 (Some data might be lost.) Here are examples:
a := b << 1; !Multiply by 2
a := b << 2; !Multiply by 4
a := b << 5; !Multiply by 32
To divide by powers of two, shift the field one position to the right for each power of 2
(Some data might be lost.) Here are examples:
a := b >> 3; !Divide by 8
a := b >> 4; !Divide by 16
a := b >> 6; !Divide by 64
To convert a word address to a byte address, use an unsigned shift operator. For
example, you can convert the word address of an INT array to a byte address and
initialize a STRING simple pointer with the byte address. You can then access the INT
array as bytes and as words:
INT a[0:5]; !Declare INT array
STRING .p := @a[0] '<<' 1; !Declare and initialize
! STRING simple pointer with
! array byte address
p[3] := 0; !Assign 0 to fourth byte
! of A