Another macro definition operator is the question mark (?) that returns the value of a symbol. When the macro processor encounters this operator, the ?symbol sequence is converted to a character string representing the decimal value of symbol. For example, consider the following modification of the SWAP_REG macro in the following listing.
SWAP_SYM MACRO REG1,REG2 ;swap REG1,REG2 using X0 as temp MOVE R\?REG1,X0 MOVE R\?REG2,R\?REG1 MOVE X0,R\?REG2 ENDM
If the source file contained the following SET statements and macro call,
AREG SET 0 BREG SET 1 SWAP_SYM AREG,BREG
then the sequence of events would be as follows: the macro processor would first substitute the characters AREG for each occurrence of REG1 and BREG for each occurrence of REG2. For discussion purposes (this would never appear on the source listing), the intermediate macro expansion would be:
MOVE R\?AREG,X0 MOVE R\?BREG,R\?AREG MOVE X0,R\?BREG
The macro processor would then replace ?AREG with the character 0 and ?BREG with the character 1, since 0 is the value of the symbol AREG and 1 is the value of BREG. The resulting intermediate expansion would be:
MOVE R\0,X0 MOVE R\1,R\0 MOVE X0,R\1
Next, the macro processor would apply the concatenation operator (\), and the resulting expansion as it would appear on the source listing would be:
MOVE R0,X0 MOVE R1,R0 MOVE X0,R1