| 数据搜索系统,热门电子元器件搜索 |
|
ST20-C1 数据表(PDF) 46 Page - STMicroelectronics |
|
|
|||||||||||||||||||||||||||||
ST20-C1 数据表(HTML) 46 Page - STMicroelectronics |
|
46 / 205 page ![]() 4.7 Evaluation of boolean expressions 46/205 ® 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 = ldc 1 false = ldc 0 !X = ¬(X) X== Y = X; Y; sub; eqc 0 X!= Y = ¬(X; Y; sub; eqc 0) X== K = X; eqc K X!= K = ¬(X; eqc K) X> Y = X; Y; gt X< Y = Y; X; gt X>= Y = ¬(Y; X; gt) X<= Y = ¬(X; Y; gt) Further optimizations can be made to the ‘not equals’ comparison when followed by a conditional jump. X != Y; cj L = X; Y; sub; cj L X != 0; 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); cj L; ¬(Y); L:) X AND Y = 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; cj L; Y; L:)] ¬(X OR Y) = ( ¬X) AND (¬Y) [= ¬(X); cj L; ¬(Y); L:] (X OR Y); cj L = ( ¬X); cj M; Y; cj L; M: (X AND Y); cj L = X; cj L; Y; cj L |
|
链接网址 |
| ALLDATASHEET是否为您带来帮助? [ DONATE ] |
关于 Alldatasheet | 广告服务 | 联系我们 | 隐私政策 | 数据表链接 | 链接交换 | 制造商名单 All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |