Program instructions
7.14 Shift and rotate
S7-200 SMART
System Manual, 09/2015, A5E03822230-AC
315
Shift and rotate
Shift instructions (only the byte size LAD box is illustrated, the others are similar)
N
SRB OUT,
N
Shift left byte
Shift right byte
The shift instructions shift the bit values of input value IN right or left by
the bit position shift count N and load the result in the memory location
assigned to OUT.
The shift instructions fill empty bit positions with zero as each bit is shift-
ed out. If the shift count N is greater than or equal to the maximum al-
lowed (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 is set to the value of the last bit shifted out. The SM1.0 zero
memory bit 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 values.
SHL_W
SHR_W
N
SRW OUT,
Shift left word
Shift right word
SHL_DW
SHR_DW
N
SRD OUT,
Shift left double
word
Shift right double
Non-fatal errors with ENO=0
• 0006H Indirect address • SM1.0 Result of operation = zero
• SM1.1 Overflow (last bit shifted out)
IN
IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *LD, *AC, Constant
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
OUT
IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *LD, *AC
IW, QW, VW, MW, SMW, SW, T, C, LW, AC, *VD, *LD, *AC
ID, QD, VD, MD, SMD, SD, LD, AC, *VD, *LD, *AC
IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *LD, *AC, Constant