3.2 Multi-step Assembly

A multi-step assembly method can be employed to achieve an incremental build of your project. Make utilities take note of which source files have changed since the last build and only rebuild these files to speed up assembly. From within MPLAB X IDE, you can select an incremental build (Build Project icon), or fully rebuild a project (Clean and Build Project icon).

Make utilities typically call the assembler multiple times: once for each source file to generate an intermediate file and once to perform the link step.

The option -c is used to create an intermediate file. This option stops after the assembler application has executed, and the resulting object output file will have a .o extension.

The intermediate files can then be specified to the driver during the second stage of compilation, when they will be passed to the linker.

The first two of the following command lines build an intermediate file for each assembly source file, then these intermediate files are passed to the driver again to be linked in the last command.

pic-as -mcpu=16F877A -c main.s
pic-as -mcpu=16F877A -c io.s
pic-as -mcpu=16F877A main.o io.o

As with any assembler, all the files that constitute the project must be present when performing the second (link) stage of compilation.

You might also wish to generate intermediate files to construct your own library files. See 7.1 Archiver/Librarian for more information on library creation.