The
-La option translates specified parts of header files into an include file to import labels and defines into an assembler source. Because the
-La compiler option is very powerful, its incorrect use must be avoided using the following guidelines implemented in a real project. This section describes how the programmer uses this option to combine C and assembler sources, both using common header files.
The following general implementation recommendations help to avoid problems when writing software using the common header file technique.
- All interface memory reservations or definitions must be made in C source files. Memory areas, only accessed from assembler files, can still be defined in the common assembler manner.
- Compile only C header files (and not the C source files) with the
-La option to avoid multiple defines and other problems. The project-related makefile must contain an inference rules section that defines the C header files-dependent include files to be created.
- Use
#pragma CREATE_ASM_LISTING ON/OFF only in C header files. This #pragma selects the objects to translate to the assembler include file. The created assembler include file then holds the corresponding assembler directives.
- Do not use the
-La option as part of the command line options used for all compilations. Use this option in combination with the
-Cx (no Code Generation) compiler option. Without this option, the compiler creates an object file which could accidently overwrite a C source object file.
- Remember to extend the list of dependencies for assembler sources in your make file.
- Check if the compiler-created assembler include file is included into your assembler source.
Note:
In case of a zero-page declared object (if this is supported by the target), the compiler translates it into an
XREF.B directive for the base address of a variable or constant. The compiler translates structure fields in the zero page into an
EQU.B directive in order to access them. Explicit zero-page addressing syntax may be necessary as some assemblers use extended addresses to
EQU.B defined labels. Project-defined data types must be declared in the C header file by including a global project header (e.g.,
global.h). This is necessary as the header file is compiled in a standalone fashion.