Rotate Instructions - Siemens SIMATIC S7 System Manual

Hide thumbs Also See for SIMATIC S7:
Table of Contents

Advertisement

100BBasic instructions
7.10 Shift and Rotate
Table 7- 142 SHL example for Word data
Shift the bits of a Word to the left by inserting zeroes from the right (N = 1)
IN
1110 0010 1010 1101
7.10.2

Rotate instructions

Table 7- 143 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- 144 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
● 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.
Table 7- 145 ROR example for Word data
Rotate bits out the right -side into the left -side (N = 1)
IN
0100 0000 0000 0001
232
OUT value before first shift:
After first shift left:
After second shift left:
After third shift left:
in:=_variant_in_,
n:=_uint_in);
in:=_variant_in_,
n:=_uint_in);
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.
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
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
S7-1200 Programmable controller
System Manual, 11/2011, A5E02486680-05

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Simatic s7-1200

Table of Contents