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