# CODESYS SHL

Instructions · `SHL` · verification: source checked

SHL is an IEC operator that shifts the bits of an operand to the left by a specified number of positions. It is written as erg := SHL(in, n), where in is the value to shift and n is the number of bit positions. The result is assigned to erg.

## Specification

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

### Parameters

| Name | Description |
|---|---|
| in | Operand which is shifted to the left |
| n | Number of bits to shift in to the left |

## Study notes

- CODESYS uses the data type of the input variable in to determine how many bits are used for the operation.
- If n exceeds the data type width, the target system determines padding for BYTE, WORD, DWORD, and LWORD operands: padding with zeros or n MOD <register size>.
- Example: in_byte := 16#45 shifted by n := 2 gives erg_byte := 16#14; in_word := 16#0045 shifted by 2 gives erg_word := 16#0114.

## Sources

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

---

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