In 8086, which instruction at the end of a sub-routine takes the
![In 8086, which instruction at the end of a sub-routine takes the](http://storage.googleapis.com/tb-img/production/19/08/26%20June_1.png)
| In 8086, which instruction at the end of a sub-routine takes the execution back to the main program?
A. JMP
B. END
C. CALL
D. RET
Please scroll down to see the correct answer and solution guide.
Right Answer is: D
SOLUTION
- When we call any subroutine during the execution of the main program then the address of next instruction is stored in a stack
- After we complete the execution of the subroutine, then the program will have to return to the original program.
- So, it pops the address that is stored in a stack during the execution of the call and assigned to the program counter PC.
-
The RET (Return) instruction is also equivalent to POP instruction. Hence it will take 3 machine Cycles (Opcode fetch, Read operation, Read operation)
Opcode |
Operand |
Explanation |
Example |
CALL |
Address |
Calls a subroutine and saves the return address on the stack. |
CALL 2050 |
RET |
None |
Returns from the subroutine to the main program |
RET |
JUMP |
Address |
Transfer the control of execution to the specified address |
JUMP 2050 |
LOOP |
Address |
Loops through a sequence of instruction until Cx = 0 |
LOOP 2050 |
END |
none |
Marks the termination point of the program |
END |