Instruction List (IL)

This language is more appropriate when your algorithm refers to the Boolean algebra.

A program written in ILClosed"Instruction list" This is a low-level language and resembles assembly language is a list of instructions.

  • Each instruction is written on one line of text.
  • An instruction can have one or more operands.
  • Operands are variables or constant expressions.
  • Each instruction can begin with a label, followed by the ":" character.
  • Labels are used as destination for jump instructions.

The KAS IDEClosed"Integrated development environment" An integrated development environment is a type of computer software that assists computer programmers in developing software. IDEs normally consist of a source code editor, a compiler and/or interpreter, build-automation tools, and a debugger allows you to mix STClosed"Structured text" A high-level language that is block structured and syntactically resembles Pascal and IL languages in textual program. ST is the default language. When you enter IL instructions, the program must be entered between "BEGIN_IL" and "END_IL" keywords, such as in the following example


BEGIN_IL
FFLD   var1
ST     var2
END_IL

Comments

Comment texts can be entered at the end of a line containing an instruction. Comment texts have no meaning for the execution of the program. A comment text must begin with "(*" and end with "*)". Comments can also be entered on empty lines (with no instruction), and on several lines (i.e. a comment text can include line breaks). Comment texts cannot be nested.

(* My comment *)
LDClosed"Ladder diagram" Ladder logic is a method of drawing electrical logic schematics. It is now a very popular graphical language for programming Programmable Logic Controllers (PLCs). It was originally invented to describe logic made from relays. The name is based on the observation that programs in this language resemble ladders, with two vertical "rails" and a series of horizontal "rungs" between them a
ST b (* Store value in d *)

Data flow

An IL complete statement is made of instructions for:
- first: evaluating an expression (called current result)
- then: use the current result for performing actions

Evaluation of expressions

The order of instructions in the program is the one used for evaluating expressions, unless parentheses are inserted. Below are the available instructions for evaluation of expressions:

Instruction

Operand

Meaning

FFLD  / FFLDN any type loads the operand in the current result
AND (&) Boolean AND between the operand and the current result
OR / ORN Boolean OR between the operand and the current result
XOR / XORN Boolean XOR between the operand and the current result
ADD numerical adds the operand and the current result
SUB numerical subtract the operand from the current result
MUL numerical multiply the operand and the current result
DIV numerical divide the current result by the operand
GT numerical compares the current result with the operand
GE numerical compares the current result with the operand
LT numerical compares the current result with the operand
LE numerical compares the current result with the operand
EQ numerical compares the current result with the operand
NE numerical compares the current result with the operand
Function call func. arguments calls a function
Parenthesis   changes the execution order

  • Instructions suffixed by N uses the Boolean negation of the operand.

Actions

The following instructions perform actions according to the value of current result. Some of these instructions do not need a current result to be evaluated:

Instruction

Operand

Meaning

ST  / STN any type stores the current result in the operand
JMP label jump to a label - no current result needed
JMPC label jump to a label if the current result is TRUE
JMPNC / JMPCN label jump to a label if the current result is FALSE
RET Jump to the end of the current program - no current result needed
RETC / RETNC / RETCN Jump to the end of the current program if the current result is TRUE / FALSE
S Boolean sets the operand to TRUE if the current result is TRUE
R Boolean sets the operand to FALSE if the current result is TRUE
CAL f. block calls a function block (no current result needed)
CALC f. block calls a function block if the current result is TRUE
CALNC / CALCN f. block calls a function block if the current result is FALSE

  • Instructions suffixed by N uses the Boolean negation of the operand.


  • IL program cannot be called if there is no entry variable, or if its type is complex (e.g. array)

Related Topics

Structured Text (ST) / Instruction List (IL) Editor