<?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>Variable and IF</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/27862/variable-and-if</link><description> 
i m working in C using Keil 3.55a 

 
how can i define a one bit variable 

 
and how can i compare two bits using if 

 
how can i set or clear Bit 

 
and how can i get the compliment of one byte or one bit, like in
ASM CPL A or CPL c 
 </description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Variable and IF</title><link>https://community.arm.com/thread/104901?ContentTypeID=1</link><pubDate>Tue, 31 May 2011 04:30:12 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5a00e89b-fdd2-4ffd-98ac-4d57c0b2e720</guid><dc:creator>raji k</dc:creator><description>&lt;p&gt;&lt;p&gt;
Neil,&lt;/p&gt;

&lt;p&gt;
Sorry for wrong post, In my next post I have tried to regret
that.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Variable and IF</title><link>https://community.arm.com/thread/91011?ContentTypeID=1</link><pubDate>Tue, 31 May 2011 04:23:13 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f4576ba4-d9e8-4fe7-80a7-39a3ce8e7ffb</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;Use #define&lt;/i&gt;&lt;/p&gt;

&lt;pre&gt;
#define glcd_SCK        4
#define glcd_SDIN       3
#define glcd_DC         2
#define glcd_SCE        1
#define glcd_RST        0
&lt;/pre&gt;

&lt;p&gt;
&lt;b&gt;Incorrect! That does &lt;i&gt;not&lt;/i&gt; define &lt;i&gt;one-bit&lt;/i&gt;
variables!&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
It does not, in fact, define any &lt;i&gt;variables&lt;/i&gt; at all!&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Variable and IF</title><link>https://community.arm.com/thread/104895?ContentTypeID=1</link><pubDate>Tue, 31 May 2011 04:21:36 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:71daffea-90be-46f0-862a-49a85af75c61</guid><dc:creator>raji k</dc:creator><description>&lt;p&gt;&lt;p&gt;
I agree with Neil.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Variable and IF</title><link>https://community.arm.com/thread/79326?ContentTypeID=1</link><pubDate>Tue, 31 May 2011 04:20:23 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:18729d31-b53d-4837-a6bf-3b214d359096</guid><dc:creator>raji k</dc:creator><description>&lt;p&gt;&lt;p&gt;
sorry for wrong answer,&lt;br /&gt;
The answer for the 1st one should be the following:&lt;/p&gt;

&lt;pre&gt;
sbit lcd_SCK=P0^4;
sbit lcd_SDIN=P0^3;
sbit lcd_DC=P0^2;
sbit lcd_SCE=P0^1;
sbit lcd_RST=P0^0;
&lt;/pre&gt;

&lt;p&gt;
sbit is for single bit declaration.&lt;/p&gt;

&lt;p&gt;
regards,&lt;br /&gt;
yateesh k&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Variable and IF</title><link>https://community.arm.com/thread/66632?ContentTypeID=1</link><pubDate>Tue, 31 May 2011 04:20:12 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f8a2ae55-4c99-49fe-8f7a-cc8205d4e663</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
So you&amp;#39;ve decided to give up on Assembler?&lt;/p&gt;

&lt;p&gt;
&lt;a href="http://www.keil.com/forum/18966/"&gt;http://www.keil.com/forum/18966/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
&lt;a href="http://www.keil.com/forum/18966/"&gt;http://www.keil.com/forum/18966/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
So now you need to learn the &amp;#39;C&amp;#39; programming language, and the
specific extensions for the 8051 provided by Keil&amp;#39;s C51
implementation.&lt;/p&gt;

&lt;p&gt;
&amp;#39;C&amp;#39; is a very widely-used and long-established languages - there&amp;#39;s
a vast wealth of books, sites, and training courses available to help
you to learn the language; eg,&lt;/p&gt;

&lt;p&gt;
&lt;a href="http://www.keil.com/books/"&gt;http://www.keil.com/books/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
&lt;a href="http://www.keil.com/events/"&gt;http://www.keil.com/events/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
&lt;a href="http://publications.gbdirect.co.uk/c_book/"&gt;publications.gbdirect.co.uk/.../&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
&lt;a href="http://www.eskimo.com/~scs/cclass/"&gt;www.eskimo.com/.../&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;
For Details of Keil products - including full &lt;b&gt;manuals&lt;/b&gt; -
see: &lt;a href="http://www.keil.com/support/"&gt;http://www.keil.com/support/&lt;/a&gt;&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Variable and IF</title><link>https://community.arm.com/thread/59473?ContentTypeID=1</link><pubDate>Tue, 31 May 2011 04:17:34 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:835bd060-e7e7-4507-92dc-cd215a3514b6</guid><dc:creator>raji k</dc:creator><description>&lt;p&gt;&lt;p&gt;
1.how can i define a one bit variable&lt;br /&gt;
A:&lt;/p&gt;

&lt;p&gt;
Use #define&lt;/p&gt;

&lt;pre&gt;
#define glcd_SCK        4
#define glcd_SDIN       3
#define glcd_DC         2
#define glcd_SCE        1
#define glcd_RST        0
&lt;/pre&gt;

&lt;p&gt;
2.How can i compare two bits using if&lt;br /&gt;
A:&lt;/p&gt;

&lt;p&gt;
if(bit1 operator bit2)&lt;/p&gt;

&lt;p&gt;
3.How can i set or clear Bit&lt;br /&gt;
A:&lt;/p&gt;

&lt;pre&gt;
   bit=0; // for clearing
   bit=1; // for setting
&lt;/pre&gt;

&lt;p&gt;
4.How can i get the compliment of one byte or one bit, like in ASM
CPL A or CPL c&lt;br /&gt;
A: Use ^ operator.&lt;/p&gt;

&lt;pre&gt;
byte^=(1&amp;lt;&amp;lt;bit_pos);  // complements the bit in the &amp;quot;bit_pos&amp;quot; bit position.
bit=(~bit);          // complements the bit
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>