检查宏中是否存在参数

时间:2017-06-18 03:35:34

标签: assembly x86 emu8086

我想检查我的宏命令中是否有参数,如果没有参数,请不要执行我的宏代码。在FASM中,它看起来像:

 [1] "BOS_01_raw"  "BOS_02_raw"  "BOS_03_raw"  "BOS_04_raw"  "BOS_05_raw"  "BOS_06_raw"  "BOS_07_raw"  "BOS_08_raw"  "BOS_09_raw"  "BOS_10_raw" 
[11] "BOS_11_raw"  "BOS_12_raw"  "BOS_13_raw"  "BOS_14_raw"  "BOS_15_raw"  "BOS_01_time" "BOS_02_time" "BOS_03_time" "BOS_04_time" "BOS_05_time"
[21] "BOS_06_time" "BOS_07_time" "BOS_08_time" "BOS_09_time" "BOS_10_time" "BOS_11_time" "BOS_12_time" "BOS_13_time" "BOS_14_time" "BOS_15_time"

但是汇编此代码会返回错误:

  

(19)非法指令:if~arg eq或参数错误。

如何重写此宏以便在emu8086中运行?

1 个答案:

答案 0 :(得分:1)

我从未使用过Emu8086,但从我在网上可以看出,它有一个内置的汇编程序,它与MASM和TASM语法兼容。在这种情况下,您将使用IFB(如果符号为空)和IFNB(如果符号空白)条件指令。

因此,您的F宏将编写如下:

F MACRO arg1
IFNB <arg1>         ; if arg1 is not blank/empty
    mov ax, arg1
    add ax, ax
    add ax, 5
ENDIF
ENDM F
相关问题