Qdatasheet_Logo
Integrated circuits, Transistor, Semiconductors Search and Datasheet PDF Download Site

ST20-C1 View Datasheet(PDF) - STMicroelectronics

Part Name
Description
MFG CO.
ST20-C1
ST-Microelectronics
STMicroelectronics ST-Microelectronics
'ST20-C1' PDF : 205 Pages View PDF
4.7 Evaluation of boolean expressions
The following shows the correspondence between C logical expressions and ST20-C1
instructions. X and Y represent expressions,and K represents a constant. The symbol
¬’ is a logical NOT (see section 4.7.1).
true
=
false
=
!X
=
X == Y
=
X != Y
=
X == K
=
X != K
=
X>Y
=
X<Y
=
X >= Y
=
X <= Y
=
ldc 1
ldc 0
¬(X)
X; Y; sub; eqc 0
¬(X; Y; sub; eqc 0)
X; eqc K
¬(X; eqc K)
X; Y; gt
Y; X; gt
¬(Y; X; gt)
¬(X; Y; gt)
Further optimizations can be made to the ‘not equals’ comparison when followed by a
conditional jump.
X != Y; cj L
=
X != 0; cj L
=
X; Y; sub; cj L
X; cj L
4.7.1 Evaluation of NOT
If zero represents false and 1 represents true, then logical NOT can be performed by
eqc 0.
4.7.2 Evaluation of AND and OR
For evaluation of logical AND and OR operations, the instruction sequence depends
on whether strict or non-strict evaluation is used, i.e. whether both operands are
always evaluated. This is important if side-effects may occur, such as a trap, or if the
second operand is not always defined, as in:
if ((ptr != NULL) && (ptr->tag == TAG_VAL)) ...
In this example, ptr->tag is not defined if ptr is NULL. For languages such as ANSI
C, non-strict evaluation is required, so the following short-cuts must be used:
X OR Y
=
X AND Y
=
¬(¬(X); cj L; ¬(Y); L:)
X; cj L; Y; L:
For non-strict evaluation, the following laws should be applied to the compilation of
conditional expressions before code is generated to ensure that the jump is taken as
early as possible:
¬(X AND Y) = (¬X) OR (¬Y)
¬(X OR Y)
= (¬X) AND (¬Y)
(X OR Y); cj L = (¬X); cj M; Y; cj L; M:
(X AND Y); cj L = X; cj L; Y; cj L
[= ¬(X; cj L; Y; L:)]
[= ¬(X); cj L; ¬(Y); L:]
46/205
®
Share Link: GO URL

All Rights Reserved © qdatasheet.com  [ Privacy Policy ] [ Contact Us ]