Return Hex Value %

The percent sign (%) is similar to the standard return value operator except that it returns the hexadecimal value of a symbol. When the macro processor encounters this operator, the % symbol sequence is converted to a character string representing the hexadecimal value of the symbol. Consider the macro definition shown in the following listing.

Listing: GEN_LAB Macro, Return Hex Value Dummy Argument
GEN_LAB MACRO LAB,VAL,STMT 
LAB\%VAL STMT 
ENDM 

This macro generates a label consisting of the concatenation of the label prefix argument and a value that is interpreted as hexadecimal. If this macro were called as follows,

  NUM SET 10 GEN_LAB HEX,NUM,'NOP' 

the macro processor would first substitute the characters HEX for LAB, then it would replace %VAL with the character A, since A is the hexadecimal representation for the decimal integer 10. Next, the macro processor would apply the concatenation operator ( \). Finally, the string ' NOP' would be substituted for the STMT argument. The resulting expansion as it would appear in the listing file would be:

  HEXA NOP 

The percent sign is also the character used to indicate a binary constant. If a binary constant is required inside a macro, it may be necessary to enclose the constant in parentheses or escape the constant by following the percent sign with a backslash (\).