3.3 Command-line options for preprocessing assembly source code

The functionality of the --cpreproc and --cpreproc_opts command-line options in the version of armasm supplied with Arm® Compiler 6 is different from the options used in earlier versions of armasm to preprocess assembly source code.

If you are using armasm to assemble source code that requires the use of the preprocessor, you must use both the --cpreproc and --cpreproc_opts options together. Also:

  • As a minimum, you must include the armclang options --target and either -mcpu or -march in --cpreproc_opts.
  • The input assembly source must have an upper-case extension .S.

If you have existing source files, which require preprocessing, and that have the lower-case extension .s, then to avoid having to rename the files:

  1. Perform the pre-processing step manually using the armclang -x assembler-with-cpp option.
  2. Assemble the preprocessed file without using the --cpreproc and --cpreproc_opts options.

Example using armclang -x

This example shows the use of the armclang -x option.

armclang --target=aarch64-arm-none-eabi -march=armv8-a -x assembler-with-cpp -E test.s -o test_preproc.s
armasm --cpu=8-A.64 test_preproc.s

Example using armasm --cpreproc_opts

The options to the preprocessor in this example are --cpreproc_opts=--target=arm-arm-none-eabi,-mcpu=cortex-a9,-D,DEF1,-D,DEF2.

armasm --cpu=cortex-a9 --cpreproc --cpreproc_opts=--target=arm-arm-none-eabi,-mcpu=cortex-a9,-D,DEF1,-D,DEF2 -I /path/to/includes1 -I /path/to/includes2 input.S

Note:

Ensure that you specify compatible architectures in the armclang options --target, -mcpu or -march, and the armasm --cpu option.
Non-ConfidentialPDF file icon PDF versionDUI0742J
Copyright © 2014–2017, 2019 Arm Limited or its affiliates. All rights reserved.