Keil Logo

Technical Support

On-Line Manuals

Compiler Reference Guide

Preface armclang Command-line Options Support level definitions Summary of armclang command-line options -C -c -D -E -e -fbare-metal-pie -fbracket-depth=N -fcommon, -fno-common -fdata-sections, -fno-data-sections -ffast-math, -fno-fast-math -ffixed-rN -ffp-mode -ffunction-sections, -fno-function-sections -fident, -fno-ident @file -fldm-stm, -fno-ldm-stm -fno-builtin -fno-inline-functions -flto, -fno-lto -fexceptions, -fno-exceptions -fomit-frame-pointer, -fno-omit-frame-pointer -fropi, -fno-ropi -fropi-lowering, -fno-ropi-lowering -frwpi, -fno-rwpi -frwpi-lowering, -fno-rwpi-lowering -fshort-enums, -fno-short-enums -fshort-wchar, -fno-short-wchar -fstack-protector, -fstack-protector-all, -fstack- -fstrict-aliasing, -fno-strict-aliasing -ftrapv -fvectorize, -fno-vectorize -fvisibility -fwrapv -g, -gdwarf-2, -gdwarf-3, -gdwarf-4 -I -include -L -l -M, -MM -MD, -MMD -MF -MG -MP -MT -march -marm -masm -mbig-endian -mbranch-protection -mcmse -mcpu -mexecute-only -mfloat-abi -mfpu -mimplicit-it -mlittle-endian -mmemtag-stack, -mno-memtag-stack -mno-neg-immediates -moutline, -mno-outline -mpixolib -munaligned-access, -mno-unaligned-access -mthumb -nostdlib -nostdlibinc -o -O -pedantic -pedantic-errors -Rpass -S -save-temps -std --target -U -u -v --version --version_number --vsn -W -Wl -Xlinker -x -### Compiler-specific Keywords and Operators Compiler-specific Function, Variable, and Type Att Compiler-specific Intrinsics Compiler-specific Pragmas Other Compiler-specific Features Standard C Implementation Definition Standard C++ Implementation Definition armclang Integrated Assembler armclang Inline Assembler

-mno-neg-immediates

1.60 -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.

Syntax

-mno-neg-immediates

Usage

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.

Default

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.

Example

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
 ^
Non-ConfidentialPDF file icon PDF version100067_0612_00_en
Copyright © 2014–2019 Arm Limited or its affiliates. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.