Operator ‘ROL’ΒΆ

This IEC operator is used for bitwise rotation of an operand to the left.

Permitted data types: BYTE, WORD, DWORD, LWORD

erg := ROL (in, n)

CODESYS moves in n-times one bit to the left and adds the bit to the leftmost position from the right.

Hint

Please note the number of bits that CODESYS uses for this operation as defined by the data type of the input variable in. If this is a constant, then CODESYS uses the smallest possible data type. The data type of the output variables still does not influence this operation.

Examples

The results for erg_byte and erg_word are different depending on the data type of the input variables, although the values of the in_byte and in_word input variables are the same.

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: 16#15 *)

erg_word := ROL(in_word,n); (* Result: 16#0114 *)

FBD:

IL: