Shift commands, 1 shift left, 9 shift commands 3.9.1 shift left (<<) – HEIDENHAIN TNC 335 Technical Manual User Manual
Page 461

7-82
TNC 360
3 Commands
8/95
3.9 Shift Commands
3.9.1 SHIFT LEFT (<<)
<<
Abbreviation for PLC Editor:
<< (SHIFT LEFT)
Byte/Word/Double
Constant
Execution time [µs]
2.0 + 0.2 x n
2.0 + 0.2 x n
Number of bytes
6
8
Operands: B, W, D, K
Operation:
Since the sign bit (MSB) is included with this command, it is grouped in with arithmetic commands.
For this reason and out of time considerations, this command should not be used for the isolation of bits.
A SHIFT LEFT instruction causes the contents of the Word Accumulator to be multiplied by two. For this
purpose, the bits in the Accumulator are simply shifted by one place to the left. The number of the shift
operations is determined via the operand. Thus the set bits, which are shifted beyond the Accumulator to
the left, are lost; the Accumulator is filled with nulls from the right-hand side. With operand contents
greater than 32, the operand value Modulo 32 is used, i.e. the integer remainder from the division (operand
value)/32.
Example:
The content of the Doubleword D8 is to be shifted four times to the left and then stored in D12.
Initial state:
Doubleword D8 = 3E 80 (hex)
Doubleword D12 = ?
The Accumulator content is shown here in binary notation, and the operand content in hexadecimal
notation.
Line Instruction
Accumulator Content
Operand Content
xxxxxxxx
xxxxxxxx
xxxxxxxxx
xxxxxxxxx
1
L D8
00000000
00000000 00111110
10000000
00
00
3E
80
2
<< K+1
00000000
00000000 01111101
00000000
3
<< K+1
00000000
00000000 11111010
00000000
4
<< K+1
00000000
00000001 11110100
00000000
5
<< K+1
00000000
00000011 11101000
00000000
6
= D12
00000000
00000011 11101000
00000000
00
03
E8
00
Line 1:
Load Doubleword D8 into the Accumulator.
Line 2 to 5:
The content of the Word Accumulator is shifted to the left by the number of bits
specified in the operand. The complete operation can also be undertaken with the
command << K+4.
Line 6:
The result is stored in the Doubleword D12.