一、条件汇编伪指令和宏使用可以使汇编程序更加灵活
二、通过伪指令来检查函数的参数是否为空,如果为空则输出警告信息
INCLUDE Irvine32.inc includelib Irvine32.lib includelib kernel32.lib includelib user32.lib .data source BYTE "this is source string",0 .code mWriteStr MACRO string IFB <string> ECHO -------------------------------------- ECHO * ERROR parameter missing in mWriteStr ECHO * no code generated ECHO -------------------------------------- EXITM ENDIF push edx mov edx,offset string call WriteString pop edx endm main PROC ;mWriteStr source mWriteStr exit main ENDP END main
编译上面的程序时会输出警告信息:
C:RadASMMasm32BinML.EXE /c /coff /Cp /nologo /I"C:RadASMMasm32Include" "MacroTest.asm" Assembling: MacroTest.asm -------------------------------------- * ERROR parameter missing in mWriteStr * no code generated -------------------------------------- C:RadASMMasm32BinLINK.EXE /SUBSYSTEM:CONSOLE /RELEASE /VERSION:4.0 /LIBPATH:"C:RadASMMasm32Lib" /OUT:"MacroTest.exe" "MacroTest.obj" Microsoft (R) Incremental Linker Version 5.12.8078 Copyright (C) Microsoft Corp 1992-1998. All rights reserved. 构建完成. 总共编译时间 203 毫秒