2 shift right (>>) – HEIDENHAIN TNC 407 (243 020) Technical Manual User Manual
Page 555
3.9.2 SHIFT RIGHT (>>)
Abbreviation for PLC Editor:
>> (SHIFT RIGHT)
Byte/Word/Double
Constant
Execution time [µs]
0.6 to 0.9
0.3 to 0.5
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 RIGHT instruction causes the contents of the Word Accumulator to be divided by two. For this
purpose, the bits in the Accumulator are simply shifted by one place to the right. The number of the shift
operations is determined via the operand. Thus the set bits, which are shifted beyond the Accumulator to
the right, are lost; the Accumulator is filled according to the sign, from the left-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 right 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
xxxxxxxx
xxxxxxxx
1
L D8
00000000
00000000 00111110
10000000
00
00
3E
80
2
>> K1
00000000
00000000 00011111
01000000
3
>> K1
00000000
00000000 00001111
10100000
4
>> K1
00000000
00000000 00000111
11010000
5
>> K1
00000000
00000000 00000011
11101000
6
= D12
00000000
00000000 00000011
11101000
00
00
03
E8
Line 1:
Load Doubleword D8 into the Accumulator.
Line 2 to 5:
The content of the Word Accumulator is shifted to the right 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 Doubleword D12.