Issues using a local label in a macro in MASM

2020-04-10 01:24发布

I'm to write a macro that takes E,NE,A,B... as a parameter and a single command i.e mov eax,ebx which would execute if the condition set by a preceding cmp operation is true.

An example call would look like.

cmp bx,20
mDoIf E,<call Dumpregs>

The issue I'm running into is that when I attempt to compile with the below definition I get one of two errors. With the LOCAL definition I get an Undefined Symbol Error: ??0000. When I remove the LOCAL definition I get an error: jump destination must specify a label.

mDoIf MACRO op, command
    LOCAL true
    J&op true
    exitm
    true: 
        command
        exitm

endm

Any help would be appreciated. Thank you.

1条回答
叛逆
2楼-- · 2020-04-10 01:25

Try this:

mDoIf MACRO op, command
    LOCAL L1, L2

    J&op    short L1
    jmp     short L2

L1: 
    call command
L2:
    exitm
endm

.code
start:
    mov     eax, 1
    cmp     eax, 2
    mDoIf l, DumpRegs

    invoke  ExitProcess, 0
end start
查看更多
登录 后发表回答