The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Igor on April 03, 2009, 03:36:59 PM

Title: Bug in macro code "if var eq 0"?
Post by: Igor on April 03, 2009, 03:36:59 PM
Am i doing something wrong here:

macro:
test_macro macro vr1
if vr1 eq 0
xor ecx, ecx
else
mov rcx, vr1
endif
endm


this code:
test_macro FALSE ; 0
test_macro TRUE ; 1
test_macro WS_EX_CLIENTEDGE ; 200h
test_macro WS_EX_CONTROLPARENT ; 10000h
test_macro WS_EX_CLIENTEDGE or WS_EX_CONTROLPARENT ; 10200h

is assembled like this:
xor         ecx,ecx
mov         rcx,1
mov         rcx,200h
mov         rcx,10000h
xor         ecx,ecx ; WTF???


He thinks it is equal to zero every time i put "or", how to resolve this?
Title: Re: Bug in macro code "if var eq 0"?
Post by: qWord on April 03, 2009, 03:50:13 PM
hi,

this is not a bug. masm replace vr1 by "WS_EX_CLIENTEDGE or WS_EX_CONTROLPARENT" and this is treated as: "if WS_EX_CLIENTEDGE  OR  ( WS_EX_CONTROLPARENT eq 0)".

change "if vr1 eq 0" to  "if (vr1) eq 0"

regards, qWord
Title: Re: Bug in macro code "if var eq 0"?
Post by: Igor on April 03, 2009, 07:09:47 PM
Ahhh, didn't know that, thank you. It works now.