MAX MACRO K,A,B,C
LOCAL NEXT,OUT
MOV AX,A
IF K-1
IF K-2
CMP C,AX
JLE NEXT
MOV AX,C
ENDIF
NEXT: CMP B,AX
JLE OUT
MOV AX,B
ENDIF
OUT:
ENDM
宏调用:
MAX 1,P
MAX 2,P,Q
MAX 3,P,Q,R
宏展开:
MAX 1,P
+ MOV AX,P
+??0001:
MAX 2,P,Q
+ MOV AX,P
+??0002:CMP Q,AX
+ JLE ??0003
+ MOV AX,Q
+??0003:
MAX 3,P,Q,R
+ MOV AX,P
+ CMP R,AX
+ JLE ??0004
+ MOV AX,R
+??0004:CMP Q,AX
+ JLE ??0005
+ MOV AX,Q
+??0005:
例2.宏指令GOTO L,X,REL,Y(其中REL可以是Z,NZ,L,NL等)可以根据不同情况产生无条件转移指令或比较和条件转移指令.
宏定义:
GOTO MACRO L,X,REL,Y
JFB <REL>
JMP L