3.2.4 Compilation of Assembly Source

Assembly source files that are part of a C project are compiled in a similar way to C source files. The compiler driver knows that these files should be passed to a different set of internal compiler applications and a single build command can contain a mix of C and assembly source files, as in the following example.

xc8-cc -mcpu=atmega3290p proj.c spi.s

If an assembly source file contains C preprocessor directives that must be preprocessed before passed to the assembler, then ensure the source file uses a .S extension, for example spi.S.

The compiler can be used to generate assembly files from C source code using the -S option. The assembly output can then be used as the basis for your own assembly routines and subsequently compiled using the command-line driver.