| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
In direct jump, the target address (i.e. its relative offset value) is encoded into the jump instruction itself. However, in an indirect jump, the target address is specified indirectly either through memory or a general-purpose register. For example, if the CX register contains the offset of the target address, then we can write JMP CX It should be observed that in indirect jumps, the target offset is the absolute value (unlike direct jumps, which use a relative offset value). The following example illustrates the use of indirect jump.
The above example shows a simple program that reads a digit from the user and prints the corresponding choice represented by the input. In order to use the indirect jump, a jump table of pointers is built. The input digit is converted to act as an index into this table and is used in the indirect jump instruction.
|