Shift And Rotate Instructions; Shift Right And Shift Left Instructions; Rotate Right And Rotate Left Instructions - Siemens SIMATIC S7-200 System Manual

Programmable controller
Hide thumbs Also See for SIMATIC S7-200:
Table of Contents

Advertisement

Shift and Rotate Instructions

Shift Right and Shift Left Instructions

The Shift instructions shift the input value IN right or left by
the shift count N and load the result in the output OUT.
The Shift instructions fill with zeros as each bit is shifted
.
out
If the shift count (N) is greater than or equal to the
maximum allowed (8 for byte operations, 16 for word
operations, and 32 for double word operations), the value is
shifted the maximum number of times for the operation. If
the shift count is greater than 0, the overflow memory bit
(SM1.1) takes on the value of the last bit shifted out. The
zero memory bit (SM1.0) is set if the result of the shift
operation is zero.
Byte operations are unsigned. For word and double word
operations, the sign bit is shifted when you use signed data
types.
Error conditions that set ENO = 0
H 0006 (indirect address)

Rotate Right and Rotate Left Instructions

The Rotate instructions rotate the input value (IN) right or
left by the shift count (N) and load the result in the memory
location (OUT). The rotate is circular.
If the shift count is greater than or equal to the maximum for
the operation (8 for a byte operation, 16 for a word
operation, or 32 for a double-word operation), the S7-200
performs a modulo operation on the shift count to obtain a
valid shift count before the rotation is executed. This result
is a shift count of 0 to 7 for byte operations, 0 to 15 for word
operations, and 0 to 31 for double-word operations.
If the shift count is 0, a rotate operation is not performed. If the rotate operation is performed, the
value of the last bit rotated is copied to the overflow bit (SM1.1).
If the shift count is not an integer multiple of 8 (for byte operations), 16 (for word operations), or
32 (for double-word operations), the last bit rotated out is copied to the overflow memory bit
(SM1.1). The zero memory bit (SM1.0) is set when the value to be rotated is zero.
Byte operations are unsigned. For word and double word operations, the sign bit is shifted when
you use signed data types.
Error conditions that set ENO = 0
H 0006 (indirect address)
Table 6-61
Valid Operands for the Shift and Rotate Instructions
Inputs/Outputs
IN
OUT
N
SM bits affected:
H SM1.0 (zero)
H SM1.1 (overflow)
SM bits affected:
H SM1.0 (zero)
H SM1.1 (overflow)
Data Types
Operands
BYTE
IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *LD, *AC, Constant
WORD
IW, QW, VW, MW, SMW, SW, T, C, LW, AC, AIW, *VD, *LD, *AC, Constant
DWORD
ID, QD, VD, MD, SMD, SD, LD, AC, HC, *VD, *LD, *AC, Constant
BYTE
IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *LD, *AC
WORD
IW, QW, VW, MW, SMW, SW, T, C, LW, AC, *VD, *LD, *AC
DWORD
ID, QD, VD, MD, SMD, SD, LD, AC, *VD, *LD, *AC
BYTE
IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *LD, *AC, Constant
S7-200 Instruction Set
Chapter 6
179

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents