News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

check before the definition

Started by mabdelouahab, November 13, 2014, 06:39:23 PM

Previous topic - Next topic

mabdelouahab

I want to make two MACRO, where I can verify that a used one of them
I used in the example: IFDEF; OPATTR  but it does not give me the result
I used .ERRNDEF but they do not show my message, and show


   forced error : symbol not defined : ....

http://msdn.microsoft.com/en-us/library/08cssy16.aspx

    include \masm32\include\masm32rt.inc

_Invoke_ MACRO _Proc:REQ,_Arg:VARARG
__Push_ _Arg
push 0
% call &_Proc&@_
ENDM

_Invoke_2 MACRO _Proc:REQ,_Arg:VARARG
% ifdef &_Proc&@_
__Push_ _Arg
push 0
% call &_Proc&@_
endif
ENDM

_Invoke_3 MACRO _Proc:REQ,_Arg:VARARG
% ifdef OPATTR(&_Proc&@_)
__Push_ _Arg
push 0
% call &_Proc&@_
endif
ENDM


_Invoke_4 MACRO _Proc:REQ,_Arg:VARARG
% .errndef &_Proc&@_, Indefined &_Proc&
__Push_ _Arg
push 0
% call &_Proc&@_
ENDM


_Proce_ MACRO _Proc:REQ,_Arg:VARARG
.code
% &_Proc&@_ PROC USES esi edi __Param_ :DWORD ,&_Arg&
;...........
ret
% &_Proc&@_ Endp

ENDM


__Push_ macro __arg :vararg
nArg = 0
??__Args CatStr <>         
% for Str_ , <&__arg>
??_Arg SUBSTR <&Str_>,1
if nArg ne 0
??__Args CatStr ??_Arg,<!, >,  ??__Args         
else
??__Args CatStr ??_Arg
nArg = 1   
endif
  endm
  % for Str_ , <&??__Args>
??_Arg SUBSTR <&Str_>,1
% push &Str_&
  endm
endm

.code
start:

_Invoke_ MyProc1,10,10

_Invoke_2 MyProc1,10,10

_Invoke_3 MyProc1,10,10

_Invoke_4 MyProc1,10,10

inkey

_Proce_ MyProc,a:dword,B:dword

end start



Note : I want to check it  before the definition of proc,not after

   r_ = opattr ( MyProc@_)
   % echo   @CatStr(%r_)      ;   ----->  =  0
   
   _Proce_   MyProc,a:dword,B:dword
   
   r_ = opattr ( MyProc@_)
   % echo   @CatStr(%r_)      ;   ----->  =  805

If there was any other way , I wanted to know , with a thousand thanks

TouEnMasm


Quote
%    ifdef   OPATTR(&_Proc&@_)
The IFDEF statement must be followed immediately by a constant.
Use of OPATTR here solve to "forced error : symbol not defined : ...."
pseudo soluce:
Quote
namedmacro MACRO
       Local etiquette,value
       etiquette equ _Proc&@_ ;modify it
      IFDEF etiquette
          ; you can use  the OPATTR function here
      ENDIF
ENDM
Fa is a musical note to play with CL

qWord

If you just want to check wether a procedure is declared, do it as:
_Invoke_2 MACRO _Proc:REQ,_Arg:VARARG
ifdef _Proc&@_
__Push_ _Arg
push 0
call _Proc&@_
else
.err <function not declared>
endif
ENDM


Quote from: ToutEnMasm on November 13, 2014, 07:15:37 PM
The IFDEF statement must be followed immediately by a constant.
actual an identifier is expected.
MREAL macros - when you need floating point arithmetic while assembling!