A variable or constant defined in an assembly source file is accessible in an ANSI-C source file.
The variable or constant is defined in the assembly source file using the standard assembly syntax.
Variables and constants must be exported using the XDEF directive to make them visible from other modules, as listed in the following listing:
XDEF ASMData, ASMConst DataSec: SECTION ASMData: DS.W 1 ; Definition of a variable ConstSec: SECTION ASMConst: DC.W $44A6 ; Definition of a constant
We recommend that you generate a header file for each assembler source file. This header file should contain the interface to the assembly module.
An external declaration for the variable or constant must be inserted in the header file, , as listed in the following listing:
/* External declaration of a variable */ extern int ASMData; /* External declaration of a constant */ extern const int ASMConst;
The variables or constants can then be accessed in the usual way, using their names, , as listed in the following listing:
ASMData = ASMConst + 3;