In ?MASM Programmer's Guide?(Chapter 9 Using Macros), there are some sentences about marco
It is important to understand the difference between text values and numeric values.
Numeric values can be processed with arithmetic operators and assigned to numeric equates.
Text values can be processed with macro functions and assigned to text macros. 

I want to know What is text value and what is  numeric value? Please give me some examples. 

Posted on 2008-09-11 06:10:43 by qlmi
The important thing to realize about macros is that they are interpreted and executed by the assembler DURING the build process, and they typically emit SOURCECODE - you'll see a lot of people say that a macro 'expands to sourcecode' - this is true, a macro can emit any number of lines of sourcecode that the assembler will then go on to interpret when the macro has finished executing.

A numerical value is a number - nothing special.

A text value is essentially a string that is defined within the sourcecode (such that the assembler can see it) but doesn't necessarily end up in your assembled binary object - using a macro, you can interpret a string (passed to the macro as an input argument) and its substrings, and then have the macro emit different asm sourcecode depending on the string passed to the macro. Text values can also be concatenated by macros, allowing for more complex interpretations.

Also, macros support a special argument type called VARARG, which allows you to pass an entire statement to the macro intact. It's even possible to parse all the terms passed in a VARARG, and analyze the input statement and respond to it accordingly, but thats a rather advanced example.

An simple example of VARARG is:

$invoke macro funcname, args:VARARG
invoke funcname, args
exitm <eax>

Note that this macro returns a value into EAX.
This allows us to use the macro inline as follows:

dUserSelected dd NULL
szCaption db "Are you human?",0
szText db "Click to choose",0
mov dUserSelected, $invoke (MessageBox,0,addr szText, addr szCaption, MB_YESNO)

When the assembler interprets the above line of code, the macro will be expanded into the following:

invoke MessageBox,0,addr szText, addr szCaption, MB_YESNO
mov dUserSelected,eax

neat, huh?

There's a whole lot you can do with macros, but their main function is to make the job of writing code easier and more readable. I think macros are not fully appreciated by most programmers due to limitations in macro-capable assemblers and due to their relative obscurity (which is a result of the former).

Posted on 2008-09-12 02:12:29 by Homer