Embedded Systems Tutorial

AVR Microcontroller

8051 Microcontroller

8085 Microprocessor

8086 Microprocessor

8255 Microprocessor

Embedded Systems Practice

Procedures in the 8086 Microprocessor

In this tutorial, we will learn 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? By Monika Sharma Last updated : May 16, 2023

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.

Comments and Discussions!

Load comments ↻

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