6.4 Built-in variables and constants

armasm defines built-in variables that hold information about, for example, the state of armasm, the command-line options used, and the target architecture or processor.

The following table lists the built-in variables defined by armasm:

Table 6-1 Built-in variables

{ARCHITECTURE}

Holds the name of the selected ARM architecture.

{AREANAME} Holds the name of the current AREA.
{ARMASM_VERSION}

Holds an integer that increases with each version of armasm. The format of the version number is PVVbbbb where:

P

is the major version.

VV

is the minor version.

bbbb

is the build number.

|ads$version| Has the same value as {ARMASM_VERSION}.

{CODESIZE}

Is a synonym for {CONFIG}.

{COMMANDLINE} Holds the contents of the command line.

{CONFIG}

Has the value 32 if the assembler is assembling ARM code, or 16 if it is assembling Thumb code.

{CPU}

Holds the name of the selected processor. The default is "ARM7TDMI". If an architecture was specified in the command-line --cpu option, {CPU} holds the value "Generic ARM".

{ENDIAN}

Has the value "big" if the assembler is in big-endian mode, or "little" if it is in little-endian mode.

{FPIC} Has the Boolean value {True} if --apcs=/fpic is set. The default is {False}.
{FPU} Holds the name of the selected FPU. The default is "SoftVFP".
{INPUTFILE} Holds the name of the current source file.
{INTER} Has the Boolean value True if --apcs=/inter is set. The default is {False}.
{LINENUM} Holds an integer indicating the line number in the current source file.
{LINENUMUP} When used in a macro, holds an integer indicating the line number of the current macro. The value is the same as {LINENUM} when used in a non-macro context.
{LINENUMUPPER} When used in a macro, holds an integer indicating the line number of the top macro. The value is the same as {LINENUM} when used in a non-macro context.

{OPT}

Value of the currently-set listing option. You can use the OPT directive to save the current listing option, force a change in it, or restore its original value.

{PC} or .

Address of current instruction.

{PCSTOREOFFSET}

Is the offset between the address of the STR PC,[…] or STM Rb,{…, PC} instruction and the value of PC stored out. This varies depending on the processor or architecture specified.

{ROPI} Has the Boolean value {True} if --apcs=/ropi is set. The default is {False}.
{RWPI} Has the Boolean value {True} if --apcs=/rwpi is set. The default is {False}.

{VAR} or @

Current value of the storage area location counter.

You can use built-in variables in expressions or conditions in assembly source code. For example:

        IF {ARCHITECTURE} = "4T"

They cannot be set using the SETA, SETL, or SETS directives.

The built-in variable |ads$version| must be all in lowercase. The names of the other built-in variables can be in uppercase, lowercase, or mixed, for example:

        IF {CpU} = "Generic ARM"

Note:

All built-in string variables contain case-sensitive values. Relational operations on these built-in variables do not match with strings that contain an incorrect case. Use the command-line options --cpu and --fpu to determine valid values for {CPU}, {ARCHITECTURE}, and {FPU}.

The assembler defines the built-in Boolean constants TRUE and FALSE.

Table 6-2 Built-in Boolean constants

{FALSE} Logical constant false.
{TRUE} Logical constant true.

The following table lists the target processor-related built-in variables that are predefined by the assembler. Where the value field is empty, the symbol is a Boolean value and the meaning column describes when its value is {TRUE}.

Table 6-3 Predefined macros

Name Value Meaning
{TARGET_ARCH_ARM} num The number of the ARM base architecture of the target processor irrespective of whether the assembler is assembling for ARM or Thumb.
{TARGET_ARCH_THUMB} num

The number of the Thumb base architecture of the target processor irrespective of whether the assembler is assembling for ARM or Thumb. The value is defined as zero if the target does not support Thumb.

{TARGET_ARCH_XX}

XX represents the target architecture and its value depends on the target processor. For example, if you specify the assembler option --cpu=4T or --cpu=ARM7TDMI then {TARGET_ARCH_4T} is defined.

{TARGET_FEATURE_EXTENSION_REGISTER_COUNT} num

The number of 64-bit extension registers available in NEON or VFP.

{TARGET_FEATURE_CLZ}

If the target processor supports the CLZ instruction (that is, ARMv5T and later except ARMv6-M).

{TARGET_FEATURE_DIVIDE}

If the target processor supports the hardware divide instructions SDIV and UDIV.

{TARGET_FEATURE_DOUBLEWORD}

If the target processor supports the LDRD and STRD instructions (that is, ARMv5TE and later except ARMv6-M).

{TARGET_FEATURE_DSPMUL}

If the DSP-enhanced multiplier (for example the SMLAxy instruction) is available, for example in ARMv5TE.

{TARGET_FEATURE_MULTIPLY}

If the target processor supports the long multiply instructions SMULL, SMLAL, UMULL, and UMLAL (that is, all architectures except ARMv6-M).

{TARGET_FEATURE_MULTIPROCESSING}

If assembling for a target processor with ARMv7 Multiprocessing Extensions.

{TARGET_FEATURE_NEON}

If the target processor has NEON.

{TARGET_FEATURE_NEON_FP16}

If the target processor has NEON with half-precision floating-point operations.

{TARGET_FEATURE_NEON_FP32}

If the target processor has NEON with single-precision floating-point operations.

{TARGET_FEATURE_NEON_INTEGER}

If the target processor has NEON with integer operations.

{TARGET_FEATURE_UNALIGNED}

If the target processor has support for unaligned access (that is, architectures ARMv6 and later except ARMv6-M).

{TARGET_FPU_SOFTVFP} If assembling with the option --fpu=SoftVFP.
{TARGET_FPU_SOFTVFP_VFP}

If assembling for a target processor with softvfp and VFP hardware, for example --fpu=SoftVFP+VFPv3.

{TARGET_FPU_VFP}

If assembling for a target processor with VFP hardware, without using SoftVFP, for example --fpu=VFPv3.

{TARGET_FPU_VFPV2} If assembling for a target processor with VFPv2.
{TARGET_FPU_VFPV3} If assembling for a target processor with VFPv3.
{TARGET_FPU_VFPV4} If assembling for a target processor with VFPv4.
{TARGET_PROFILE_A} If assembling for a Cortex™-A profile processor, for example, if you specify the assembler option --cpu=7-A.
{TARGET_PROFILE_M} If assembling for a Cortex-M profile processor, for example, if you specify the assembler option --cpu=7-M.
{TARGET_PROFILE_R} If assembling for a Cortex-R profile processor, for example, if you specify the assembler option --cpu=7-R.

The following table shows the possible values for {TARGET_ARCH_ARM} and {TARGET_ARCH_THUMB}, and for XX in the TARGET_ARCH_XX built-in variables. It also shows how these values relate to versions of the ARM architecture.

Table 6-4 {TARGET_ARCH_ARM} in relation to {TARGET_ARCH_THUMB}

ARM architecture {TARGET_ARCH_ARM} {TARGET_ARCH_THUMB} xx
v4 4 0 4
v4T 4 1 4T
v5T 5 2 5T
v5TE 5 2 5TE
v5TEJ 5 2 5TEJ
v6 6 3 6
v6K 6 3 6K
v6Z 6 3 6Z
v6T2 6 4 6T2
v6-M 0 3 6_M
v6S-M 0 3 6S_M
v7-A 7 4 7_A
v7-R 7 4 7_R
v7-M 0 4 7_M
v7E-M 0 4 7E_M
Non-ConfidentialPDF file icon PDF versionARM DUI0473M
Copyright © 2010-2016 ARM Limited or its affiliates. All rights reserved.