This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to use a bit variable defined in another module?

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
what should I do to let the keil know I want invoke the red_flag bit variable which is defined in main.c;how to declare it? The MCU I use is atmel at89s52.Thanks.
---going to mad.

Parents
  • 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__
    

    Then put the two lines into your C file.
    //my.c
    unsigned char bdata flags;
    sbit red_flag = flags^1;
    
    Then #include the .h file in your asm files.It will be OK.

Reply
  • 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__
    

    Then put the two lines into your C file.
    //my.c
    unsigned char bdata flags;
    sbit red_flag = flags^1;
    
    Then #include the .h file in your asm files.It will be OK.

Children
No data