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

per-function[1]
Thumbarmcc --thumbarmasm -16 or --thumbsource file(s)
Thumb#pragma thumb

CODE16 directive

per-functiona

[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

armcc

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

armcc

armcpp

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

armcc --cpp

tcc

Compiles for ISO standard C, and the Thumb instruction set

armcc --thumb

tcpp

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

armcc --thumb --cpp

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