Non-Confidential | ![]() | 100067_0609_00_en | ||
| ||||
Home > armclang Command-line Options > -mno-neg-immediates |
Disables the substitution of invalid instructions with valid equivalent instructions that use the logical inverse or negative of the specified immediate value.
-mno-neg-immediates
If an instruction does not have an encoding for the specified value of the
immediate operand, but the logical inverse or negative of the immediate operand is
available, then armclang
produces a valid
equivalent instruction and inverts or negates the specified immediate value. This
applies to both assembly language source files and to inline assembly code in C and
C++ language source files.
For example, armclang
substitutes the instruction sub r0, r0, #0xFFFFFF01
with the equivalent
instruction add r0, r0, #0xFF
.
You can disable this substitution using the option -mno-neg-immediates
. In this case, armclang
generates the error instruction requires:
NegativeImmediates
, if it encounters an invalid instruction that can be
substituted using the logical inverse or negative of the immediate value.
When you do not use the option -mno-neg-immediates
, armclang
is
able to substitute instructions but does not produce a diagnostic message when a
substitution has occurred. When you are comparing disassembly listings with source
code, be aware that some instructions might have been substituted.
By default, armclang
substitutes invalid
instructions with an alternative instruction if the substitution is a valid
equivalent instruction that produces the same result by using the logical inverse or
negative of the specified immediate value.
Copy the following code to a file called neg.s
.
.arm sub r0, r0, #0xFFFFFF01 .thumb subw r0, r1, #0xFFFFFF01
Assemble the file neg.s
without the -mno-neg-immediates
option to produce the output
neg.o
.
armclang --target=arm-arm-none-eabi -march=armv7-a -c neg.s -o neg.o
Use fromelf
to see the disassembly from neg.o
.
fromelf --cpu=7-A --text -c neg.o
Note that the disassembly from neg.o
contains substituted instructions ADD
and ADDW
:
** Section #2 '.text' (SHT_PROGBITS) [SHF_ALLOC + SHF_EXECINSTR] Size : 8 bytes (alignment 4) Address: 0x00000000 $a.0 0x00000000: e28000ff .... ADD r0,r0,#0xff $t.1 0x00000004: f20100ff .... ADDW r0,r1,#0xff
Assemble the file neg.s
with the -mno-neg-immediates
option to produce the output
neg.o
.
armclang --target=arm-arm-none-eabi -march=armv7-a -c -mno-neg-immediates neg.s -o neg.o
Note that armclang
generates the error
instruction requires: NegativeImmediates
when assembling this
example with the -mno-neg-immediates
option.
neg.s:2:2: error: instruction requires: NegativeImmediates sub r0,#0xFFFFFF01 ^ neg.s:4:2: error: instruction requires: NegativeImmediates subw r0,r1,#0xFFFFFF01 ^