Shift Right Word, Shift Left Word Shift/Rotate

Inputs/Outputs Operands Data Types
IN (LAD, FBD) VW, IW, QW, MW, SW, SMW, LW, T, C, AIW, AC, Constant, *VD, *AC, *LD WORD
N VB, IB, QB, MB, SB, SMB, LB, AC, Constant, *VD, *AC, *LD BYTE
OUT VW, IW, QW, MW, SW, SMW, LW, T, C, AC, *VD, *AC, *LD WORD

Memory Ranges ENO Errors Instruction Support for S7-200 CPUs SIMATIC/International Mnemonics
The Shift Right Word and Shift Left Word instructions shift the input word (IN) value right or left by the shift count (N), and load the result in the output word (OUT).

The shift instructions fill with zeros as each bit is shifted out. If the shift count (N) is greater than or equal to 16, the value is shifted a maximum of 16 times. 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.

Note that the sign bit is shifted when you are using signed data types.

Error Conditions that Set ENO = 0:

0006 (indirect address), SM4.3 (run-time)

These instructions affect the following Special Memory bits:

SM1.0 (zero); SM1.1 (overflow)


Example