CH 5 Procedures and Macros
CH 5 Procedures and Macros
Topics Covered:
1. Introduction
2. Procedure
3. Macros
• Example:
It is used for large set of instructions mostly more than ten It is used for small set of instructions mostly less than ten
instructions. instructions.
In case of procedure memory requirement is less. In case of macro memory requirement is high.
CALL and RET instruction/statements are required in procedure. CALL and RET instruction/statements are not required
in macro.
Assembler directive PROC is used to define procedure and Assembler directive MACRO is used to define macro
assembler directive ENDP is used to indicate the body is over. and assembler directive ENDM to indicate body is over.
Execution time of procedures is high as it executes slower than Execution time of macro is less as it executes faster than
macro. procedure.
Here machine code is created only once, it is generated only once Here machine code is created multiple times as each
when the procedure is defined. time machine code is generated when macro is called.
Overhead time takes place during calling procedure and returning Overhead time does not take place as there is no calling
control to calling program. and returning.
Difference between Far and Near
Far Near
Within Different CS Within Same CS
Replace old pair CS:IP with new pair Replace old IP with new IP