IL Language Basics

Instruction List (IL) is a low-level text-based programming language defined in the IEC 61131-3 standard. It works like assembly language for PLCs. Each line contains a single instruction that operates on an accumulator register. IL is the most compact IEC language but also the least readable, making it best suited for simple programs or legacy migration.

Note: IL was deprecated in the IEC 61131-3 third edition (2013) in favor of Structured Text. The Autonomy Edge IDE supports IL for backward compatibility, but for new projects, Structured Text is recommended.

How IL Works

IL uses an accumulator-based execution model. There's a single implicit register (the "current result" or accumulator) that every instruction operates on:

  1. You load a value into the accumulator.
  2. You perform operations (AND, OR, ADD, etc.) between the accumulator and an operand.
  3. You store the accumulator value into an output variable.

Every IL program follows this load → operate → store pattern, repeated for each piece of logic.

Instruction Format

Each IL instruction occupies one line:

code
[label:] operator [operand] [comment]
  • Label (optional): A name followed by a colon. Used as a jump target.
  • Operator: The instruction mnemonic (e.g., LD, AND, ST).
  • Operand (optional): The variable or literal the instruction operates on.
  • Comment (optional): Text inside (* ... *).

Examples:

code
LD sensor_a (* Load sensor_a into accumulator *) AND sensor_b (* AND with sensor_b *) ST output (* Store result to output *)

Core Instructions

Load and Store

InstructionDescriptionExample
LDLoad operand into accumulatorLD sensor_a
LDNLoad negated operand into accumulatorLDN error_flag
STStore accumulator to operandST output
STNStore negated accumulator to operandSTN alarm_clear
SSet operand to TRUE (latch)S motor_run
RReset operand to FALSE (unlatch)R motor_run

LD always starts a new logic evaluation. ST writes the result without modifying the accumulator, so you can chain multiple stores.

Boolean Logic

InstructionDescriptionExample
ANDLogical AND with operandAND ready_signal
ANDNLogical AND NOT with operandANDN fault_signal
ORLogical OR with operandOR alternate_input
ORNLogical OR NOT with operandORN inhibit
XORLogical exclusive ORXOR toggle_input
XORNLogical exclusive OR NOTXORN parity_bit
NOTNegate the accumulator (no operand)NOT

The N suffix on AND, OR, and XOR means "negate the operand before the operation". Equivalent to operating with NOT(operand).

Arithmetic

InstructionDescriptionExample
ADDAdd operand to accumulatorADD offset_value
SUBSubtract operand from accumulatorSUB correction
MULMultiply accumulator by operandMUL gain
DIVDivide accumulator by operandDIV scale_factor
MODModulo (remainder)MOD wrap_limit

Comparison

InstructionDescriptionResult
GTGreater thanAccumulator = TRUE if previous > operand
GEGreater than or equalAccumulator = TRUE if previous ≥ operand
EQEqualAccumulator = TRUE if previous = operand
NENot equalAccumulator = TRUE if previous ≠ operand
LELess than or equalAccumulator = TRUE if previous ≤ operand
LTLess thanAccumulator = TRUE if previous < operand

Jump and Call

InstructionDescriptionExample
JMPUnconditional jump to labelJMP loop_start
JMPCJump if accumulator is TRUEJMPC error_handler
CALCall function blockCAL timer_instance
CALCCall if accumulator is TRUECALC my_block
RETReturn from POURET
RETCReturn if accumulator is TRUERETC

Tip: To jump when the accumulator is FALSE, use NOT followed by JMPC. The JMPN, CALN, and RETN instructions from the IEC standard are not supported.

Program Structure

A complete IL program follows this pattern:

code
(* Load first input *) LD input_1 (* Combine with second input *) AND input_2 (* Store the result *) ST output_1

There are no explicit variable declarations in the IL code body. All variables are defined in the Variables Table above the editor.

Labels and Jumps

Labels mark locations in the code that can be targeted by JMP instructions:

code
start: LD counter ADD 1 ST counter LD counter LT 100 JMPC start (* Jump back to 'start' if counter < 100 *) LD TRUE ST done

This creates a loop that increments counter until it reaches 100.

Tip: Loops in IL using JMP/JMPC can cause the scan to overrun if the loop doesn't terminate quickly. For long-running loops, use a state machine pattern across multiple scan cycles instead.

Parenthesized Expressions

IL supports parentheses to change evaluation order, similar to nested expressions in algebra:

code
LD a AND( b OR c ) ST result

This evaluates as: result := a AND (b OR c).

Without parentheses, IL evaluates strictly left to right, so LD a / AND b / OR c would compute as (a AND b) OR c.

For more complex expressions with multiple levels of nesting, use an intermediate variable instead of deeply nested parentheses:

code
LD z OR w AND y ST temp LD x OR temp ST output

This evaluates as: output := x OR (y AND (z OR w)). Breaking complex expressions into steps with intermediate variables is more readable and avoids compiler limitations with deeply nested parentheses.

The IL Editor

The Autonomy Edge IDE provides a code editor for IL with:

  • Syntax highlighting: Keywords (LD, AND, OR, ST, etc.) are highlighted in a distinct color. Labels, operands, and comments each have their own color.
  • Label recognition: Labels (text followed by :) are highlighted differently for easy identification.
  • Block comments: The editor supports (* ... *) comment blocks.
  • Case insensitivity: IL keywords can be uppercase or lowercase; the editor recognizes both.

Unlike ST, the IL editor does not currently provide IntelliSense autocomplete for variable names. You'll need to reference the Variables Table manually when writing IL code.

IL vs. Other Languages

AspectInstruction ListStructured Text
Abstraction levelLow (assembly-like)High (Pascal-like)
ReadabilityPoor for complex logicGood
Code densityVery compactModerate
Learning curveSteepModerate
Modern recommendationDeprecated (use ST)Preferred

What's Next?

See practical IL examples: IL Examples.