1.

Branch Instructions

Answer»

Branch Instructions : 

Branch Instructions transfers the flow of execution of the program to a new address specified in the instruction directly or indirectly. When this type of instruction is executed, the CS and IP registers get loaded with new values of CS and IP corresponding to the location to be transferred. 

The Branch Instructions are classified into two types 

i. Unconditional Branch Instructions. 

ii. Conditional Branch Instructions. 

Unconditional Branch Instructions : 

In Unconditional control transfer instructions, the execution control is transferred to the specified location independent of any status or condition. The CS and IP are unconditionally modified to the new CS and IP. 

CALL : Unconditional Call 

This instruction is used to call a Subroutine (Procedure) from a main program. Address of procedure may be specified directly or indirectly. There are two types of procedure depending upon whether it is available in the same segment or in another segment. 

i. Near CALL i.e., ±32K displacement. 

ii. For CALL i.e., anywhere outside the segment. 

On execution this instruction stores the incremented IP & CS onto the stack and loads the CS & IP registers with segment and offset addresses of the procedure to be called. 

RET: Return from the Procedure. 

At the end of the procedure, the RET instruction must be executed. When it is executed, the previously stored content of IP and CS along with Flags are retrieved into the CS, IP and Flag registers from the stack and execution of the main program continues further. 

INT N: Interrupt Type N. 

In the interrupt structure of 8086, 256 interrupts are defined corresponding to the types from 00H to FFH. When INT N instruction is executed, the type byte N is multiplied by 4 and the contents of IP and CS of the interrupt service routine will be taken from memory block in 0000 segment.

13

INTO: Interrupt on Overflow 

This instruction is executed, when the overflow flag OF is set. This is equivalent to a Type 4 Interrupt instruction. 

JMP: Unconditional Jump 

This instruction unconditionally transfers the control of execution to the specified address using an 8-bit or 16-bit displacement. No Flags are affected by this instruction. 

IRET: Return from ISR 

When it is executed, the values of IP, CS and Flags are retrieved from the stack to continue the execution of the main program. 

LOOP : LOOP Unconditionally 

This instruction executes the part of the program from the Label or address specified in the instruction upto the LOOP instruction CX number of times. At each iteration, CX is decremented automatically and JUMP IF NOT ZERO structure. 

Example: MOV CX, 0004H

MOV BX, 7526H

Label 1 MOV AX, CODE

OR BX, AX 

LOOP Label 1

Conditional Branch Instructions 

When this instruction is executed, execution control is transferred to the address specified relatively in the instruction, provided the condition implicit in the Opcode is satisfied. Otherwise execution continues sequentially. 

JZ/JE Label 

Transfer execution control to address ‘Label’, if ZF=1. 

JNZ/JNE Label 

Transfer execution control to address ‘Label’, if ZF=0 

JS Label 

Transfer execution control to address ‘Label’, if SF=1.

JNS Label 

Transfer execution control to address ‘Label’, if SF=0.

JO Label 

Transfer execution control to address ‘Label’, if OF=1.

14

JNO Label 

Transfer execution control to address ‘Label’, if OF=0. 

JNP Label 

Transfer execution control to address ‘Label’, if PF=0. JP Label Transfer execution control to address ‘Label’, if PF=1. 

JB Label 

Transfer execution control to address ‘Label’, if CF=1. 

JNB Label 

Transfer execution control to address ‘Label’, if CF=0. JCXZ Label Transfer execution control to address ‘Label’, if CX=0 

Conditional LOOP Instructions. 

LOOPZ / LOOPE 

Label Loop through a sequence of instructions from label while ZF=1 and CX=0. LOOPNZ / LOOPENE Label Loop through a sequence of instructions from label while ZF=1 and CX=0.



Discussion

No Comment Found

Related InterviewSolutions