AARM User's Guide

Discontinued

% Operator

The percent operator ('%') is used to pass the value of an expression to a macro rather than passing the literal expression itself. The following example shows a macro definition, that requires a numeric value, along with macro invocations that use the percent operator to pass the value of an expression to the macro.

OUTPORT MACRO   N
        MOV     R1, #N
        ENDM

RESET_SIG EQU 0FFh
CLEAR_SIG EQU 0

OUTPORT %(RESET_SIG AND NOT 11110000b)
; Expands into MOV R1, #15

OUTPORT %(CLEAR_SIG OR 11110000b)
; Expands into MOV R1, #240

The expressions evaluated in the highlighted lines could not be passed to the macro because the macro expects a numeric value. Expressions like these must be evaluated before the macro. The percent operator forces the assembler to generate a numeric value which is then passed to the macro.