What does an instruction look like?
The instruction is the key element in the computer as it tells the processor which action should be
performed. The instructions which are to be executed are indicated in the source file and the computer goes from
one instruction to the next following the instructions from top to bottom (as a file is read in sequence from top to
bottom).
An instruction is generally comprised of two elements:
- the operator: the action that the processor is to carry out
- the operand(s): one or more pieces of data on which the operation is performed
Types of operators:
There are generally two or three types of operators:
- Unary operators: those which operate on one operand only
- Binary operators: these operators are those which, contrary to what you would think, do not work on binary
operands, but rather work on two operands (binary here means the number of operands that are affected, addition,
often denoted as +, is therefore a binary operator)
- Ternary operators: are operators which allow three operands (for example, conditional operators are ternary
operators)
Operators may also be divided into several categories according to the type of operation they perform when
executed:
- arithmetic operators
- comparison operators
- logical operators
- bit operators
- assignment operators
- conditional operators
- sequential operators
- ...
Operator priority
Each language generally has operator precedence so that the computer knows in which
direction to calculate the operators where several operators exist in the same expression