The Art of Assembly Language

Boolean logic is the basis of computation in modern computer systems. You can represent any algorithm, or any electronic computer circuit, using a system of Boolean equations. To fully understand how software operates you need to understand basic Boolean logic and digital design.

This material is especially important to those who want to design electronic circuits or write software that controls electronic circuits. Even if you never plan to do this, you can use your knowledge of Boolean logic to optimize your software. However, there is one other reason for studying Boolean functions, even if you never intend to do either of these two things. Many high-level languages process Boolean expressions, such as those that control an if statement or while loop. By optimizing your Boolean expressions, it is often possible to improve the performance of high-level language code. Therefore, studying Boolean functions is important even if you never intend to design an electronic circuit. It can help you write better code in a traditional programming language.

8.1 Boolean Algebra

Boolean algebra is a deductive mathematical system. A binary operator ' °' accepts a pair of Boolean inputs and produces a single Boolean value. For example, the Boolean AND operator accepts two Boolean inputs and produces a single Boolean output (the logical AND of the two inputs).

8.1.1 The Boolean Operators

For our purposes, we will base Boolean algebra on the following set of operators and values:

8.1.2 Boolean Postulates

Every algebraic system follows a certain set of initial assumptions, or postulates . You can deduce additional rules, theorems, and other properties of the system from this basic set of postulates. Boolean algebra systems are no different, and usually employ the following postulates:

When applied to the Boolean operators, the preceding postulates produce the following set of Boolean postulates :

You can prove all other theorems in Boolean algebra using this set of Boolean postulates. This chapter will not go into the formal proofs of the following theorems, but familiarity with some important theorems in Boolean algebra will be useful. Here are some of the important theorems:

Th1:

A + A = A

Th2:

A * A = A

Th3:

A + 0 = A

Th4:

A * 1 = A

Th5:

A * 0 = 0

Th6:

A + 1 = 1

Th7:

( A + B ) ' = A' * B'

Th8:

( A * B ) ' = A' + B'

Th9:

A + A * B = A

Th10:

A * ( A + B ) = A

Th11:

A + A'B = A + B

Th12:

A' * ( A + B' ) = A'B'

Th13:

AB + AB' = A

Th14:

( A' + B' ) * ( A' + B ) = A'

Th15:

A + A' = 1

Th16:

A * A' = 0

Note  

Theorems seven and eight are called DeMorgan's Theorems after the mathematician who discovered them.

An important principle in the Boolean algebra system is that of duality . Each pair, theorems 1 and 2, theorems 3 and 4, and so on, forms a dual . Any valid expression you can create using the postulates and theorems of Boolean algebra remains valid if you interchange the operators and constants appearing in the expression. Specifically, if you exchange the * and + operators and swap the 0 and 1 values in an expression, the resulting expression will obey all the rules of Boolean algebra. This does not mean the dual expression computes the same values ; it only means that both expressions are legal in the Boolean algebra system.

8.1.3 Boolean Operator Precedence

If several different Boolean operators appear within a single Boolean expression, the result of the expression depends on the precedence of the operators. The following Boolean operators are ordered from highest precedence to lowest :

The logical AND and OR operators are left associative. This means that if two operators with the same precedence appear between three operands, you must evaluate the expressions from left to right. The logical NOT operation is right associative, although it would produce the same result using either left or right associativity because it is a unary operator having only a single operand.

Категории