http://www.emu8086.com/assembler_tutorial/asm_tutorial_10.html
1. like proc but not really.
exist only until the code is compiled.
after compilation, all macros are replaced with real instructions.
2.definition:
name MACRO [parameters,...]
<instructions>
ENDM
Unlike proc, macros should be defined above the code that uses it.
3. Some important facts
- use- "CALL MyProc" vs "MyMacro" (no CALL in using macro)
- procedure is located at some specific address in memory. When using it 100 times, the size grows very insignificantly. Macro is opposite because macro is expanded directly in program's code.
- Different in the method of passing parameters
- ENDM vs ENDP
4. Use LOCAL followed by names of variables, labels or procedure names in Macro
example:
MyMacro2 MACRO
LOCAL label1, label2
CMP AX, 2
JE label1
CMP AX, 3
JE label2
label1:
INC AX
label2:
ADD AX, 2
ENDM
ORG 100h
MyMacro2
MyMacro2
RET
5. If using macros in several programs, put them in a INC file.