4.14.2. Targeting the ARM or Thumb instruction set

You can compile or assemble your sources for the ARM® or Thumb instruction set. Table 4.6 shows the compiler and assembler functionality that enables you to do this.

Table 4.6. Targeting the ARM and Thumb instruction sets

Target instruction setCompilerAssemblerScope
ARMarmcc --armarmasm -32 or --armsource file(s)
ARM#pragma arm

CODE32 directive

Thumbarmcc --thumbarmasm -16 or --thumbsource file(s)
Thumb#pragma thumb

CODE16 directive


[1] If your source code contains these instructions, they override the opposing command-line options. For example, the CODE16 directive overrides the command armasm -32.

If you include the pragmas or directives in your source code, you generate mixed instruction set code. For this to work properly, you must also use the interworking compiler option. See Targeting specific procedure call standard variants for details.

To see how the assembler directives are used, examine the RVDK example assembler file examples_directory\asm\thumbsub.s.

You can also use alternative compiler commands shown in Table 4.7 to compile your C and C++ code for ARM and Thumb instructions sets.

Table 4.7. Alternative compiler commands

CommandDescriptionEquivalent armcc command


Compiles for ISO standard C, and the ARM instruction set, but only if your source files have .c extensions



Compiles for ISO standard C++, and the ARM instruction set

armcc --cpp


Compiles for ISO standard C, and the Thumb instruction set

armcc --thumb


Compiles for ISO standard C++, and the Thumb instruction set

armcc --thumb --cpp

Copyright © 2005, 2006 ARM Limited. All rights reserved.ARM DUI 0276B