Boolean Algebra

In this lesson, you will learn following related to Boolean algebra in assembly language.

1. What is Boole

2. Boolean Algebra

Boole observed that by encoding logic values true and false as binary values 1 and 0. The simplest Boolean algebra is defined over the two-element set {0, 1}.

Below are several operations in this algebra. Our symbols for representing these operations are chosen to match those used by the C bit-level operations.

Operations of Boolean algebra. Binary values 1 and 0 encode logic values true and false, while operations ~, &, | , and ^ encode logical operations not, and, or, and exclusive-or, respectively.

The Boolean operation ~ corresponds to the logical operation not, denoted by the symbol ¬. That is, we say that ¬P is true when P is not true, and vice versa. Correspondingly, ~p equals 1 when p equals 0, and vice versa. Boolean operation & corresponds to the logical operation and, denoted by the symbol ∧. We say that P Q holds when both P is true and Q is true. Correspondingly, p & q equals 1 only when p = 1 and q = 1. Boolean operation | corresponds to the logical operation or, denoted by the symbol ∨. We say that P Q holds when either P is true or Q is true. Correspondingly, p | q equals 1 when either p = 1 or q = 1. Boolean operation ^ corresponds to the logical operation exclusive-or, denoted by the symbol ⊕. We say that P Q holds when either P is true or Q is true, but not both. Correspondingly, p ^ q equals 1 when either p = 1 and q = 0, or p = 0 and q = 1.

Example 1: Consider the case where w = 4, and with arguments a = [0110] and b = [1100]. What will be the four operations a & b, a | b, a ^ b, and ~b.

Solution:


Example 2: Computers generate color pictures on a video screen or liquid crystal display by mixing three different colors of light: red, green, and blue. Imagine a simple scheme, with three different lights, each of which can be turned on or off, projecting onto a glass screen. We can then create eight different colors based on the absence (0) or presence (1) of light sources R, G, and B,

RedGreenBlueColor
000Black
001Blue
010Green
011Cyan
100Red
101Magenta
110Yellow
111While
Color Vectors

Each of these colors can be represented as a bit vector of length 3, and we can apply Boolean operations to them. Answer followings related to these vectors.

  1. The complement of a color is formed by turning off the lights that are on and turning on the lights that are off. What would be the complement of each of the eight colors listed above?
  2. Describe the effect of applying Boolean operations on the following colors:
    • Blue | Green = ___________
    • Yellow & Cyan = ___________
    • Red ^ Magenta = ____________

Solution: Part A

RedGreenBlueColorComplement
000BlackWhite (1 1 1)
001BlueYellow (1 1 0)
010GreenMagenta (1 0 1)
011CyanRed (1 0 0)
100RedCyan (0 1 1)
101MagentaGreen (0 1 0)
110YellowBlue (0 0 1)
111WhileBlack (0 0 0)
Color and Complement Vectors

Solution: Part B

  • Blue | Green = [001] | [010] = [011] = Cyan
  • Yellow & Cyan = [110] & [011] = [010] = Green
  • Red ^ Magenta = [100] ^ [101] = [001] = Blue

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Design a site like this with WordPress.com
Get started