How the MASM macros work? I've been learning win32asm with MASM for some months and I still don't understand how they work or how to make them and when to make them.
Some questions I have:
Do these macros increase the EXE size?
Those macros are like VC++ pre-compiler?
Where can I learn how to make them?
Thanks in advance.
Posted on 2001-09-09 21:57:30 by dilau
Think of a macro as a code generator. Macros are processed by the "firat pass" of the assembler, and any code that they generate is then processed with the "normal" instructions that you wrote. Here's a simple macro that comes with many of the MASM32 examples:

m2m MACRO M1, M2
push M2
pop M1
ENDM

Now that the macro is defined, you can use it by saying something like this:

m2m toword, fromword

The macro would generate the following code, which is then assembled:

push fromword
pop toword

This is a simple macro. They can be very complex. The ML documentation has some good info on macros. MASM32 also has a MASM reference that covers the basics of macros.

:)
Posted on 2001-09-10 03:17:46 by S/390
Chapter 9 of the MASM Reference is the best place to start. You can find it on the web by just searching Google for "MASM MACROS".

Macros can add to the exe size, or reduce performance without proper consideration of the problem being solved. For example if the macro above was 'm2m eax,ecx' this would produce sub-optimal code because the macro is being used out-of-context. If size/performance is not a concern then macros can be used to program quite rapidly in asm.

Macro instructions are very much like the preprocessor of other languages. Values are manipulated without producing code, or code is conditionally created based on assemble-time values.
Posted on 2001-09-10 08:20:46 by bitRAKE