RORΒΆ

The IEC Operators and additional, norm-extending \ functions Bitwise rotation of an operand to the right: erg:= ROL (in, n)

erg, in and n should be of the type BYTE, WORD or DWORD. in will be shifted one bit position to the right n times while the bit that is furthest to the right will be reinserted from the left.

Note

The amount of bits used for the arithmetic operation is determined by the data type of the input variable! If the input variable is a constant the smallest possible data type is used. The data type of the output variable has no effect at all on the arithmetic operation.

In the following example in hexadecimal notation you get different results for erg_byte and erg_word depending on the data type of the input variable (BYTE or WORD), although the values of the input variables in_byte and in_word are the same.

Example in IL:

LD 16#45
ROR 2
ST erg_byte

Example in ST:

PROGRAM ror_st
VAR
in_byte : BYTE:=16#45;
in_word : WORD:=16#45;
erg_byte : BYTE;
erg_word : WORD;
n: BYTE :=2;
END_VAR
erg_byte:=ROR(in_byte,n); (* Result is 16#51 *)
erg_word:=ROR(in_word,n); (* Result is 16#4011 *)

Example in FBD:

../_images/afee196c4373986d0a3313905c72d969