<?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>bitwise operation</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/21932/bitwise-operation</link><description> 
hello, 
i m implementing a pc keyboard logic. 
pc keboard signals are transmitted serially to port pin. 
i want to know how to do bitwise shifting in &amp;#39;c&amp;#39; for reception as
well as for transmission to get the data present on port pin. 
i did it in assembly</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: bitwise operation</title><link>https://community.arm.com/thread/51534?ContentTypeID=1</link><pubDate>Mon, 25 Feb 2008 09:38:02 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:056de26f-3e36-451b-ad43-fd80f105c597</guid><dc:creator>Drew Davis</dc:creator><description>&lt;p&gt;&lt;p&gt;
Keil C51 has intrinsic library functions for rotate. See _crol_,
_cror_, _iror/l_, _lror/l_.&lt;/p&gt;

&lt;p&gt;
Take another look at your 8051 architecture manual. Port pins are
generally bit-addressable. (SFRs whose addresses end in x0 or x8 are
bit-addressable.) You can test and set the bits directly, without
having to rotate a byte into the carry. Instead of doing a rotate,
branch if carry, simply do an &amp;quot;if (bit)&amp;quot;.&lt;/p&gt;

&lt;p&gt;
It&amp;#39;s possible, but unwise, to directly access CPU registers such
as the ACC or CY from C. The code generator allocates and uses those
registers for its own purposes, and you have no guarantees on its
behavior. Even if you peek at the generated code, there&amp;#39;s no
assurance the pattern will remain exactly the same in the next
version of the compiler, or even if you change the source.&lt;/p&gt;

&lt;p&gt;
On the bright side, you generally don&amp;#39;t need to access those
registers from C anyway.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: bitwise operation</title><link>https://community.arm.com/thread/51540?ContentTypeID=1</link><pubDate>Sat, 23 Feb 2008 04:45:07 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:9edef280-2f97-4955-93d1-fbf96969090d</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
Pick up a decent book on the C language and/or get the language
standard.&lt;/p&gt;

&lt;p&gt;
No rotate in the language. Possibly in the runtime library for the
specific compiler.&lt;/p&gt;

&lt;p&gt;
Shift built into the language.&lt;/p&gt;

&lt;p&gt;
No access to any carry or shifted-out bits unless you use
assembler.&lt;/p&gt;

&lt;pre&gt;
a &amp;lt;&amp;lt;= 1; // shift a one step left
a = a &amp;lt;&amp;lt; 1; // long form of above
a &amp;gt;&amp;gt;= 1; // shift a one step right
a = a &amp;gt;&amp;gt; 1; // long form of above
a = (a &amp;lt;&amp;lt; 1) | 1; // shift in a new bit at low side
a = (a &amp;gt;&amp;gt; 1) | 0x80; // shift in a new bit to the right (8-bit logic)
if (a &amp;amp; 1) ; // test if bit is set
&lt;/pre&gt;

&lt;p&gt;
Most serial communication is done using hardware devices in the
chips, i.e. without the need to shift any bits. Different chips have
different hardware for asynchronous or (in this case) synchronous
data transfers built in. Receiving serial data in software requires
that your program is ready for every single bit. You must either poll
the clock signal contnuously or use an interrupt.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>