ROL

The IEC Operators and additional, norm-extending \ functions Bitwise rotation of an operand to the left: 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 left n times while the bit that is furthest to the left will be reinserted from the right.

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
ROL 2
ST erg_byte

Example in ST:

PROGRAM rol_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:=ROL(in_byte,n); (* Result is 16#15 *)
erg_word:=ROL(in_word,n); (* Result is 16#0114 *)

Example in FBD:

../_images/9f37fc13437397e10a3313905c72d969