4.1.5. Predefined Assembler Symbols

The legacy TI-syntax Arm assembler provides several types of predefined symbols, many of which will need to be mapped to their GNU-syntax Arm assembler’s functional equivalent when migrating TI-syntax Arm assembly source to GNU-syntax Arm assembly source.

This section of the migration guide will provide guidance on which TI-syntax Arm assembler predefined symbols can be mapped to their GNU-syntax equivalents and how to map them, also noting which of the TI-syntax Arm assembler predefined symbols to not have a functionally equivalent predefined symbol in GNU-syntax Arm assembly source.

4.1.5.1. Section Location Counter

The TI-Syntax ‘$’ Symbol

The TI-syntax Arm assembler provides a special $ symbol that can be used to represent the current value of the section location counter (also known as the section program counter or SPC). The $ symbol can come in handy in TI-syntax Arm assembly source when computing a section-relative offset at assembly time.

The GNU-Syntax ‘.’ Symbol

The tiarmclang’s integrated GNU-syntax Arm assembler provides a special dot symbol (.) that is functionally equivalent to the TI-syntax Arm assembler’s $ symbol. The dot symbol refers to the current address of the section that tiarmclang is assembling into.

An Example Migration

In the following example, a section location counter is used to compute the size of a block of data.

* TI-syntax block of data
      .data
data_start:
      .int      data_end - $
      <data defining directives>
data_end:

We can simply replace the $ symbol with the dot symbol to convert the block of data from TI-syntax to GNU-syntax Arm assembly:

* GNU-syntax block of data
      .data
data_start:
      .int      data_end - .
      <data defining directives>
data_end:

4.1.5.2. Predefined Symbolic Constants

The TI-syntax Arm assembler predefines a number of symbolic constants. The value of many of these symbolic constants is determined by the command-line arguments with which the assembler is invoked. For example, the __TI_ARM_V6M0__ symbol is predefined with a value of 1 if the TI-syntax Arm assembler is invoked for a Cortex-M0 target (-mv6M0 option).

The vast majority of references to TI-syntax Arm assembler symbolic constants are made in the context of conditional directives. For example, a Cortex-M0 specific implementation of a function written in TI-syntax Arm assembly might be guarded by an “.if” conditional directive:

;* Cortex-M0 implementation of my_func (TI-syntax)

    .if __TI_ARM_V6M0__

    ...
    .global my_func

my_func:
    ...
    <assembly source implementation>
    ...

    .endif

Convert TI-Syntax Symbolic Constant References to Preprocessor Directives

While the tiarmclang’s integrated GNU-syntax Arm assembler does support conditional directives like those supported in the TI-syntax Arm assembler, the GNU-syntax Arm assembler does not support the same predefined symbolic constants as the TI-syntax Arm assembler. However, a given reference to a TI-syntax symbolic constant can be converted into a C/C++ preprocessing directive that can be embedded in a GNU-syntax Arm assembly source file that will be processed by the tiarmclang’s C/C++ preprocessor before invoking the integrated GNU-syntax assembler.

Thus, the above snippet of TI-syntax Arm assembly source can be converted to GNU-syntax using a preprocessor directive in place of the conditional directives like so:

;* Cortex-M0 implementation of my_func (GNU-syntax)

    #if (__ARM_ARCH == 6) && (__ARM_ARCH_PROFILE == 'M')

    ...
    .global my_func

my_func:
    ...
    <assembly source implementation>
    ...

    #endif

You must then instruct the tiarmclang compiler to pre-process the GNU-syntax Arm assembly source file in one of two ways:

  • Use .S file extension - Using a .S file extension for your GNU-syntax Arm assembly source file will instruct the tiarmclang compiler to run its preprocessor over the assembly source before passing the preprocessed assembly source on to the integrated GNU-syntax Arm assembler.

%> tiarmclang -mcpu=cortex-m0 -c my_func.S
  • Use -x assembler-with-cpp option - If the -x assembler-with-cpp option is specified on the tiarmclang command-line, then tiarmclang will interpret input files that follow the -x assembler-with-cpp option as GNU-syntax assembly source files that will be preprocessed before being assembled.

%> tiarmclang -mcpu=cortex-m0 -c -x assembler-with-cpp my_func.xyz

The remainder of this section will list the predefined symbolic constants that are supported in the TI-syntax Arm assembler and, if a given symbolic constant has a functional equivalent predefined macro symbol expression that is supported via tiarmclang’s C/C++ preprocessor, then a description of how the TI-syntax symbolic constant reference can be converted into a preprocessing directive will be provided.

Most of the preprocessing directive examples below make use of predefined macro symbols that are part of the Arm C Language Extensions (ACLE) support included in the tiarmclang compiler. You can find more information about ACLE in the Arm C Language Extensions - ACLE section of this migration guide.

  • .TI_ARM

    The .TI_ARM predefined symbol is always set to 1 when the TI-syntax Arm assembler is invoked. The following reference to .TI_ARM:

    ;* TI-syntax reference to .TI_ARM
    
      .if .TI_ARM
      .int      0x1234
      .endif
    

    is functionally equivalent to the following GNU-syntax Arm assembly:

    // GNU-syntax conversion of .TI_ARM reference
    
      #if defined(__ti_version__) && (__ARM_ARCH != 0)
      .int      0x1234
      #endif
    

    where __ti_version__ is a predefined macro symbol unique to tiarmclang and __ARM_ARCH is an ACLE representation of the Arm architecture version.

  • .TI_ARM_16BIS

    The .TI_ARM_16BIS predefined symbol is set to 1 if the compiler has been instructed to generate THUMB mode instructions for an Arm processor. The following reference to .TI_ARM_16BIS:

    ;* TI-syntax reference to .TI_ARM_16BIS
    
      .if .TI_ARM_16BIS
      .int      0x1234
      .endif
    

    is functionally equivalent to the following GNU-syntax Arm assembly:

    // GNU-syntax conversion of .TI_ARM_16BIS reference
    
      #if defined(__thumb__)
      .int      0x1234
      #endif
    

    where __thumb__ is a tiarmclang predefined macro symbol that indicates that the compiler has been instructed to generate THUMB mode instructions.

  • .TI_ARM_32BIS

    The .TI_ARM_32BIS predefined symbol is set to 1 if the compiler has been instructed to generate 32-bit ARM mode instructions for an Arm processor. The following reference to .TI_ARM_32BIS:

    ;* TI-syntax reference to .TI_ARM_32BIS
    
      .if .TI_ARM_32BIS
      .int      0x1234
      .endif
    

    is functionally equivalent to the following GNU-syntax Arm assembly:

    // GNU-syntax conversion of .TI_ARM_32BIS reference
    
      #if !defined(__thumb__)
      .int      0x1234
      #endif
    

    where __thumb__ is a tiarmclang predefined macro symbol that indicates that the compiler has been instructed to generate THUMB mode instructions. The expression “!defined(__thumb__) in this case indicates that the compiler will generate ARM mode instructions.

  • .TI_ARM_T2IS

    The .TI_ARM_T2IS predefined symbol is set to 1 if an Arm version 7 architecture processor is selected and targeted to generate THUMB mode instructions (this is also referred to as the THUMB2 or T32 instruction set). The following reference to .TI_ARM_T2IS:

    ;* TI-syntax reference to .TI_ARM_T2IS
    
      .if .TI_ARM_T2IS
      .int      0x1234
      .endif
    

    is functionally equivalent to the following GNU-syntax Arm assembly:

    // GNU-syntax conversion of .TI_ARM_T2IS reference
    
      #if defined(__thumb__) && \
          (__ARM_ARCH == 7 && \
           (__ARM_ARCH_PROFILE == 'R' || \
            (__ARM_ARCH_PROFILE == 'M' && defined(__ARM_FEATURE_SIMD32))))
      .int      0x1234
      #endif
    

    where __thumb__ is a tiarmclang predefined macro symbol that indicates that the compiler has been instructed to generate THUMB mode instructions. The __ARM_ARCH, __ARM_ARCH_PROFILE, and __ARM_FEATURE_SIMD32 are ACLE predefined macro symbols, the combination of which is used to identify the Cortex-M4 or a Cortex-R series Arm processor that can be selected via tiarmclang’s -mcpu=cortex-m4, -mcpu=cortex-r4, or -mcpu=cortex-r5 option.

  • .TI_ARM_LITTLE

    The .TI_ARM_LITTLE predefined symbol is set to 1 if little-endian mode is selected via armcl’s -me or --endian=little option. The following reference to .TI_ARM_LITTLE:

    ;* TI-syntax reference to .TI_ARM_LITTLE
    
      .if .TI_ARM_LITTLE
      .int      0x1234
      .endif
    

    is functionally equivalent to the following GNU-syntax Arm assembly:

    // GNU-syntax conversion of .TI_ARM_LITTLE reference
    
      #if defined(__ARM_LITTLE_ENDIAN)
      .int      0x1234
      #endif
    

    where __ARM_LITTLE_ENDIAN is an ACLE predefined macro symbol. __ARM_BIG_ENDIAN indicates that the compiler will generate little-endian object code as dictated by the tiarmclang -mlittle-endian option.

  • .TI_ARM_BIG

    The .TI_ARM_BIG predefined symbol is set to 1 if big-endian mode is selected via armcl’s --endian=big option (which is also the default behavior for armcl). The following reference to .TI_ARM_BIG:

    ;* TI-syntax reference to .TI_ARM_BIG
    
      .if .TI_ARM_BIG
      .int      0x1234
      .endif
    

    is functionally equivalent to the following GNU-syntax Arm assembly:

    // GNU-syntax conversion of .TI_ARM_BIG reference
    
      #if defined(__ARM_BIG_ENDIAN)
      .int      0x1234
      #endif
    

    where __ARM_BIG_ENDIAN is an ACLE predefined macro symbol. __ARM_BIG_ENDIAN indicates that the compiler will generate big-endian object code as dictated by the tiarmclang -mbig-endian option.

  • __TI_ARM_V6M0__

    The __TI_ARM_V6M0__ predefined symbol is set to 1 if the Cortex-M0 processor is targeted via armcl’s -mv6m0 option. The following reference to __TI_ARM_V6M0__:

    ;* TI-syntax reference to __TI_ARM_V6M0__
    
      .if __TI_ARM_V6M0__
      .int      0x1234
      .endif
    

    is functionally equivalent to the following GNU-syntax Arm assembly:

    // GNU-syntax conversion of __TI_ARM_V6M0__ reference
    
      #if (__ARM_ARCH == 6 && __ARM_ARCH_PROFILE == 'M')
      .int      0x1234
      #endif
    

    where __ARM_ARCH and __ARM_ARCH_PROFILE are ACLE predefined macro symbols, the combination of which is used to identify the Cortex-M0 processor that can be selected via tiarmclang’s -mcpu=cortex-m0 option.

  • __TI_ARM_V7__

    The __TI_ARM_V7__ predefined symbol is set to 1 if any processor based on version 7 of the Arm architecture is selected via an armcl option. The following reference to __TI_ARM_V7__:

    ;* TI-syntax reference to __TI_ARM_V7__
    
      .if __TI_ARM_V7__
      .int      0x1234
      .endif
    

    is functionally equivalent to the following GNU-syntax Arm assembly:

    // GNU-syntax conversion of __TI_ARM_V7__ reference
    
      #if (__ARM_ARCH == 7)
      .int      0x1234
      #endif
    

    where __ARM_ARCH is a ACLE predefined macro symbol used to identify a processor that is based on version 7 of the Arm architecture.

  • __TI_ARM_V7M3__

    The __TI_ARM_V7M3__ predefined symbol is set to 1 if the Cortex-M3 Arm processor is targeted via armcl’s -mv7m3 option. The follow when the TI-syntax Arm assembler is invoked. The following reference to .TI_ARM:

    ;* TI-syntax reference to __TI_ARM_V7M3__
    
      .if __TI_ARM_V7M3__
      .int      0x1234
      .endif
    

    is functionally equivalent to the following GNU-syntax Arm assembly:

    // GNU-syntax conversion of __TI_ARM_V7M3__ reference
    
      #if (__ARM_ARCH == 7 && __ARM_ARCH_PROFILE == 'M' && \
           !defined(__ARM_FEATURE_SIMD32))
      .int      0x1234
      #endif
    

    where __ARM_ARCH, __ARM_ARCH_PROFILE, and __ARM_FEATURE_SIMD32 are ACLE predefined macro symbols, the combination of which is used to identify the Cortex-M3 processor that can be selected via tiarmclang’s -mcpu=cortex-m3 option.

  • __TI_ARM_V7M4__

    The __TI_ARM_V7M$__ predefined symbol is set to 1 if the Cortex-M4 Arm processor is targeted via armcl’s -mv7m4 option. The following reference to __TI_ARM_V7M4__:

    ;* TI-syntax reference to __TI_ARM_V7M4__
    
      .if __TI_ARM_V7M4__
      .int      0x1234
      .endif
    

    is functionally equivalent to the following GNU-syntax Arm assembly:

    // GNU-syntax conversion of __TI_ARM_V7M4__ reference
    
      #if (__ARM_ARCH == 7 && __ARM_ARCH_PROFILE == 'M' && \
           defined(__ARM_FEATURE_SIMD32))
      .int      0x1234
      #endif
    

    where __ARM_ARCH, __ARM_ARCH_PROFILE, and __ARM_FEATURE_SIMD32 are ACLE predefined macro symbols, the combination of which is used to identify the Cortex-M4 processor that can be selected via tiarmclang’s -mcpu=cortex-m4 option.

  • __TI_ARM_V7R4__

    The __TI_ARM_V7R4__ predefined symbol is set to 1 if the Cortex-R4 Arm processor is targeted via armcl’s -mv7r4 option. The following reference to __TI_ARM_V7R4__:

    ;* TI-syntax reference to __TI_ARM_V7R4__
    
      .if __TI_ARM_V7R4__
      .int      0x1234
      .endif
    

    is functionally equivalent to the following GNU-syntax Arm assembly:

    // GNU-syntax conversion of __TI_ARM_V7R4__ reference
    
      #if (__ARM_ARCH == 7 && __ARM_ARCH_PROFILE == 'R')
      .int      0x1234
      #endif
    

    where __ARM_ARCH and __ARM_ARCH_PROFILE are ACLE predefined macro symbols, the combination of which is used to identify the Cortex-R4 processor that can be selected via tiarmclang’s -mcpu=cortex-r4 option.

  • __TI_VFP_SUPPORT__

    The __TI_VFP_SUPPORT__ predefined symbol is set to 1 if floating-point coprocessor support is enabled via the armcl’s --float_support option usage. The following reference to __TI_VFP_SUPPORT__:

    ;* TI-syntax reference to __TI_VFP_SUPPORT__
    
      .if __TI_VFP_SUPPORT__
      .int      0x1234
      .endif
    

    is functionally equivalent to the following GNU-syntax Arm assembly:

    // GNU-syntax conversion of __TI_VFP_SUPPORT__ reference
    
      #if defined(__ARM_FP)
      .int      0x1234
      #endif
    

    where __ARM_FP is an ACLE predefined macro symbol. __ARM_FP indicates that use of the floating-point coprocessor is enabled via the -mfloat-abi=hard option.

  • __TI_VFPV3D16_SUPPORT__

    The __TI_VFPV3D16_SUPPORT__ predefined symbol is set to 1 if floating-point coprocessor support is enabled via the armcl’s --float_support=vfpv3d16 option. The following reference to __TI_VFPV3D16_SUPPORT__:

    ;* TI-syntax reference to __TI_VFPV3D16_SUPPORT__
    
      .if __TI_VFPV3D16_SUPPORT__
      .int      0x1234
      .endif
    

    is functionally equivalent to the following GNU-syntax Arm assembly:

    // GNU-syntax conversion of __TI_VFPV3D16_SUPPORT__ reference
    
      #if (defined(__ARM_FP) && __ARM_ARCH == 7 && __ARM_ARCH_PROFILE == 'R')
      .int      0x1234
      #endif
    

    where __ARM_FP, __ARM_ARCH, and __ARM_ARCH_PROFILE are ACLE predefined macro symbols. __ARM_FP indicates that use of the floating-point coprocessor is enabled via the -mfloat-abi=hard option. The combination of __ARM_ARCH and __ARM_ARCH_PROFILE is used to identify the Cortex-R4 processor that is paired with the floating point coprocessor selected via the -mfpu=vfpv3-d16 option.

  • __TI_FPV4SPD16_SUPPORT__

    The __TI_FPV4SPD16_SUPPORT__ predefined symbol is set to 1 if floating-point coprocessor support is enabled via the armcl’s --float_support=fpv4spd16 option. The following reference to __TI_FPV4SPD16_SUPPORT__:

    ;* TI-syntax reference to __TI_FPV4SPD16_SUPPORT__
    
      .if __TI_FPV4SPD16_SUPPORT__
      .int      0x1234
      .endif
    

    is functionally equivalent to the following GNU-syntax Arm assembly:

    // GNU-syntax conversion of .TI_ARM reference
    
      #if (defined(__ARM_FP) && __ARM_ARCH == 7 && __ARM_ARCH_PROFILE == 'M')
      .int      0x1234
      #endif
    

    where __ARM_FP, __ARM_ARCH, and __ARM_ARCH_PROFILE are ACLE predefined macro symbols. __ARM_FP indicates that use of the floating-point coprocessor is enabled via the -mfloat-abi=hard option. The combination of __ARM_ARCH and __ARM_ARCH_PROFILE is used to identify the Cortex-M4 processor that is paired with the floating point coprocessor selected via the -mfpu=fpv4-sp-d16 option.

Other TI-Syntax Symbolic Constants

The following list of TI-syntax predefined symbolic constants do not serve any real purpose in the context of an application that is to be built with the tiarmclang compiler tools since tiarmclang only generates code that is compatible with the EABI and only supports a subset of existing Arm processor variants (Cortex-M0, Cortex-M0+, Cortex-M3, Cortex-M4, Cortex-M33, Cortex-R4, and Cortex-R5).

  • __TI_EABI_ASSEMBLER

    The __TI_EABI_ASSEMBLER predefined symbol is set to 1 when the armcl compiler is invoked to generate EABI compatible object code via armcl’s --abi=eabi option. The latest available version of the armcl compiler tools only support generation of EABI compatible object code, so the use of __TI_EABI_ASSEMBLER has become superfluous.

    Likewise, the tiarmclang compiler tools will only generate EABI compatible object code, so there is no need to migrate the __TI_EABI_ASSEMBLER predefined symbolic constant.

  • __TI_ARM7ABI_ASSEMBLER

  • __TI_ARM9ABI_ASSEMBLER

    Both of these ABIs have been deprecated and are no longer supported in the latest version of the armcl compiler tools.

  • __TI_NEON_SUPPORT__

    The tiarmclang compiler does not currently support the Cortex-A8 Arm processor and therefore does not support the neon extensions that are available with a Cortex-A8 Arm processor.

  • __TI_ARM_V4__

  • __TI_ARM_V5E__

  • __TI_ARM_V6__

  • __TI_ARM_V7A8__

    These TI-syntax Arm assembler predefined symbolic constants serve no purpose in the context of an application intended to be built with the tiarmclang compiler tools. The tiarmclang compiler only supports the following Arm Cortex-M and Cortex-R series processor variants:

    • Cortex-M0

    • Cortex-M0+

    • Cortex-M3

    • Cortex-M4

    • Cortex-M33

    • Cortex-R4

    • Cortex-R5

  • __TI_VFPV3_SUPPORT__

    The tiarmclang does not currently support the Cortex-A8 Arm processor and therefore does not support use of the VFPV3 floating point coprocessor that is available with a Cortex-A8 Arm processor.