| |||
| Home > Using the Assembler > Using the C preprocessor | |||
You can use C preprocessor commands in your assembly language
source file. If you do this, you must use the --cpreproc command
line option when invoking the assembler. This causes armasm to
call armcc to preprocess the file before assembling
it.
armasm looks for the armcc binary
in the same directory as the armasm binary.
If it does not find the binary, it expects it to be on the PATH.
armasm passes certain options to armcc if
present on the command line. These are shown in Table 25. Some of these
options are converted to the armcc equivalent
before passing to armcc. These are shown in Table 26.
Table 25. Command-line options
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
To pass other simple compiler options, such as the preprocessor
option -D, you must use the --cpreproc_opts command
line option. armasm correctly interprets the
preprocessed #line commands. It can generate
error messages and debug_line tables using the
information in the #line commands.
Example 22 shows the
commands you write to preprocess and assemble a file, source.s.
The example also passes the compiler options to define a macro called
RELEASE, and to undefine a macro called ALPHA.
Example 22. Preprocessing an assembly language source file
armasm --cpreproc --cpreproc_opts=-D,RELEASE,-U,ALPHA source.s
If you want to use complex preprocessor options, you must
manually call armcc to preprocess the file
before calling armasm. Example 23 shows the commands you write to manually preprocess
and assemble a file, source.s. In this example,
the preprocessor outputs a file called preprocessed.s,
and armasm assembles preprocessed.s.
Example 23. Preprocessing an assembly language source file manually
armcc -E source.s > preprocessed.s armasm preprocessed.s
Using the Compiler:
Assembler Reference: