News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Making a macro public

Started by kiptron, November 21, 2020, 09:08:46 AM

Previous topic - Next topic

kiptron

Hey folks,  just a quick question. How do I make a macro public in my
Include file ?? It is not a proc or a variable so EXTERNDEF doesn't seem
to work.  Thanks and Happy Thanksgiving  !!  Kiptron

hutch--

PUBLIC is done in binary where a macro is run before assembly. I think what you need is the IFNDEF notation that if the macro is not defined, it gets defined conditionally.

HSE

Kiptron:

You can write the macros in a file, and include the same file in every module.
Equations in Assembly: SmplMath

kiptron

That makes sense,  I will try that. Thank you HSE  I should have thought of that. I am
fairly experienced at this. I wrote two nifty little macros to adjust and restore the stack
and creating the 32 byte "shadow space" before and after making an un-prototyped
API call. That is the issue that has given me huge problems with running many of the
"extension" calls of Opengl. Thanks again    Kiptron

Vortex

Hi kiptron,

QuoteI wrote two nifty little macros to adjust and restore the stack
and creating the 32 byte "shadow space" before and after making an un-prototyped
API call.

If you are using Masm64, you don't need full prototypes. Does your macro declare the API functions with the statement EXTERNDEF?

kiptron

  So far I am just trying to share a macro(make it visible across .asm files) just like you would
do with any proc or variable,   like   externdef whatever_variable: dword  or externdef whatever_proc:near
but that won't work with macros. A macro has no type.  I can't say externdef whatever_macro: ?????  What's the type ??
It has no type. HSE recommended putting macros in an include file but if you think about it that won't
work either.  Scratching my head. Happy Thankgiving   Kiptron

Vortex

Hi kiptron,

Here is a quick example for you :

@sum MACRO x,y

    mov     eax,x
    add     eax,y
    EXITM   <eax>

ENDM


The @sum macro is called twice by the Main and TestFunc modules. This macro's definion can be found in the include file named MyMacro.inc
You can examine the modules in the attachment.

kiptron

Thank you Vortex, Yes I see, you just put the text of the macro in
the .inc file. I made a total error. My macro used an undefined variable.
                                   OOPS  Kiptron