NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: ilikenasm on February 05, 2009, 09:35:46 AM
-
Hi Frank,
I wrote a macro:
%macro testmacro 1
if %1, ==, NULL
invoke MessageBoxA, dword NULL, "null", 'ok', dword MB_OK
endif
%endmacro
But got a error: invalid combination of opcode and operands
If I chage it to:
%macro testmacro 1
mov eax, %1
if eax, ==, NULL
invoke MessageBoxA, dword NULL, "null", 'ok', dword MB_OK
endif
%endmacro
It work, why the parameter can not be compared directly?
Regards,
Freeman
-
Not enough information. What's "NULL"? (as opposed to ' "null" '?) I suppose "if" (as opposed to "%if") and "endif" (as opposed to "%endif") are defined somewhere? If I replace "if %1, ==, NULL" with "%ifidn %1, NULL" it seems to work. Too subtle for me, I'm afraid!
Best,
Frank
-
It looks like he's using NASMX, if that's the case then I don't see why the above code wouldn't work unless you passed an immediate value to testmacro. NASMX's if macro uses cmp internally which the arguments to if are subject to that opcodes operands. When you added the mov eax, %1 to your code you subvert your arguments dependency on a specific type of operand by forcing the first operand to cmp to be EAX.
-
Yes, I'm using nasmx.
Thanks, I will use %ifidn instead.
Regards,
Freeman