Substitute Operator (&) 

The substitute operator (&) forces the assembler to substitute a parameter with the actual argument. The syntax is

      &name
where name is the value of the argument in the macro call. The & operator is typically used to concatenate one or more parameters with other text.

Example: We can write a macro to sort two numbers num1 and num2 that works on a 16-bit signed or unsigned numbers.
   Sort2   MACRO   cond, num1, num2
             LOCAL done
             PUSH   AX
             MOV    AX, num1
             CMP    AX, num2
             J&cond  done 
             XCHG   AX, num2    
             MOV    num1, AX
      done:  POP    AX
           ENDM
 

In this macro, the cond parameter specifies the relationship of num2 relative to num1. For example, to sort two unsigned numbers value1 and value2 such that value1 >= value2, we can invoke the macro as

    sort2 AE, value1, value2
which causes the following macro expansion:
            sort2 AE, value1, value2
                     PUSH   AX
                     MOV    AX, value1
                     CMP    AX, value2
                     JAE    ??0000
                     XCHG   AX, value2
                     MOV    value1, AX
            ??0000:  POP    AX

If value1 and value2 are signed numbers, this macro should be invoked as

    sort2 GE, value1, value2
which generates the JGE conditional jump instruction in the macro expansion.

The substitute operator is also useful to force the assembler to substitute a parameter inside a quoted string. This is illustrated in the following example.

Example: Write a macro to define an error message for informing the user when the input number is out of range.
   range_error  MACRO   number, variable
                  err_msg&number  DB  "&variable: out of range", 0 
                ENDM
 

When the macro is invoked as

    range_error   1, Assignment_mark     
it will be expanded as
    err_msg1  DB  "Assignment_mark: out of range",0