| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The Pentium instruction set provides two types of jump instructions that are based on testing a single flag. One type is for jumps taken if the flag is set and the other for jumps taken if the flag is clear. There are two instructions for each of the flags: CF, OF, SF, ZF, PF. The only flag, from the arithmetic flags, that does not have such instructions is the Auxiliary Flag. These instructions are summarized in the table below.
There are many applications for these instructions. For example, to check if the result is positive or negative, one can use the JNS and JS instructions. To check if the result of an operation on a signed number is correct or not, one can use the instructions JO and JNO. To check if the result is zero or not, one can use the instructions JZ and JNZ. To check if the result of comparing two values is equal or not, one can also use the JZ/JE and JNZ/JNE instructions. To check if the result of an operation on an unsigned number is correct or not, once can use the instructions JC and JNC. Furthermore, to check if the last bit shifted or rotated is 1 or 0, one can use the instructions JC and JNC. The next example demonstrates the use of the JC instruction in counting the number of 0's in register AL and storing the count in register AH.
In the next example, we demonstrate the use of the JNC instruction in displaying the binary content of register BX.
The following example illustrates the use of the JNZ instruction. Notice that the loop is iterated until the content of BX becomes equal to zero and the zero flag (ZF) is set to one.
|