1. GNU-Syntax Arm Assembler Command Line

1.1. Usage

To invoke the tiarmclang assembler, use the following syntax:

tiarmclang [options] <gnu asm file>.S […]
tiarmclang [options] <gnu asm file>.s […]
  • tiarmclang - This command runs the assembler and other tools (compiler and linker, for example). For information about running the compiler, see Invoking the Compiler. For information about running the linker, see Invoking the Linker.

  • options - Options that affect the way that the compiler tools process input files. For the assembler, these may include:

    • tiarmclang options - affect the behavior of the C/C++ compiler or the integrated GNU-syntax Arm assembler. See Command-Line Options.

    • Legacy TI-syntax Arm assembler options - are prefixed with either the -Wti-a, or -Xti-assembler option indicating that the option that follows should be passed directly to the legacy TI-syntax Arm assembler. This legacy assembler can also be invoked using the tiarmasm command. Legacy TI-syntax Arm assembler options are described in more detail in the TI-Syntax Arm Assembler section. See Passing Options to Other Tools from tiarmclang for more information about passing options to the legacy TI-Syntax Arm Assembler.

  • filenames - One or more input files. For the GNU-syntax Arm assembler, by default, an input file with either a .s or .S file extension is interpreted as a GNU-syntax Arm assembly source file. See Effects of the C Preprocessor for details about the difference between how .S and .s files are handled.

You may use the -x assembler option to instruct tiarmclang to interpret input files that follow the -x assembler option on the tiarmclang command-line as GNU-syntax Arm assembly source files. Similarly, you may use the -x assembler-with-cpp option to instruct tiarmclang to run the input files that follow the option through the C pre-processor before passing the output of the C pre-processor to the GNU-syntax Arm assembler. For more information, see Using -x Option to Control Input File Interpretation.

Additional information about the assembler command line can be found in Integrated GNU-Syntax Arm Assembler.

1.2. Example

The following simple example uses the tiarmclang command to run the assembler:

tiarmclang -mcpu=cortex-m0 print_global.S def_global.s -c

The print_global.S file is run through the C preprocessor and then passed to the GNU-syntax Arm assembler. The def_global.s file is passed directly to the assembler. The -c option instructs tiarmclang to generate an object file without invoking the linker.

1.3. Effects of the C Preprocessor

Input files with an uppercase .S file extension are first run through the C pre-processor, and the output is passed to the integrated GNU-syntax Arm assembler. Input files with a lowercase .s file extension are passed directly to the integrated GNU-syntax Arm assembler without using the C pre-processor.

Preprocessing directives in the assembly source file are useful for configuring assembly source content based on predefined macro symbols that are available to the C preprocessor. These macro symbols comply with the Arm C Language Extensions (ACLE) by predefining the appropriate ACLE macro symbols based on the processor options specified on the command line.

For example, the following assembly code has different results depending on whether it is contained in a .S or .s file:

.section        .data, "aw", %progbits

.if     __ARM_ARCH == 7
.long   7
.elseif __ARM_ARCH == 6
.long   6
.else
.long   5
.endif

If this example code is contained in a file with a .S extension, the __ARM_ARCH macro symbol is defined by the C preprocessor and is available to the assembler. If this code is contained in a file with a .s extension, the directives that reference the __ARM_ARCH macro cause an error to be generated. See the Runtime Support and Pre-Defined Macro Symbols topics for more about the defined macro symbols.

1.4. Command-Line Options

When specifying an assembler-only option from the tiarmclang command line, you must precede the assembler option with the -Xasssembler option. For example:

%> tiarmclang -mcpu=cortex-m0 -Xassembler -I"./asm_inc_dir" hello.s -c

Or, you can use the -Wa option. For example:

%> tiarmclang -mcpu=cortex-m0 -Wa,-I"./asm_inc_dir" hello.s -c

Either option tells the integrated assembler to add the relative path ./asm_inc_dir to the directory search path in which the assembler looks for files that are incorporated into the assembly source file via an .include directive.

Standard command-line options available with the GNU assembler are described in the GNU Assembler - Using as document. See the Command-Line Options and Arm-Dependent Options for details. Please note that not all GNU assembler options documented in these online resources are supported by the tiarmclang compiler tools.