Home »
Embedded Systems
The CALL and RET Instruction in the 8086 Microprocessor
In this tutorial, we will learn about the instructions used for call and return purpose inside the procedures in the 8086 Microprocessor. These instructions are CALL and RET. We will learn about their working and how they are used in a procedure. Also, we will learn how the control of the instruction execution is affected by these instructions?
By Monika Sharma Last updated : May 16, 2023
The CALL instruction in the 8086 microprocessor
The CALL instruction is used whenever we need to make a call to some procedure or a subprogram. Whenever a CALL is made, the following process takes place inside the microprocessor:
- The address of the next instruction that exists in the caller program (after the program CALL instruction) is stored in the stack.
- The instruction queue is emptied for accommodating the instructions of the procedure.
- Then, the contents of the instruction pointer (IP) is changed with the address of the first instruction of the procedure.
- The subsequent instructions of the procedure are stored in the instruction queue for execution.
The Syntax for the CALL instruction is as follows:
CALL subprogram_name
The RET instruction in the 8086 microprocessor
The RET instruction stands for return. This instruction is used at the end of the procedures or the subprograms. This instruction transfers the execution to the caller program. Whenever the RET instruction is called, the following process takes place inside the microprocessor:
- The address of the next instruction in the mainline program which was previously stored inside the stack is now again fetched and is placed inside the instruction pointer (IP).
- The instruction queue will now again be filled with the subsequent instructions of the mainline program.
The Syntax for the RET instruction is as follows:
RET
The following diagram illustrates how the control of the instruction execution is transferred within the code from one program to another whenever a procedure is called and whenever it returns the execution. In most of the cases, the procedure CALL is made from the mainline program and hence the control is returned to the mainline program itself.
Note: The storing and fetching of the address inside and from the stack takes place in the same way as the data is pushed into it or popped form it.