<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>how to use a bit variable  defined in another module?</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/16980/how-to-use-a-bit-variable-defined-in-another-module</link><description> 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</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: how to use a bit variable  defined in another module?</title><link>https://community.arm.com/thread/145874?ContentTypeID=1</link><pubDate>Wed, 31 Dec 2003 22:59:05 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:0a5a65ac-9f7c-43e9-a3ad-f7365bc64aaf</guid><dc:creator>Angus  John</dc:creator><description>&lt;p&gt;Dear Jim:&lt;br /&gt;
Thank you very much.^_^ It is done again.&lt;br /&gt;
and thank you once  more.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to use a bit variable  defined in another module?</title><link>https://community.arm.com/thread/145881?ContentTypeID=1</link><pubDate>Wed, 31 Dec 2003 07:23:59 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:deb98b33-20da-4dc1-a3f4-9f8a1b3b704e</guid><dc:creator>Jim King</dc:creator><description>&lt;p&gt;You can put them into the header file and include it in your asm files.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to use a bit variable  defined in another module?</title><link>https://community.arm.com/thread/143931?ContentTypeID=1</link><pubDate>Wed, 31 Dec 2003 05:56:39 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:55b3072b-9f1b-4eee-89a2-c5dd62e29c84</guid><dc:creator>Angus  John</dc:creator><description>&lt;p&gt;Dear Jim:&lt;br /&gt;
Thank you for helping me with this problem.&lt;br /&gt;
Now I&amp;#39;ve got another qustion that:&lt;br /&gt;
in my main.c flie,I define as follows:&lt;br /&gt;
sbit sda = P1^1;&lt;br /&gt;
sbit scl = P1^2;&lt;br /&gt;
&lt;br /&gt;
Now I wanna use sda &amp;amp; scl in my assem.asm file,how to declare them? I have tried these:&lt;br /&gt;
extrn bit(sda);extrn bit(scl);&lt;br /&gt;
but failed.:(&lt;br /&gt;
&lt;br /&gt;
So is it possible?If yes,then how?&lt;br /&gt;
expecting your reply.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to use a bit variable  defined in another module?</title><link>https://community.arm.com/thread/141326?ContentTypeID=1</link><pubDate>Tue, 30 Dec 2003 21:35:50 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a1e6c0a6-9f9a-4aa2-8aec-92724dda22e4</guid><dc:creator>Angus  John</dc:creator><description>&lt;p&gt;Dear Jim,thank you so much from China West Lake.^_^&amp;amp;#65292;I have compiled it successfully too&amp;amp;#12290;^_^Appreciate you&amp;amp;#12290;&lt;br /&gt;
Thank God&amp;amp;#65292;It is done&amp;amp;#12290;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to use a bit variable  defined in another module?</title><link>https://community.arm.com/thread/141320?ContentTypeID=1</link><pubDate>Tue, 30 Dec 2003 20:40:18 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:9f874bfd-54d2-4079-92b6-593c99d662a1</guid><dc:creator>Jim King</dc:creator><description>&lt;p&gt;Sorry,John.Now I have compiled it successfully.It will be right,I think.&lt;br /&gt;
&lt;pre&gt;
//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__
&lt;/pre&gt;
&lt;br /&gt;
Then put the two lines into your C file.&lt;br /&gt;
&lt;pre&gt;
//my.c
unsigned char bdata flags;
sbit red_flag = flags^1;
&lt;/pre&gt;
Then #include the .h file in your asm files.It will be OK.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to use a bit variable  defined in another module?</title><link>https://community.arm.com/thread/137793?ContentTypeID=1</link><pubDate>Tue, 30 Dec 2003 19:59:06 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:4405815e-cffe-49ec-af30-639d24cd2042</guid><dc:creator>Angus  John</dc:creator><description>&lt;p&gt;Thank you,Jim.&lt;br /&gt;
I am reading Cx51.pdf.I am going to that after I finish Cx51.pdf.^_^&lt;br /&gt;
Thank you once more.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to use a bit variable  defined in another module?</title><link>https://community.arm.com/thread/129835?ContentTypeID=1</link><pubDate>Tue, 30 Dec 2003 18:07:09 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:9932382b-417e-4b06-97df-6911f0f2fba0</guid><dc:creator>Jim King</dc:creator><description>&lt;p&gt;A51.pdf, P131&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to use a bit variable  defined in another module?</title><link>https://community.arm.com/thread/122240?ContentTypeID=1</link><pubDate>Tue, 30 Dec 2003 11:09:05 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:dedb25e4-02f3-483f-b827-a6d5e753b531</guid><dc:creator>Angus  John</dc:creator><description>&lt;p&gt;&amp;quot;See the spec please. &amp;quot;&lt;br /&gt;
Which spec?GS51.pdf?Cx51.pdf?A51.pdf?&lt;br /&gt;
I have read GS51.pdf.But didn&amp;#39;t see anything about this.Let me check it again.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to use a bit variable  defined in another module?</title><link>https://community.arm.com/thread/110676?ContentTypeID=1</link><pubDate>Tue, 30 Dec 2003 11:05:52 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:743d22fe-3224-4b2d-8a4e-24ec5a48d983</guid><dc:creator>Angus  John</dc:creator><description>&lt;p&gt;Dear Jim,&lt;br /&gt;
oh&amp;amp;#65292;my&amp;amp;#65281;I copied your code to my project&amp;amp;#12290;But it didn&amp;#39;t work!&lt;br /&gt;
&lt;pre&gt;extrn DATA:BYTE(flags);//ILLEGAL USE OF A RESERVED WORD;
sbit red_flag = flags^1;//INAVLID SIMPLE RELOCATABLE EXPRESSION;&lt;/pre&gt;
Is there something I do wrong ,or something else??&lt;br /&gt;
Expecting your reply.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to use a bit variable  defined in another module?</title><link>https://community.arm.com/thread/96007?ContentTypeID=1</link><pubDate>Tue, 30 Dec 2003 08:04:41 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:0b6c2e27-8160-4eb7-8306-06723af793c5</guid><dc:creator>Jim King</dc:creator><description>&lt;p&gt;Oh,sorry.The extrn directive can be written like this:&lt;br /&gt;
&lt;pre&gt;
//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&amp;#39;t put this line to C source files

#ifdef __C51__
//C function prototype
void TextOut (BYTE byChar);
#endif //__C51__

#endif //__MY_H__
&lt;/pre&gt;
See the spec please.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to use a bit variable  defined in another module?</title><link>https://community.arm.com/thread/72170?ContentTypeID=1</link><pubDate>Tue, 30 Dec 2003 02:48:21 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:591599c4-6c36-4032-bea8-fbe5177c3f2c</guid><dc:creator>Angus  John</dc:creator><description>&lt;p&gt;Dear Jim&amp;amp;#65306;&lt;br /&gt;
I have tried&amp;amp;#65292;but failed&amp;amp;#12290;&amp;amp;#65306;&amp;amp;#65288;&lt;br /&gt;
no head file is included in c program.&lt;br /&gt;
The head file in assem.asm is as follows&amp;amp;#65306;&lt;br /&gt;
&lt;pre&gt;
#ifndef __MY_H__
#define    __MY_H__
&amp;amp;#65293;&amp;gt;extrn unsigned char bdata flags;
   sbit red_flag = flags^1;
#endif __MY_H__
&lt;/pre&gt;
but Keil told me this:&lt;br /&gt;
error A24:SEGMENT TYPE EXPECTED&lt;br /&gt;
error A35:&amp;#39;(&amp;#39; EXPECTED&lt;br /&gt;
error A34:&amp;#39;,&amp;#39; EXPECTED&lt;br /&gt;
error A17:INVALID BYTE BASE IN BIT ADDRESS EXPRESSION&lt;br /&gt;
warning A232:new line expected,extra characters found&lt;br /&gt;
I am confused.Don&amp;#39;t know why.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to use a bit variable  defined in another module?</title><link>https://community.arm.com/thread/41452?ContentTypeID=1</link><pubDate>Tue, 30 Dec 2003 01:30:54 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:6081b07f-e37a-45db-b942-37c8d3808793</guid><dc:creator>Angus  John</dc:creator><description>&lt;p&gt;thank you.Jim King.Let me have a try first.^_^&amp;amp;#65292;I&amp;#39;ll tell you the result later&amp;amp;#12290;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to use a bit variable  defined in another module?</title><link>https://community.arm.com/thread/41454?ContentTypeID=1</link><pubDate>Tue, 30 Dec 2003 00:49:55 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:2d00f596-4cd1-4509-86c9-91479aa99adc</guid><dc:creator>Jim King</dc:creator><description>&lt;p&gt;If you want to write mixed program,you can write the header files like this:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;
//my.h
#ifndef __MY_H__
#define __MY_H__

//Declaration
extrn unsigned char bdata flags;
sbit red_flag = flags^1;//Don&amp;#39;t put this line to C source files

#ifdef __C51__
//C function prototype
void TextOut (BYTE byChar);
#endif //__C51__

#endif //__MY_H__
&lt;/pre&gt;
&lt;br /&gt;
Then you can include it in your asm files.&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;
;assem.asm
#include &amp;quot;my.h&amp;quot;

mov ...
clr ...
...
&lt;/pre&gt;
&lt;br /&gt;
A51 supports all the preprocessors of C51.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>