Home » Embedded Systems

The CALL and RET instruction in the 8086 Microprocessor

In this article, we are going to study the instructions used for call and return purpose inside the procedures in the 8086 microprocessor. These instructions are CALL and RET. We are going to study 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?
Submitted by Monika Sharma, on July 30, 2019

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.

RET instruction

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.






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.
Learn PCB Designing: PCB DESIGNING TUTORIAL




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.