 | Technical Support |  |
|
|
Technical Support Support Resources Product Information | C51: EXTERN VARS AND INLINE ASSEMBLY
Information in this article applies to:
QUESTIONI am using inline assembly. Included in the C file in which the inline assembly resides is a header file (.H) that contains EXTERN declarations for variables declared in other modules. When I try to build the project, I receive either UNDEFINED SYMBOL or REDEFINED SYMBOL errors pointing to the EXTERNS. Is there an example of the correct way to accomplish this? ANSWERYes. - Create a project with the following files:
MAIN.CM
#pragma SRC(MAIN.A51)
#include "xdatinc.h"
void main(void) {
ioport=0x55;
while(1) {
ioport+=2;
#pragma asm
inc r0 // this is just here to add inline asm to the mix..
#pragma endasm
}
}
INCFILE.H
extern xdata unsigned char ioport;
INCFILE.C
xdata unsigned char ioport _at_ 0x8000
- Create a project file and add the following files in the following order.
- MAIN.C
- MAIN.A51 (create when MAIN.C is compiled)
- INCFILE.C
- Turn off the "Include in Link/LIB" checkbox for MAIN.C. Turn ON the "Always Build" checkbox for both MAIN.C AND MAIN.A51
- Build the project. There should be no errors.
Last Reviewed: Saturday, July 09, 2005
|
|