written 2.6 years ago by |
Procedure :
The repeated group of instructions in a large program can be written separately from the main program.
This subprogram is called as Procedure in an assembly language programming, i.e. Procedure is a set of statements that can be processed independently from the main program.
Syntax:
PROC PROCEDURENAME
PROCEDURENAME ENDP
Example:
PROC Addition
.. Addition logic..
Addition ENDP
Advantages of Procedure:
Simplify and reduce the amount of repetitive coding.
Reduces errors caused by repetitive coding.
Makes program more readable.
Execution time is less as compare to procedure as no extra instructions are required.
Reentrant Procedure:
The procedure which can be interrupted, used and "reentered" without losing or writing over anything is called re-entrant procedure.
In some situation it may happen that procedurel is called from main program procedure2 is called from procedure is again called from procedure2. In this situation program execution flow reenters in theprocedure1. These types of procedures are called reentrant procedures.
Recursive procedure
A recursive procedure is a procedure which calls itself. Recursive procedures are used to work withcomplex data structure called trees. If the procedure is called with N (recursion depth) = 3. Then the n is decremented by one after cach procedure is called until n=0.