Basic instructions
8.10 Shift and rotate
S7-1200 Programmable controller
System Manual, V4.2, 09/2016, A5E02486680-AK
333
ROR (Rotate right) and ROL (Rotate left) instructions
Table 8- 185 ROR and ROL instructions
in:=_variant_in_,
n:=_uint_in);
out := ROR(
in:=_variant_in_,
Use the rotate instructions (ROR and ROL) 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
1
For LAD and FBD: Click the "???" and select the data types from the drop-down menu.
Table 8- 186 Data types for the parameters
N USInt, UDint Number of bit positions to rotate
Bit pattern after rotate operation
● For N=0, no rotate occurs. 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
value, so no original bit values are lost.
● If the number of bit positions to rotate (N) exceeds the number of bits in the target value
(8 for Byte, 16 for Word, 32 for DWord), then the rotation is still performed.
● ENO is always TRUE following execution of the rotate instructions.
Table 8- 187 Example: ROR for Word data
Rotate bits out the right -side into the left -side (N = 1)
OUT value before first rotate:
After first rotate right:
After second rotate right: