8086 Assembler Tutorial For Beginners (Part 10)
8086 Assembler Tutorial For Beginners (Part 10)
8086 Assembler Tutorial For Beginners (Part 10)
Macros
Macros are just like procedures, but not really. Macros look like
procedures, but they exist only until your code is compiled, after
compilation all macros are replaced with real instructions. If you
declared a macro and never used it in your code, compiler will simply
ignore it. emu8086.inc is a good example of how macros can be
used, this file contains several macros to make coding easier for
you.
Macro definition:
<instructions>
ENDM
MOV AX, p1
MOV BX, p2
MOV CX, p3
ENDM
ORG 100h
MyMacro 1, 2, 3
MyMacro 4, 5, DX
RET
CALL MyProc
When you want to use a macro, you can just type its name.
For example:
MyMacro
MyMacro 1, 2, 3
To mark the end of the procedure, you should type the name
of the procedure before the ENDP directive.
http://courses.ee.sun.ac.za/OLD/2003/Rekenaarstelsels245/8086_Instruksies/asm_tutorial_10.html 2/3
10/2/2017 8086 Assembler Tutorial for Beginners (Part 10)
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
http://courses.ee.sun.ac.za/OLD/2003/Rekenaarstelsels245/8086_Instruksies/asm_tutorial_10.html 3/3