Guide to Assembly Language Programming in Linux

Assembly language provides several instructions to facilitate conditional execution. We have discussed some of these instructions like jmp and loop in Chapter 9. Our discussion here complements that discussion. In this chapter, we give more details on these instructions including how the target address is specified, how the flags register is used to implement conditional jumps, and so on. The jump instructions we have used so far specify the target address directly. It is also possible to specify the target of jump indirectly. We describe how the target can be specified indirectly and illustrate its use of such indirect jumps by means of an example.
Modern high-level languages provide a variety of decision structures. These structures include selection structures such as if-then-else and iterative structures such as while and for loops. Assembly language, being a low-level language, does not provide these structures directly. However, assembly language provides several basic instructions that could be used to construct these high-level language selection and iteration structures. These assembly language instructions include the unconditional jump, compare, conditional jump, and loop. We briefly introduced some of these instructions in Chapter 9. In this chapter, we give more details on these instructions.
As we have seen in the previous chapters, we can specify the target address directly. In assembly language programs, we do this by specifying a label associated with the target instruction. The assembler replaces the label with the address. In general, this address can be a relative address...