The IEC operator is used for bitwise shift of an operand to the right.
erg := SHR (in, n)
in
: Operand which is shifted to the right
n
: Number of bits to shift in
to the right




NOTICE

If n
exceeds the data type width, then it depends on the target system how the BYTE
, WORD
, DWORD
, and LWORD
operands are padded. The target systems cause padding with zeros or n MOD <register size>
.
Examples
ST
PROGRAM shr_st VAR in_byte : BYTE := 16#45; (* 2#01000101 ) in_word : WORD := 16#0045; (* 2#0000000001000101 ) erg_byte : BYTE; erg_word : WORD; n: BYTE := 2; END_VAR erg_byte := SHR(in_byte,n); (* Result is 16#11, 2#00010001 *) erg_word := SHR(in_word,n); (* Result is 16#0011, 2#0000000000010001 *)
FBD
