Author Topic: check before the definition  (Read 1564 times)

mabdelouahab

• Member
• Posts: 361
check before the definition
« on: November 13, 2014, 06:39:23 PM »
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

Code: [Select]
`   forced error : symbol not defined : ....` http://msdn.microsoft.com/en-us/library/08cssy16.aspx
Code: [Select]
`    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.codestart: _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

ToutEnMasm

• Member
• Posts: 1189
Re: check before the definition
« Reply #1 on: November 13, 2014, 07:15:37 PM »

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

• Member
• Posts: 1472
• The base type of a type is the type itself
Re: check before the definition
« Reply #2 on: November 14, 2014, 12:57:29 AM »
If you just want to check wether a procedure is declared, do it as:
Code: [Select]
`_Invoke_2 MACRO _Proc:REQ,_Arg:VARARG  ifdef _Proc&@_ __Push_ _Arg push 0 call _Proc&@_ else .err <function not declared> endifENDM`
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!