Assembly language is a common intermediate level programming language which is used for microprocessor programming. This macro and procedure are two concepts in assembly by which modular programming is implemented. So now lets understand how macro and procedure are different from each other.
1. Macro :
Macro is a set of instruction and the programmer can use it anywhere in the program by using its name. It is mainly used to achieve modular programming. So same set of instructions can be used multiple times where ever required by the help of macro.
Sysntax of macro :
%macro macro_name number_of_parameters <macro body> %endmacro
2. Procedure :
Procedures are also like macro but they are used for large set of instruction when macro is useful for small set of instructions. It contains a set of instructions which performs a specific task. It contains three main parts i.e Procedure name to identify the procedure, procedure body which contains set of instructions, and RET statement which denotes return statement.
Syntax of Procedure :
procedure_name : procedure body …....................... RET
To call a procedure
After execution of procedure control passes to the calling procedure using RET statement.
Difference between Macro and Procedure :
|01.||Macro definition contains a set of instruction to support modular programming.||Procedure contains a set of instructions which can be called repetitively which can perform a specific task.|
|02.||It is used for small set of instructions mostly less than ten instructions.||It is used for large set of instructions mostly more than ten instructions.|
|03.||In case of macro memory requirement is high.||In case of procedure memory requirement is less.|
|04.||CALL and RET instruction/statements are not required in macro.||CALL and RET instruction/statements are required in procedure.|
|05.||Assembler directive MACRO is used to define macro and assembler directive ENDM is used to indicate the body is over.||Assembler directive PROC is used to define procedure and assembler directive ENDP is used to indicate the body is over.|
|06.||Execution time of macro is less as it executes faster than procedure.||Execution time of procedures is high as it executes slower than macro.|
|07.||Here machine code is created multiple times as each time machine code is generated when macro is called.||Here machine code is created only once, it is generated only once when the procedure is defined.|
|08.||In a macro parameter is passed as part of statement that calls macro.||In a procedure parameters are passed in registers and memory locations of stack.|
|09.||Overhead time does not take place as there is no calling and returning.||Overhead time takes place during calling procedure and returning control to calling program.|
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
- Difference between Inline and Macro in C++
- Difference between Function and Procedure
- Difference between Trigger and Procedure in DBMS
- Macro Processor
- Difference between Stop and Wait protocol and Sliding Window protocol
- Similarities and Difference between Java and C++
- Difference between Yaacomo and and XAP
- Difference between VoIP and and POTS
- Difference and Similarities between PHP and C
- Difference between ++*p, *p++ and *++p
- Difference Between DOS and Windows
- Difference between User Level thread and Kernel Level thread
- What’s difference between The Internet and The Web ?
- Difference between Priority Inversion and Priority Inheritance
- What’s difference between Linux and Android ?
- What’s difference between header files "stdio.h" and "stdlib.h" ?
- Difference between HTML and HTTP
- Difference between http:// and https://
- What's difference between MMU and MPU?
- What's difference between Microcontroller (µC) and Microprocessor (µP)?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.