Search code examples
assemblynaming-conventionsmasm

MASM naming convention for identifiers beginning with a question mark?


Looking at the BNF grammar for MASM, an identifier can be named as follows:

The first character of the identifier can be an upper or lower-case alphabetic character ([A–Za-z]) or any of these four characters: @ _ $ ? The remaining characters can be any of those same characters or a decimal digit ([0–9]). Maximum length is 247 characters.

Are there any MASM (or assembly) naming conventions for beginning an identifier with a ? (question mark) ?


Solution

  • I'm not aware of any documented convention for leading ?s. But MASM appears to use two leading question marks when expanding macros that contain LOCAL labels.

    This isn't clearly documented as a convention AFAIK, but the MASM Programmer's Guide kind of mentions it in passing in the section named "Defining Local Symbols in Macros".


    We can also test this ourselves by writing a simple piece of code:

    .686
    .model flat,stdcall
    option casemap:none
    
    FOO MACRO
    LOCAL local_to_foo
    local_to_foo:
    ENDM
    
    .code
    
    start:
    
    FOO
    FOO
    
    END start
    

    If we tell MASM to generate a listing file for this (with the /Fl option), the listing for the code section will look like this:

     00000000           .code
    
     00000000           start:
    
                    FOO
     00000000            1  ??0000:
                    FOO
     00000000            1  ??0001:
    
                    END start
    

    Bottom line is, it's probably best for you as a programmer to not use leading question marks in your identifiers, just like the MASM Programmer's Guide advises you not not use leading @ characters since MASM uses that for some predefined special symbols.