## 5.13 A32 and T32 instruction substitutions

In certain circumstances, if the value of an Operand2 constant is not available with a given instruction, but its logical inverse or negation is available, then armasm can produce an equivalent instruction with the inverted or negated constant. The armclang integrated assembler provides limited support for such substitutions.

## Substitutions when using armasm

More information about the syntax of Operand2 constants is available in the armasm User Guide. The following table shows the instruction substitutions supported by armasm, based on the values of Operand2 constants for the A32 and T32 instruction sets. The equivalent instructions shown can be used manually with the armclang integrated assembler for instructions where automatic substitution is not supported.

Table 5-3 A32 and T32 instruction substitutions supported by armasm

A32 and T32 instruction Equivalent instruction Constant substitution method
`ADC{S}{cond} {Rd}, Rn, #constant` `SBC{S}{cond} {Rd}, Rn, #~constant` Logical inversion
`ADD{S}{cond} {Rd}, Rn, #constant` `SUB{S}{cond} {Rd}, Rn, #-constant` Negation
`AND{S}{cond} Rd, Rn, #constant` `BIC{S}{cond} Rd, Rn, #~constant` Logical inversion
`BIC{S}{cond} Rd, Rn, #constant` `AND{S}{cond} Rd, Rn, #~constant` Logical inversion
`CMP{cond} Rn, #constant` `CMN{cond} Rn, #-constant` Negation
`CMN{cond} Rn, #constant` `CMP{cond} Rn, #-constant` Negation
`MOV{S}{cond} Rd, #constant` `MVN{S}{cond} Rd, #~constant` Logical inversion
`MVN{S}{cond} Rd, #constant` `MOV{S}{cond} Rd, #~constant` Logical inversion

`ORN{S}{cond} Rd, Rn, #constant`

(T32 only)

`ORR{S}{cond} Rd, Rn, #~constant`

(T32 only)

Logical inversion

`ORR{S}{cond} Rd, Rn, #constant`

(T32 only)

`ORN{S}{cond} Rd, Rn, #~constant`

(T32 only)

Logical inversion
`SBC{S}{cond} {Rd}, Rn, #constant` `ADC{S}{cond} {Rd}, Rn, #~constant` Logical inversion
`SUB{S}{cond} {Rd}, Rn, #constant` `ADD{S}{cond} {Rd}, Rn, #-constant` Negation

To find instruction substitutions in code assembled using armasm, use the command-line option `--diag_warning=1645`.

## Substitutions when using armclang integrated assembler

The armclang integrated assembler is also able to produce valid equivalent instructions through substitution, by inverting or negating the specified immediate value. This applies to both assembly language source files and to inline assembly code in C and C++ language source files.

You can disable this substitution using the `-mno-neg-immediates` armclang option.

 Non-Confidential PDF version 100068_0609_00_en Copyright © 2014–2017 Arm Limited (or its affiliates). All rights reserved.