Modifiers and Operators in IL

Modifiers:

Modifier

Combined with operator

Description

C

JMP, CAL, RET

The instruction is only executed if the result of the preceding expression is TRUE.

N

JMPC, CALC, RETC

The instruction is only executed if the result of the preceding expression is FALSE.

N

otherwise

Negation of the operand (not the accumulator).

Operators with the possible modifiers:

Operator

N

Meaning

Example

LD

N

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

LD ivar

ST

N

Stores the (negated) content of the accumulator in the operands.

ST iErg

S

 

Sets the operand (type BOOL) to TRUE, if the content of the accumulator is TRUE.

S bVar1

R

 

Sets the operand (type BOOL) to FALSE, if the content of the accumulator is TRUE.

R bVar1

AND

N,(

Bitwise AND of the accumulator value and the (negated) operand

AND bVar2

OR

N,(

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

OR xVar

XOR

N,(

Bitwise, exclusive OR of the accumulator value and the (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 into the accumulator.

ADD ivar1

SUB

(

Subtraction of the operand from the accumulator value. The result is written into the accumulator.

SUB iVar2

MUL

(

Multiplication of the accumulator value and the operand. The result is written into the accumulator.

MUL ivar2

DIV

(

Division of the accumulator value by the operand. The result is written into the accumulator.

DIV 44

GT

(

Checks whether the accumulator value is greater than the value of the operand. The result (BOOL) is written into the accumulator. >

GT 23

GE

(

Checks whether the accumulator value is greater than or equal to the value of the operand. The result (BOOL) is written into the accumulator.

GE iVar2

EQ

(

Checks whether the accumulator value is equal to the value of the operand. The result (BOOL) is written into the accumulator.

EQ iVar2

NE

(

Checks whether the accumulator value is equal to the value of the operand. The result (BOOL) is written into the accumulator.

NE iVar1

LE

(

Checks whether the accumulator value is greater than or equal to the value of the operand. The result (BOOL) is written into the accumulator.

LE 5

LT

(

Checks whether the accumulator value is less than the value of the operand. The result (BOOL) is written into the accumulator.

LT cVar1

JMP

CN

Unconditional (conditional) jump to the specified label

JMPN next

CAL

CN

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

CAL prog1

RET

 

Exits the block and returns to the calling function block

RET

RET

C

If the accumulator value is TRUE: Exits the function block and returns to the calling function block

RETC

RET

CN

If the accumulator value is FALSE: Exits the function block and returns to the calling function block

RETCN

)

 

Evaluates the deferred operation

 

Example:

Modifiers and Operators in IL 1:

Application

Description

Example

Multiple operands for 1 operator

Possibilities

  • You enter the operands in successive lines, separated by a comma in the 2nd column.
  • You repeat the operator in successive lines.

Version 1:

Modifiers and Operators in IL 2:

Version 2:

Modifiers and Operators in IL 3:

Complex operands

For a complex operand, specify the opening bracket ( in the first column. Enter the closing bracket in the first column in a separate line after the operand entries for the following lines.

A string is rotated by one character each cycle:

Modifiers and Operators in IL 4:

Function block call, subroutine call

Column 1: Operator CAL or CALC

Column 2: Name of the function block instance or program and opening bracket (. If no parameters follow, the closing bracket ) is entered here.

Subsequent lines:

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

Column 2: Parameter value followed by comma, if followed by other parameters. After the last parameter the closing bracket ) is entered.

Complex expressions cannot be used here, which is a restriction with regard to the IEC standard. You must assign such constructs to the function block or the program before the call.

Modifiers and Operators in IL 5:

Function call

Line 1: Column 1: LD

Column 2: Input Variable

Line 2: Column 1: Function name column 2: further input parameters, separated by commas.

TwinCAT writes the return value to the accumulator.

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

Modifiers and Operators in IL 6:

Action call

Like function block or program call.

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

Modifiers and Operators in IL 7:

Jump

Column 1: Operator JMP or JMPC.

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

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

For a conditional jump, the execution depends on the loaded value.

Modifiers and Operators in IL 8:

See also: