Instructions and operators

Expressions
Simple expressions:
Variable:
m
Constant:
4
Composed expressions:
Arithmetic operators precedence
Post-increase/Post-decrease ➡️ e.g.:
i++
,i--
Pre-increase/Pre-decrease ➡️ e.g.:
++i
,--i
* / %
➡️ e.g.:i*2
,i/2
,i%2
+ -
➡️ e.g.:i+1
,i-1
=
➡️ e.g.:i=1
These operators have Side Effect on the operands (they can modify their values).
Relational
Comparison ➡️
< <= > >=
Equality ➡️
=
Inequality ➡️
!=
Logical
NOT ➡️
!
OR ➡️
||
AND ➡️
&&
These operators have Lazy evalutation:
expr1 && expr2
: ifexpr1
isfalse
,expr2
is not evaluated ➡️ returnsfalse
expr1 || expr2
: ifexpr1
istrue
,expr2
is not evaluated ➡️ returnstrue
Bitwise applicable only to two data types (
int
andchar
) and all the other derivated types (short int
,unsigned int
,long int
,unsigned char
)
~x
Bitwise Complement
x ^ y
AND
x | y
OR
x ^ y
XOR
x >> n
Right SHIFT (by n
bits)
Add 1s on the left
x << n
Left SHIFT (by n
bits)
Add 0s on the right
L-value
Modifiable entities and variable:
on the left of the assignment operator (
=
)they should not be:
constants
results of expressions (
m+n = 0;
)
Instruction (Expression Statement)
Expression with Side Effect followed by ;
.
Example: The following expression is not read by the compiler (the same happens for the comments):
i+4;
because the previous instruction has not side effect.
Last updated