Procedures in the 8086 microprocessor

In this article, we are going to study about the procedures in the 8086 microprocessors. We will first define what the procedures mean, how they are useful, and how they are implemented in the assembly language program for the 8086 microprocessor?
Submitted by Monika Sharma, on July 30, 2019

In a program, we very frequently face situations where there is a need to perform the same set of task again and again. So, for that instead of writing the same sequence of instructions, again and again, they are written separately in a subprogram. This subprogram is called a procedure. With the help of procedures, we can very well implement the concept of modular programming in our code. Also, whenever we need to execute the instructions mentioned in the procedure, we can simply make a CALL to it. Therefore, with the help of procedures, the duplicity in the instructions can be avoided.

The Syntax for a procedure is as follows:

    Procedure_name PROC  [near / far]
        Instruction 1
        Instruction 2
        - - - - - - - - - - -
        - - - - - - - - - - -
        Instruction n
    Procedure_name ENDP

Here, the PROC is a keyword to define that the set of instructions enclosed by the given name is a procedure. It is used in the starting instruction whenever we define a procedure. The ENDP keyword defines that the body of the procedure has been ended. All the instructions lying between these two keywords are the instructions that belong to the procedure and will be executed whenever a CALL to the procedure is made. The keyword near or far defines the range of code within which the procedure is defined. If it is defined in the same segment as the rest code, then near is used. If it is defined in some other segment, then the keyword far is used for it.

The CALL to a procedure can be made in the following way,

    CALL procedure_name

At the end of the procedure, the RET instruction is used. This instruction will cause the execution to be transferred to the program from which the call to the procedure was made.

Related Tutorials


Comments and Discussions!

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

© some rights reserved.