Hi guys, Just started with 32 bit assembly. I've seen two uses of the angle brackets ("< >") already. One is in the macro used for vararg and the other in EQU statements like MessageBox EQU
. What exactly does these angle brackets signify and is there any more uses of it. Eagerly awaiting reply.
This is from masm32.hlp:
Description: Treats as a single literal string. Angle brackets are often used in macro calls and with the FOR directive to ensure that values in a parameter list are treated as a single parameter. For example, MyMacro ;Passes one argument to ;MyMacro MyMacro one, two, three ;Passes three arguments to ;MyMacro The assembler removes one set of angle brackets each time it inserts an argument into a macro expansion. The is any name, number, or expression. It can contain commas, spaces, tabs, or semicolons. The exclamation point (!) is an escape character that allows you to include special characters such as the semicolon, ampersand, and quotation marks. -o-
How about MessageBox EQU
. Here MessageBoxA is a proc name and not a string. I think < > has got a different meaning here. It is also used in initializing structures.
Well the real meaning of them depends on the context. But in the equ (or textequ most of the time), it does have the meaning as explained in my previous post. In MessageBox equ
(or textequ instead of equ), MessageBoxA is just a string. This line just tells masm that whenever the text "MessageBox" occurs, it should read "MessageBoxA". Until here, it has nothing to do with MessageBoxA being a procedure. This comes later, when masm actually processes the code. The equate just indicates a string stands for something else, no matter what.
Sometimes they are also used to indicate a collection. Like with structure initialization, <> means: the collection of members in the structure. Even here it means fairly the same as 'treat this like a single literal string', but in a different context: 'treat this as a single collection of items'.
You will find the following in user32.inc:
*IS* a text expression. It tells the compiler to do this replacement.
An Aside: Windows 9x has very little Unicode support, the barest set of functions 9really just translators to and from ASCII to Unicode) are defined. HOWEVER, for some curious reason, MessageBoxW IS defined, and more importaintly, it is fully functional. Meaning you hand it Unicode strings, it displays Unicode text.
This can be extremely handy if you are checking Unicode strings under Win 9x.
To use this function, just drop this somewhere:
Here's how and what it does: Most WIN32 APIs exist in two forms: an ASCII form and a UNICODE form. This is true with MessageBox. The ASCII form function is named MessageBoxA, the Unicode version is named MessageBoxW. That's the typical naming convention, A for ACSII, W for Unicode (think of W as W I D E ). Keep in mind a sec that while MASM32 does not support Unicode, while WIN32 does. The big question here is how can the compiler handle TWO forms of every API function? C does it with conditional compilation. If you don't define the symbol UNICODE, it will translate MessageBox as MessageBoxA. If it IS defined, it becomes MessageBoxW. Since MASM32 doesn't support Unicode, it takes a shortcut. It just replaces MessageBox with MessageBoxA and it's done. So
MessageBoxA PROTO :DWORD,:DWORD,:DWORD,:DWORD MessageBox equ
MessageBoxW PROTO :DWORD,:DWORD,:DWORD,:DWORD
Thanks all, I kinda get the idea Clark