Guide to Assembly Language Programming in Linux

This chapter continues the assembly language overview from the last chapter. After the introduction, we discuss the data exchange and translate instructions. Then we describe the assembler directives to define constants numeric as well as string constants. Next we discuss macros supported by NASM. Macros provide a sophisticated text substitution mechanism and are useful in program maintenance. NASM allows definition of macros with parameters. We use several examples to illustrate the application of the instructions discussed here. The performance advantage of the translation instruction is demonstrated in the last section. The chapter concludes with a summary.
As mentioned in the last chapter, three types of statements are used in assembly language programs: instructions, assembler directives, and macros. We have discussed several instructions and directives in the last chapter. For example, we used assembler directives to allocate storage space for variables. This chapter continues our discussion from the last chapter and covers a few more processor instructions, some assembler directives to define constants, and macros.
We present some more instructions of the IA-32 instruction set. We describe two instructions for data exchange and translation: xchg and xlat. The xchg instruction exchanges two data values. These values can be 8, 16, or 32 bit values. This instruction is particularly useful in sort applications. The xlat instruction translates a byte value. We also discuss the shift and rotate family of instructions. We illustrate the use of these instructions by means of several examples.
Next we discuss the NASM directives...