Author Topic: more conditions in %ifdef, %ifidni ...  (Read 17620 times)

Zdenek Sojka

  • Guest
more conditions in %ifdef, %ifidni ...
« on: August 28, 2007, 10:11:02 AM »
Hello,

I would like to use conditional assembly under some more complex circumstances, eg.

if parameter %1 is eax or ebx
if macro1 or macro2 is defined
etc...

%ifidn %1,eax || %1,ebx
%ifdef macro1 || macro2
doesn't work, but it doesn't give any warning, too

How can I do that?
thank you

nobody

  • Guest
Re: more conditions in %ifdef, %ifidni ...
« Reply #1 on: August 28, 2007, 11:42:58 PM »
I'm not a very sophisticated macro user. I don't *think* Nasm will accept boolean expressions within an "%if???". I think you'll have to do it one at a time...

%ifidni %1, eax
; do your thing
%endif

%ifidni %1, ebx
; do your thing
%endif

Et painful cetera...

Best,
Frank

Zdenek Sojka

  • Guest
Re: more conditions in %ifdef, %ifidni ...
« Reply #2 on: September 01, 2007, 01:34:13 PM »
Thank you for reply - I didn't receive any notification email, so I am reading your post now...

Too bad NASM works this way...
at least, I was able to use following construction:

%macro is32bitreg 1
 %ifdef res
  %undef res
 %endif
 %ifidni %1, eax
  %define res
 %elifidni %1, ebx
  %define res
 %elifidni %1, ecx
  %define res
 %elifidni %1, ecx
  %define res
 %elifidni %1, edx
  %define res
 %elifidni %1, esi
  %define res
 %elifidni %1, edi
  %define res
 %elifidni %1, ebp
  %define res
 %elifidni %1, esp
  %define res
 %endif
%endmacro

%macro imovzx 2
 is32bitreg %1
 %ifdef res
  movzx %1,%2
 %else
  mov %1,%2
 %endif
%endmacro