Skip to main content

Modifiers and Operators in IL

Table 5. Modifiers

Modifier

Combined with operator

Description

C

JMP, CAL, RET

The command is executed only when the result of the preceding expression is TRUE.

N

JMPC, CALC, RETC

The command is executed only when the result of the preceding expression is FALSE.

N

Otherwise

Negation of the operand (not of the accumulator)



Table 6. Operators with the possible modifiers

Operator

N

Meaning

Example

LD

N

Loads the (negated) the value of the operand into the accumulator

LD ivar

ST

N

Stores the (negated) contents of the accumulator in the operand

ST iErg

S

Sets the operand (type BOOL) to TRUE if the contents of the accumulator is TRUE

S bVar1

R

Sets the operand (type BOOL) to FALSE if the contents of the accumulator is TRUE

R bVar1

AND

N,(

Bitwise AND of the accumulator value and (negated) operand

AND bVar2

OR

N,(

Bitwise OR of the accumulator value and (negated) operand

OR xVar

XOR

N,(

Bitwise exclusive OR of the accumulator value and (negated) operand

XOR N,(bVar1,bVar2)

NOT

Bitwise negation of the accumulator value

ADD

(

Addition of the accumulator value and the operand

The result is written to the accumulator.

ADD ivar1

SUB

(

Subtraction of the operand from the accumulator value

The result is written to the accumulator.

SUB iVar2

MUL

(

Multiplication of accumulator value and operand

The result is written to the accumulator.

MUL ivar2

DIV

(

Addition of the accumulator value and the operand

The result is written to the accumulator.

DIV 44

GT

(

Checks if the accumulator value is greater than the operand value

The result (BOOL) is written to the accumulator.

GT 23

GE

(

Checks if the accumulator value is greater than or equal to the operand value

The result (BOOL) is written to the accumulator.

GE iVar2

EQ

(

Checks if the accumulator value is equal to the operand value

The result (BOOL) is written to the accumulator.

EQ iVar2

NE

(

Checks if the accumulator value is not equal to the operand value

The result (BOOL) is written to the accumulator.

NE iVar1

LE

(

Checks if the accumulator value is less than or equal to the operand value

The result (BOOL) is written to the accumulator.

LE 5

LT

(

Check if the accumulator value is less than the operand value

The result (BOOL) is written to the accumulator.

LT cVar1

JMP

CN

Unconditional (conditional) jump to the specified jump label

JMPN next

CAL

CN

(Conditional) call of a program or a function block (if the accumulator value is TRUE)

CAL prog1

RET

Exit the box and return to the calling box

RET

RET

C

If the accumulator value is TRUE: Exit the box and return to the calling box

RETC

RET

CN

If the accumulator value is FALSE: Exit the box and return to the calling box

RETCN

)

Evaluation of the reset operation



Example 9. Example
_cds_img_il_example.png


Application

Description

Examples

Multiple operands for one operator

. Options
  • You enter the operands into consecutive rows, separated by commas in the 2nd column.

  • You repeat the operator in consecutive rows.

Variant 1:

_cds_img_il_add_multiple_operands_1.png

Variant 2:

_cds_img_il_add_multiple_operands_2.png

Complex operands

For a complex operand, you enter the opening bracket ( in the first column. You enter the closing bracket in the first column in a separate row following the operand entries of the following rows.

A string is rotated by one character each cycle.

_cds_img_il_complex_oparand.png

Function block call, program call

Column 1: CAL operator or CALC operator

Column 2: Name of the function block instance or program and opening bracket (

If no parameters follow, then the closing bracket ) is entered here.

Rows to follow that:

Column 1: Parameter name followed by := for input parameter or => for output parameter

Column 2: Parameter value followed by a comma , if further parameters follow

The closing bracket ) is input after the last parameter.

As a limitation according to the IEC standard, complex expressions cannot be used here. You need to assign such constructs to the function block or the program before the call.

_cds_img_il_fb_call1.png

Function call

Line 1: Column 1: LD

Column 2: Input variable

Line 2: Column 1: Function name Column 2: Further input parameters separated by comma

CODESYS writes the return value into the accumulator.

Line 3: Column 1: ST Column 2: Variable into which the return value is written

_cds_img_il_function_call.png

Action call

Like function block call or program call.

The action name is appended to the name of the FB instance or the program.

_cds_img_il_action_call.png

Jump

Column 1: JMP operator or JMPC operator

Column 2: Name of the jump label of the destination network

In the case of an unconditional jump, the preceding instruction sequence must end with one of the following commands: ST,STN, S, R, CAL, RET, JMP

In the case of a conditional jump the execution of the jump depends on the loaded value.

_cds_img_il_jmp.png
. For more information, see the following: