•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Assembly section within the Software Development category of DaniWeb, a massive community of 422,414 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 5,060 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Assembly advertiser: Programming Forums
Views: 454 | Replies: 1
![]() |
•
•
Join Date: Jun 2008
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
Hi, I have doubt on my answer in regards to the example for the coding part. I know my definition part should be okay, but I have doubt on my example part to show the difference between the Macro and the procedure. Can you please take a look at my answer and let me know if my answer is the best answer for this question? Thanks
1.Briefly explain the differnce between a marco and a procedure and
give an example.
Answer:
-------
A macro is a group of repetitive instructions in a program which are codified only once and can be used as many times
as necessary.
The main difference between a macro and a procedure is that in the macro the passage of parameters is possible and in the
procedure it is not, this is only applicable for the MASM - there are other programming languages which do allow it.
At the moment the macro is executed each parameter is substituted by the name or value specified at the time of the call.
We can say then that a procedure is an extension of a determined program, while the macro is a module with specific
functions which can be used by different programs.
Another difference between a macro and a procedure is the way of calling each one, to call a procedure the use of a
directive is required, on the other hand the call of macros is done as if it were an assembler instruction.
Example of procedure:
For example, if we want a routine which adds two bytes stored in AH and AL each one, and keep the addition in the BX register:
Adding Proc Near ; Declaration of the procedure
Mov Bx, 0 ; Content of the procedure
Mov B1, Ah
Mov Ah, 00
Add Bx, Ax
Ret ; Return directive
Add Endp ; End of procedure declaration
and an example of Macro:
Position MACRO Row, Column
PUSH AX
PUSH BX
PUSH DX
MOV AH, 02H
MOV DH, Row
MOV DL, Column
MOV BH, 0
INT 10H
POP DX
POP BX
POP AX
ENDM

1.Briefly explain the differnce between a marco and a procedure and
give an example.
Answer:
-------
A macro is a group of repetitive instructions in a program which are codified only once and can be used as many times
as necessary.
The main difference between a macro and a procedure is that in the macro the passage of parameters is possible and in the
procedure it is not, this is only applicable for the MASM - there are other programming languages which do allow it.
At the moment the macro is executed each parameter is substituted by the name or value specified at the time of the call.
We can say then that a procedure is an extension of a determined program, while the macro is a module with specific
functions which can be used by different programs.
Another difference between a macro and a procedure is the way of calling each one, to call a procedure the use of a
directive is required, on the other hand the call of macros is done as if it were an assembler instruction.
Example of procedure:
For example, if we want a routine which adds two bytes stored in AH and AL each one, and keep the addition in the BX register:
Adding Proc Near ; Declaration of the procedure
Mov Bx, 0 ; Content of the procedure
Mov B1, Ah
Mov Ah, 00
Add Bx, Ax
Ret ; Return directive
Add Endp ; End of procedure declaration
and an example of Macro:
Position MACRO Row, Column
PUSH AX
PUSH BX
PUSH DX
MOV AH, 02H
MOV DH, Row
MOV DL, Column
MOV BH, 0
INT 10H
POP DX
POP BX
POP AX
ENDM
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,114
Reputation:
Rep Power: 38
Solved Threads: 928
•
•
•
•
The main difference between a macro and a procedure is that in the macro the passage of parameters is possible and in the
procedure it is not
That isn't true of any major computer language that I know of. Procedures in every language can accept parameters. In assembly language you can store the parameters in registers, push them one the stack or some combination of the two before calling the procedure.
I think it's about time we voted for senators with breasts. After all, we've been voting for boobs long enough. ~Clarie Sargent, Arizona senatorial candidate
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
Those who are too smart to engage in politics are punished by being governed by those who are dumber. ~Plato
![]() |
•
•
•
•
•
•
•
•
DaniWeb Assembly Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Other Threads in the Assembly Forum
- Previous Thread: Ascii operations in assembly language
- Next Thread: What is the assembly language?



Linear Mode