News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

How to "include" Macros?

Started by peaslee, November 12, 2010, 08:02:49 PM

Previous topic - Next topic

peaslee

I'm working my way through some tutorials. One describes a macro RGB for creating color values. It doesn't appear I can just tuck it into an include file, so what do I do to have it available for all the subsequent applications?

Thanks.
Bruce Peaslee
"Reality is a crutch for those who can't do drugs."

MichaelW

I think you mean the RGB macro in macros.asm. You can include macros.asm in your source (along with the .MODEL directive, etc, see the include file for the details) as part of masm32rt.inc with:

include \masm32\include\masm32rt.inc

Or separately with:

include \masm32\macros\macros.asm

Another of multiple possibilities is a macro function that returns an RGB value calculated entirely by the preprocessor (at assembly time, instead of at run time as the MASM32 RGB macro does).

    rgb MACRO red, green, blue
      EXITM % blue SHL 16 + green SHL 8 + red
    ENDM


eschew obfuscation

peaslee

RGB was a bad choice for an example. Let's say I create an entirely new macro or perhaps a procedure that I will use frequently. I assume that it would have to be assembled and linked, but I don't know how.
Bruce Peaslee
"Reality is a crutch for those who can't do drugs."

dedndave

have a look in the masm32\macros folder
there are a few examples
another appropriate place to put them is the masm32\include folder

just make your file, stick it one of those folders, then include it in your asm file

when you INCLUDE an external file, it is as though all the text in that file is expanded at the INCLUDE directive

MichaelW

Create your own include file, put it in some convenient location, and include it in you source. The attachment is a quick demo.
eschew obfuscation