You can use the following modifiers in Instruction List.
C |
with JMP, CAL, RET: |
The instruction will only be executed if the result of the preceding expression is TRUE. |
N |
with JMPC, CALC, RETC: |
The instruction will only be executed if the result of the preceding expression is FALSE. |
N |
with operators according to the Operators table below (N in Modifiers column) |
Negation of the operand (not of the accumulator). |
( |
with operators according to the Operators table below (( (left parenthesis) in Modifiers column) |
To be used for complex operands. For details, refer to the list of use cases for complex operands. |
NOTE: Generally, it is not good practice to use the statement CALC (/RETC/JMPC) directly after an STN, S or R operator, as those instructions arbitrarily modify the value of the accumulator and thus could lead to difficult-to-find programming errors.
The table shows which operators can be used in combination with the specified modifiers.
The accumulator stores the current value, resulting from the preceding operation.
Operator |
Modifiers |
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 into the operand variable. |
ST iErg |
S |
– |
Sets the operand (type BOOL) to TRUE when the content of the accumulator is TRUE. |
S bVar1 |
R |
– |
Sets the operand (type BOOL) to FALSE when the content of the accumulator is TRUE. |
R bVar1 |
AND |
N,( |
Bitwise AND of the accumulator and the (negated) operand. |
AND bVar2 |
OR |
N,( |
Bitwise OR of the accumulator and the (negated) operand. |
OR xVar |
XOR |
N,( |
Bitwise exclusive OR of the accumulator and the (negated) operand. |
XOR N, (bVar1,bVar2) |
NOT |
– |
Bitwise negation of the content of the accumulator. |
– |
ADD |
( |
Addition of accumulator and operand, result is copied to the accumulator. |
ADD iVar1 |
SUB |
( |
Subtraction of accumulator and operand, result is copied to the accumulator. |
SUB iVar2 |
MUL |
( |
Multiplication of accumulator and operand, result is copied to the accumulator. |
MUL iVar2 |
DIV |
( |
Division of accumulator and operand, result is copied to the accumulator. |
DIV 44 |
GT |
( |
Verifies if accumulator is greater than the operand, result (BOOL) is copied into the accumulator; > |
GT 23 |
GE |
( |
Verifies if accumulator is greater than or equal to the operand, result (BOOL) is copied into the accumulator; >= |
GE iVar2 |
EQ |
( |
Verifies if accumulator is equal to the operand, result (BOOL) is copied into the accumulator; = |
EQ iVar2 |
NE |
( |
Verifies if accumulator is not equal to the operand, result (BOOL) is copied into the accumulator; <> |
NE iVar1 |
LE |
( |
Verifies if accumulator is less than or equal to the operand, result (BOOL) is copied into the accumulator; <= |
LE 5 |
LT |
( |
Verifies if accumulator is less than operand, result (BOOL) is copied into the accumulator; < |
LT cVar1 |
JMP |
C, CN |
Unconditional (conditional) jump to the label oJMP = unconditional jump oJMPC = conditional jump if accumulator is TRUE oJMPCN = conditional jump if accumulator is FALSE |
JMP next |
CAL |
C, CN |
Unconditional (conditional) call of a PROGRAM or FUNCTION_BLOCK oCAL = unconditional call oCALC = conditional call if accumulator is TRUE oCALCN = conditional call if accumulator is FALSE |
CAL prog1 |
RET |
C, CN |
Unconditional (conditional) return of the POU and jump back to the calling POU oRET = unconditional return oRETC = conditional return if accumulator is TRUE oRETCN = conditional return if accumulator is FALSE |
RET |
) |
– |
Evaluate deferred operation |
– |
See also IEC operators and Work in IL editor for how to use and handle multiple operands, complex operands, function / method / function block / program / action calls and jumps.
Example IL program using some modifiers:
LD TRUE load TRUE to accumulator
ANDN bVar1 execute AND with negative value of bVar1
JMPC m1 if accum. is TRUE, jump to label "m1"
LDN bVar2 store negated value of bVar2...
ST bRes ... in bRes
___________________________________________________________
m1:
LD bVar2 store value of bVar2...
ST bRes ... in bRes
The table lists use cases for operands:
Use case |
Description |
Examples |
---|---|---|
Several operands for one operator |
Options oEnter the operands into consecutive rows, separated by commas in the 2nd column. oRepeat the operator in consecutive rows. |
oOption 1: LD 2 oOption 2: LD 2 |
Complex operands |
For a complex operand, enter the left parenthesis ( in the first column. Enter the right parenthesis in the first column in a separate row followed by the operand entries in the following rows. |
A string is rotated by one character each cycle: LD stRotate |
Function block call, program call |
Row 1: oColumn 1: Operator CAL or CALC oColumn 2: Name of the function block instance or the program and left parenthesis (. If no parameters follow, the right parenthesis ) is entered here. Following rows: oColumn 1: Parameter name followed by: o:= for input parameters o=> for output parameters oColumn 2: Parameter value followed by a comma , if followed by further parameters. Enter the right parenthesis ) after the last parameter. According to the IEC standard complex expressions are not allowed here. Assign such constructs to the function block or the program before it is called. |
CAL POUToCall( |
Function call |
Row 1: oColumn 1: LD oColumn 2: Input variable Row 2: oColumn 1: Function name oColumn 2: Further input parameters, separated by commas The return value is written to the accumulator. Row 3: oColumn 1: ST oColumn 2: Variable to which the return value is written |
LD X7 |
Action call |
Similar to function block call or program call. The name of the action is appended to the name of the function block instance or the program. |
CAL POU1.ResetAction |
Jump |
oColumn 1: Operator JMP or JMPC oColumn 2: Name of the jump label of the destination network. oUnconditional jump: The preceding instruction sequence must end with one of the following commands: oST oSTN oS oR oCAL oRET oJMP oConditional jump: The execution of the jump depends on the loaded value. |
LD BVar1 |