flat assembler
Message board for the users of flat assembler.

Index > Windows > Looking for an "IFDEF" equivalent

Author
Thread Post new topic Reply to topic
ChrisLeslie



Joined: 04 Jun 2006
Posts: 50
Location: Australia
ChrisLeslie
I need a directive that will allow assembly if a macro exists. I have tried "if defined", "if ~ defined", "if used" etc but I cant get anything to work.

For example I do this:

.if [uMsg] = WM_TIMER
if used mytimer
mytimer
end if
.endif

then I want it to skip the assembly if "mytimer" macro does not exist.
I can't understand the FASM manual very well on this topic!!

Regards

Chris
Post 20 Aug 2006, 06:51
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
well, you should read principes of FASM, to understand what is preprocessing. Macro is expanded at preprocessing stage before, "if"s are handled (in assemby stage). Also operator "used" is for checking value of numeric constants, not macros.
Post 20 Aug 2006, 09:03
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Dmitry



Joined: 06 Aug 2006
Posts: 3
Location: ru
Dmitry
So, you should use 'match' directive

For example:
Code:
macro mytimer
{
;;handler code
}

mytimer_present equ 1

;;

.if [uMsg] = WM_TIMER
;
match =1,mytimer_present { mytimer }
;
.endif 


    
Post 20 Aug 2006, 12:42
View user's profile Send private message Reply with quote
ChrisLeslie



Joined: 04 Jun 2006
Posts: 50
Location: Australia
ChrisLeslie
Dmitry

Ah!, the match directive. I can't wait to try that when I get home. Thanks for the advice.

Regards

Chris
Post 20 Aug 2006, 21:59
View user's profile Send private message Reply with quote
ChrisLeslie



Joined: 04 Jun 2006
Posts: 50
Location: Australia
ChrisLeslie
No, I could get the match directive as above to work. I don't understand the code Dmitry however because if "mytimer_present" equate to 1 then the match will only be true, even if mytimer does not exist. How can the presence or not of the macro name be interpreted by the match? Or am I misunderstanding something...

Chris
Post 22 Aug 2006, 03:08
View user's profile Send private message Reply with quote
Dmitry



Joined: 06 Aug 2006
Posts: 3
Location: ru
Dmitry
You should manually change this value.
mytimer_present equ 1 if mytimer macro present, otherwise 0

The improved version:
Code:
macro __macro name*, [params]
{
        common 
        name#_present equ 1
        macro name params \{
}

MACRO fix __macro
ENDM fix }

macro IFMDEF name*
{       
        match =1, name#_present \{ name \}
}


;;macros

MACRO mymacro
        xor eax,eax
ENDM


;;code
.if [uMsg] = WM_TIMER
;
IFMDEF mymacro
;
.endif  
    
Post 22 Aug 2006, 07:54
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.