# CODESYS ROL

Instructions · `ROL` · verification: source checked

ROL is an IEC operator in CODESYS that performs a bitwise rotation of an operand to the left. It moves the input value n bit positions to the left and places the bits shifted out of the leftmost position back in from the right. The result is assigned to an output variable; permitted data types are BYTE, WORD, DWORD and LWORD.

## Specification

| Property | Value |
|---|---|
| Language | iec 61131 3 |
| Code | ROL |
| Syntax | erg := ROL(in, n) |
| Dialect | CODESYS |

### Parameters

| Name | Data type | Description |
|---|---|---|
| in | BYTE, WORD, DWORD, LWORD | Operand to be rotated left; its data type determines the number of bits used. |
| n | BYTE | Number of bit positions the operand is rotated to the left. |

## Study notes

- Permitted data types for the operand are BYTE, WORD, DWORD and LWORD.
- The number of bits used for the rotation is defined by the data type of the in input variable.
- If the input is a constant, CODESYS uses the smallest possible data type.
- The data type of the output variable does not influence the operation.
- Example: with n = 2, ROL on BYTE 16#45 gives 16#15, while ROL on WORD 6#45 gives 16#0114, because the input data types differ.
- The operator is shown with ST, FBD and IL representations.

## Sources

1. [Beckhoff Information System](https://infosys.beckhoff.com/content/1033/tc3_plc_intro/2528945291.html) (accessed 2026-10-26)
2. [CODESYS Group](https://content.helpme-codesys.com/en/CODESYS%20Development%20System/_cds_operator_rol.html) (accessed 2026-10-26)

---

Source page: https://machineschema.com/instruction/iec-rol  
JSON: https://machineschema.com/instruction/iec-rol.json  
License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Cite Machine Schema and the original sources.
