<?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 printf()s work under C51?</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/14144/how-printf-s-work-under-c51</link><description> Can any body tell me how printf() and the likes work under C51? If I don&amp;#39;t have a display device, where does the output go? If I don&amp;#39;t have a kernel and still want to use the functions and redirect the output to the serial port what should I implement</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: How printf()s work under C51?</title><link>https://community.arm.com/thread/84077?ContentTypeID=1</link><pubDate>Sat, 07 Apr 2001 17:38:14 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:22a6aee2-dc30-4057-b3d5-8c3fadbb56eb</guid><dc:creator>Alex Ruiz</dc:creator><description>&lt;p&gt;&lt;i&gt;We don&amp;#39;t really need to know how printf does its magic&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
It depends on the viewpoint, I don&amp;#39;t belive in magic... ;-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How printf()s work under C51?</title><link>https://community.arm.com/thread/53601?ContentTypeID=1</link><pubDate>Sat, 07 Apr 2001 14:34:09 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8bb997be-7a20-4dab-b447-c663eebe9767</guid><dc:creator>Andrew Neil</dc:creator><description>&lt;p&gt;&amp;lt;I&amp;gt;&amp;quot;It&amp;#39;s a pity the fact that Keil doesn&amp;#39;t have routines source code, just to glance, ( prinft.c, strcopy.c,... )&amp;lt;/I&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The standard library implementations for printf, etc, are available from many places.&lt;br /&gt;
We don&amp;#39;t really need to know how printf does its magic, just how to send the characters it generates to whatever our embedded platform supports.&lt;br /&gt;
That&amp;#39;s where putchar (and getkey) come in!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How printf()s work under C51?</title><link>https://community.arm.com/thread/37388?ContentTypeID=1</link><pubDate>Thu, 05 Apr 2001 08:00:09 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1194df26-b87b-4265-9105-dda9f50408a9</guid><dc:creator>Alex Ruiz</dc:creator><description>&lt;p&gt;By default, the &lt;i&gt;printf&lt;/i&gt; routine used to send data to the Video Interface ( monitor ), it&amp;#39;s true if we&amp;#39;re talking about &lt;i&gt;PCs&lt;/i&gt; and the like... &lt;br /&gt;
&lt;br /&gt;
In the &lt;i&gt;Embedded World&lt;/i&gt; ( C51, C251, etc... ) of course we don&amp;#39;t have a video interface/monitor, the available option to &lt;i&gt;input/output&lt;/i&gt; data is the serial channel, all the routines that usually send data to the monitor in a PC will work with the serial channel in the C51, so we can conclude that most of the I/O routines were rewrote to &lt;i&gt;input/output&lt;/i&gt; data from/to the &lt;b&gt;SBUF&lt;/b&gt; ( serial buffer ) using the best variable types for the C51 ( char  - 8bits architecture). So when we talk about embedded, now we know that data is sent to the serial interface.&lt;br /&gt;
&lt;br /&gt;
It&amp;#39;s a pity the fact that Keil doesn&amp;#39;t have routines source code, just to glance, &lt;i&gt;( prinft.c, strcopy.c,... )&lt;/i&gt; in a folder like Avcase do, so unfortunately you&amp;#39;ll not be able to glance at the sources to know exactly how they work . &lt;br /&gt;
&lt;br /&gt;
You can redirect the input/output to a place different than the serial channel, you can redirect to a LCD connected to the P1 ( Port 1 )  for example. &lt;br /&gt;
&lt;br /&gt;
The following files, &lt;b&gt;Putchar.c&lt;/b&gt; and &lt;b&gt;Getkey.c&lt;/b&gt; ( &lt;i&gt;C51\Lib&lt;/i&gt; folder ), determine where the I/O commands will place data, you can change them and redirect the &lt;i&gt;input/output&lt;/i&gt; to wherever you want, after rewriting the files you will need to add them together with your project files, like you do when you change the &lt;i&gt;startup.a51 .&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How printf()s work under C51?</title><link>https://community.arm.com/thread/37386?ContentTypeID=1</link><pubDate>Thu, 05 Apr 2001 07:34:23 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:46b0ea5f-851c-4396-aa08-f92e36db8958</guid><dc:creator>Keil Support</dc:creator><description>&lt;p&gt;All of the I/O routines (printf, scanf, puts, and so on) output characters using the putchar routine and input characters using the _getkey routine.  The source for each of these routines is provided.&lt;br /&gt;
&lt;br /&gt;
The default for putchar is to outout characters on the 8051&amp;#39;s serial port.&lt;br /&gt;
&lt;br /&gt;
The default for _getkey is to input characters on the 8051&amp;#39;s serial port.&lt;br /&gt;
&lt;br /&gt;
You may rewrite these routines, however, to send characters wherever you want.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Jon&lt;/b&gt;&lt;br /&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>