Recursive and Re-entrant Procedures in 8086 Microprocessor

In this tutorial, we will learn about the two special types of procedures whose functioning is a bit different from the normal procedures. These are the Recursive procedures and Re-entrant procedures, also discuss the control mechanism of the processor while executing these types of procedures. By Monika Sharma Last updated : May 16, 2023

As we all know that a procedure is a set of instruction written separately which can be used any time in the code when required. A normal procedure execution includes calling of the procedure, shifting the control of the processor to the procedure, and then returning the control to the calling program. This can be well understood as follows:

Recursive and Re-entrant Procedures in 8086 Microprocessor (1)

Apart from this, we have two special types of procedures: Recursive Procedures and Re-entrant procedures...

1) Recursive procedures

A recursive procedure is a procedure which calls itself. This results in the procedure call to be generated from within the procedures again and again. This can be understood as follows:

Recursive and Re-entrant Procedures in 8086 Microprocessor (2)

Image reference: https://images.app.goo.gl/kyJgWtWnF5faQfTe7

The recursive procedures keep on executing until the termination condition is reached. The recursive procedures are very effective to use and to implement but they take a large amount of stack space and the linking of the procedure within the procedure takes more time as well as puts extra load on the processor.

2) Re-entrant procedures

The re-entrant procedure is a very special kind of procedure. In such kind of procedure, procedure 1 is called the mainline program, then procedure 2 is called form procedure 1 and then again procedure 1 is called form procedure 2. This can be well understood from the following diagram:

Recursive and Re-entrant Procedures in 8086 Microprocessor (3)

Image reference: https://images.app.goo.gl/HKw5j6K6HQk79ki29

This is called a re-entrant procedure because a procedure is re-entering into itself form another procedure which is also present inside its own body. The re-entrant procedure occurs in the following three conditions: when the procedure is undergoing recursion, when multi-threading is being implemented inside a program or when some interruption is being generated. Like the recursive procedures, it is important to have a termination condition for the procedures in the re-entrant procedures also, else we can face machine halts due to infinite procedure calls.





Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.