Sunday 25 December 2016

Jumps, Flags and Conditional Jumps


1. Flags

- Flags indicate whether some condition is present or not.


2. Jump

- Jump instructions are used to tell the computer the address to fetch its next instruction from.
- There are two types of jump instructions:
                      a. Conditional Jump Instruction
                      b. Unconditional Jump Instruction


a. Conditional Jump Instruction

- Conditional jump evaluates the state of specified flag to determine whether to fetch its next instruction from the jump destination location or to fetch its next instruction from the next sequential memory location.

Fig. 1. Flow chart showing the working of conditional jump

b. Unconditional Jump Instruction

- When the 8086 executes a jump(JMP) instruction, it loads a new number into the instruction pointer register and in some cases, it also loads a new number into the code segment register.

- If the jump destination is in the same code segment, the 8086 only has to change the contents of the instruction pointer. This type if a jump is referred to as a near or intrasegment jump.

 If the jump destination is in the different code segment, the 8086 has to change the contents of the instruction pointer and the code segment to make the jump. This type of jump is referred to as far jump or intersegment jump.

- Near and far jumps are further described as either
   i) Direct
      - If the destination address for the jump is specified directly as a part of the instruction, then the jump is described as direct. It is further classified as direct near jump and direct far jump.
  ii) Indirect
      - If the destination address for the jump is contained in a register or memory location, the jump is referred to as an indirect jump.

The direct near and Short type jump instructions

- A near-type jump instruction can cause the next instruction to be fetched from anywhere in the current code segment.

- A 16 bit signed displacement means that the jump can be to a location anywhere from +32,767 to -32,768 bytes from the current instruction pointer location.

- A positive displacement is an ahead jump. and a negative displacement is a backward jump.

- A special case of the direct near type jump instruction is the direct short type jump.

- If the destination for the jump is within a displacement range of +127 to -127 bytes from the current instruction pointer location, the destination can be reached with just an 8-bit displacement.

1 comment:

  1. Thank you for your articles that you have shared with us. Hopefully you can give the article a good benefit to us. LCD Separator machine

    ReplyDelete