CH 5
CH 5
(NBA accredited)
Microprocessors
(Course Code: 22415)
Course Teacher: Anjali Gharat
Procedure and Macro:
Procedure:
A large program is difficult to implement even if an algoritham is available,
Hence it should be split into number of independent tasks which can be easily
Designed and implemented
The process of splitting a large program into small tasks and designing
them independently is known as modular programming
2
Advantages
Reusability of code:
The procedures provide us an ease in our code by making the set
of instructions reusable. So, we need not write the same set of
instructions again and again when required.
4
Disadvantages of using procedures
6
Types of procedure
7
Directives used for procedure :
General form :
procedure name PROC [Near/far]
Example:
ADD ENDP
Directives used for procedure :
ENDP Directive: This directive is used along with the name of the
procedure to indicate the end
9
Explain NEAR CALL and FAR CALL procedure
10
Describe recursive procedure &reentrant
procedure with the help of schematic diagram
11
Recursive procedure
13
Re-entrant procedure
14
Passing Parameter to procedure and from
procedure :
1) In register
2) In dedicated memory locations accessed by name
3) With pointer passed in register.
4) With the stack
15
1) Passing parameters in registers :
The main program can pass upto 6 parameters to the procedure through
the registers AX,BX,CX,DX,SI & DI before executing the call instruction.
e.g. consider the program to calculate a square of given number.
16
2)Passing parameters in dedicated
memory locations accessed by name :
17
3) Passing parameters with Pointer
18
4) Passing parameters with stack
19
20
Macro
General Form :
MACRO-name MACRO [ARGUMENT
1,……….ARGUMENT N]
-----
MACRO CODIN GOES HERE
ENDM
21
Macro
22
Advantages and disadvantages of MACRO :
Advantages:
23
Disadvantages :
24
Comparison Of Macro and Procedure
Procedures are used for large Procedures are used for small group of
5
group of instructions to be instructions to be repeated
repeated
Directives PROC & ENDP are used Directives MACRO and ENDM are used
7
for defining procedure. for defining MACRO
More time is required for it’s Less time is required for it’s execution
8
execution
26
Thank You
27