Chapter 8: Intermediate Code Generation

Methods of translation

. Evaluate similar to arithmetic expressions

- Normally use 1 for true and 0 for false

. implement by flow of control

- given expression E 1 or E2 if E1 evaluates to true then E1 or E 2 evaluates to true without evaluating E2

There are two principal methods of representing the value of Boolean expressions-

1. Encode true and false numerically and evaluate analogously to an arithmetic expression. Normally 1 is used to denote true and 0 to denote false.

2. Implementing Boolean expressions by flow of control, that is, representing the value of a Boolean expression by the position reached in the program. For example, consider the expression - a or (b and c). If the value of a is true the values of b and c can be ignored and the entire expression can be assigned the value true. If a is false the value of (b and c) needs to be considered. If the value of b is false, the expression (b and c) and hence the entire expression can be assigned value false. The value of c needs to be considered only if a is false and b is true.