December 2001 Commands 7 – 135
7.7.55 SHIFT LEFT (<<)
Syntax: << (SHIFT LEFT)
Operands: B, W, D, K
Action:
A SHIFT LEFT instruction multiplies the content of the word accumulator by 
two. This is done by simply shifting the bits by one place to the left. The result 
must lie in the range of -2 147 483 648 to +2 147 483 647, otherwise the 
accumulator contains an undefined value. You define the number of shifts 
through the operand. The TNC fills the right end of the accumulator with zeros.
This instruction is one of the arithmetic commands because it includes the 
sign bit. For this reason, and to save time, you should not use this command 
to isolate bits.
Example:
Shift the content of double word D8 four times to the left, then assign it to 
double word 12. 
Initial state:
Double word  D8 = 3E 80 (hex)
Double word D12 = ?
The accumulator content is shown here in binary notation; the operand 
content in hexadecimal notation.
Instead of using the << K+1 command four times, simply use the << K+4 
command.
Function STL Accumulator contents [bit] Operand 
content (hex)
x xxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx
Load the 
double word 
D8 into the 
word 
accumulator.
L D8 0 0000000 00000000 00111110 10000000 0 0 00 3E 80
Shift the 
content of the 
word 
accumulator to 
the left by the 
number of bits 
that are 
specified in 
the operand.
<<K+1 0 0000000 00000000 01111101 00000000
<<K+1 0 0000000 00000000 11111010 00000000
<<K+1 0 0000000 00000001 11110100 00000000
<<K+1 0 0000000 00000011 11101000 00000000
Assign the 
result to 
double word 
D12.
= D12 0 0000000 00000011 11101000 00000000 0 0 03 E8 00