Guide to Assembly Language Programming in Linux

Bit manipulation is an important aspect of many high-level languages. This chapter discusses the logical and bit manipulation instructions supported by the assembly language. Assembly language provides several logical instructions to implement logical expressions. These instructions are also useful in implementing bitwise logical operations. In addition, several shift and rotate instructions are provided to facilitate bit manipulation. A few instructions are also provided to test and modify bits. These four types of instructions are discussed in this chapter. After describing these instructions, we give several examples to illustrate their application. The chapter concludes with a summary.
Modern high-level languages provide several conditional and loop constructs. These constructs require Boolean or logical expressions for specifying conditions. Assembly language provides several logical instructions to express these conditions. These instructions manipulate logical data just like the arithmetic instructions manipulate arithmetic data (e.g., integers) with operations such as addition and subtraction. The logical data can take one of two possible values: true or false.
As the logical data can assume only one of two values, a single bit is sufficient to represent these values. Thus, all logical instructions that we discuss here operate on a bit-by-bit basis. By convention, if the value of the bit is 0 it represents false, and a value of 1 represents true.
We have discussed the assembly language logical instructions in Chapter 9, we devote part of this chapter to look at the typical uses for these logical instructions. The assembly language also provides...