Ror (Rotate Right) And Rol (Rotate Left) Instructions - Siemens S7-1200 System Manual

Hide thumbs Also See for S7-1200:
Table of Contents

Advertisement

Basic instructions
7.10 Shift and rotate
7.10.2

ROR (Rotate right) and ROL (Rotate left) instructions

Table 7- 146 ROR and ROL instructions
LAD / FBD
SCL
out := ROL(
out := ROR(
For LAD and FBD: Click the "???" and select the data types from the drop-down menu.
1
Table 7- 147 Data types for the parameters
Parameter
IN
N
OUT
● 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 7- 148 ROR example for Word data
Rotate bits out the right -side into the left -side (N = 1)
IN
0100 0000 0000 0001
282
in:=_variant_in_,
n:=_uint_in);
in:=_variant_in_,
n:=_uint_in);
Data type
Byte, Word, DWord
UInt
Byte, Word, DWord
OUT value before first rotate:
After first rotate right:
After second rotate right:
Description
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
Description
Bit pattern to rotate
Number of bit positions to rotate
Bit pattern after rotate operation
0100 0000 0000 0001
1010 0000 0000 0000
0101 0000 0000 0000
S7-1200 Programmable controller
System Manual, 03/2014, A5E02486680-AG

Advertisement

Table of Contents
loading

Table of Contents