Gentlemen: I wanna use a bit variable in file:assem.asm.And the bit variable is defined in another file:main.c;Just as follows:
in main.c unsigned char bdata flags; sbit red_flag = flags^1; in assem.asm
Oh,sorry.The extrn directive can be written like this:
//my.h #ifndef __MY_H__ #define __MY_H__ //Declaration #ifdef __C51__ extrn unsigned char bdata flags; #else EXTRN DATA:BYTE (flags) #endif sbit red_flag = flags^1;//Don't put this line to C source files #ifdef __C51__ //C function prototype void TextOut (BYTE byChar); #endif //__C51__ #endif //__MY_H__
Dear Jim, oh,my!I copied your code to my project。But it didn't work!
extrn DATA:BYTE(flags);//ILLEGAL USE OF A RESERVED WORD; sbit red_flag = flags^1;//INAVLID SIMPLE RELOCATABLE EXPRESSION;
"See the spec please. " Which spec?GS51.pdf?Cx51.pdf?A51.pdf? I have read GS51.pdf.But didn't see anything about this.Let me check it again.
A51.pdf, P131
Thank you,Jim. I am reading Cx51.pdf.I am going to that after I finish Cx51.pdf.^_^ Thank you once more.
Sorry,John.Now I have compiled it successfully.It will be right,I think.
//my.h #ifndef __MY_H__ #define __MY_H__ //Declaration #ifdef __A51__ EXTRN DATA (flags) EXTRN BIT (red_flag) #else extern unsigned char bdata flags; extern bit red_flag; #endif #ifdef __C51__ //C function prototype void TextOut (BYTE byChar); #endif //__C51__ #endif //__MY_H__
//my.c unsigned char bdata flags; sbit red_flag = flags^1;
Dear Jim,thank you so much from China West Lake.^_^,I have compiled it successfully too。^_^Appreciate you。 Thank God,It is done。
Dear Jim: Thank you for helping me with this problem. Now I've got another qustion that: in my main.c flie,I define as follows: sbit sda = P1^1; sbit scl = P1^2; Now I wanna use sda & scl in my assem.asm file,how to declare them? I have tried these: extrn bit(sda);extrn bit(scl); but failed.:( So is it possible?If yes,then how? expecting your reply.
You can put them into the header file and include it in your asm files.
Dear Jim: Thank you very much.^_^ It is done again. and thank you once more.