Parameter
IN
N
OUT
● For N=0, no shift occurs and the IN value is assigned to OUT.
● Zeros are shifted into the bit positions emptied by the shift operation.
● If the number of positions to shift (N) exceeds the number of bits in the target value (8 for
● ENO is always TRUE for the shift operations.
SHL example for Word size data: Shift in zeros from the left
IN
Rotate instruction
Click below the box name and select a data type from the drop-down menu.
Parameter
IN
N
OUT
● For N=0, no rotate occurs and the IN value is assigned to OUT.
● Bit data rotated out one side of the target value is rotated into the other side of the target
● If the number of bit positions to rotate (N) exceeds the number of bits in the target value
● ENO is always TRUE following execution of the rotate instructions.
ROR example for WORD size data: Rotate bits out the right -side into the left -side
IN
S7-1200 Programmable controller
System Manual, 11/2009, A5E02486680-02
Data type
Byte, Word, DWord
UInt
Byte, Word, DWord
Byte, 16 for Word, 32 for DWord), then all original bit values will be shifted out and
replaced with zeros (zero is assigned to OUT).
1110 0010 1010 1101
You use the rotate instructions to rotate the bit pattern of parameter IN. The
result is assigned to parameter OUT. Parameter N defines the number of bit
positions rotated.
ROR: Rotate bit pattern right
ROL: Rotate bit pattern left
Data type
Byte, Word, DWord
UInt
Byte, Word, DWord
value, so no original bit values are lost.
(8 for Byte, 16 for Word, 32 for DWord), then the rotation is still performed.
0100 0000 0000 0001
Description
Bit pattern to shift
Number of bit positions to shift
Bit pattern after shift operation
OUT value before first shift:
After first shift left:
After second shift left:
After third shift left:
Description
Bit pattern to rotate
Number of bit positions to rotate
Bit pattern after rotate operation
OUT value before first rotate:
After first rotate right:
After second rotate right:
Programming instructions
6.1 Basic instructions
1110 0010 1010 1101
1100 0101 0101 1010
1000 1010 1011 0100
0001 0101 0110 1000
0100 0000 0000 0001
1010 0000 0000 0000
0101 0000 0000 0000
131