<?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>Using Pointer</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/15370/using-pointer</link><description> Please could some body take a look at 
my code to see why the Pointer variables 
do not display correctly using debug in 
Uvision2. 
 
Here is the code: 
 
unsigned int xdata VALUE; 
unsigned int xdata *addr = &amp;amp;VALUE; 
 
Main() 
{ 
 for (VALUE=1; VALUE</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Using Pointer</title><link>https://community.arm.com/thread/39273?ContentTypeID=1</link><pubDate>Mon, 14 Oct 2002 10:17:44 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:678391cc-ef16-42a4-bf3d-6a591306b071</guid><dc:creator>Mark Odell</dc:creator><description>&lt;p&gt;For this reason, ISO C stipulates that one should use the %p formatter for printing pointers. It&amp;#39;s easy to remember since p is for pointer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using Pointer</title><link>https://community.arm.com/thread/121820?ContentTypeID=1</link><pubDate>Mon, 14 Oct 2002 06:25:32 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:e40cbd21-180c-4628-aded-adc6f4835d47</guid><dc:creator>John Donaldson</dc:creator><description>&lt;p&gt;&amp;quot;Nonsense!&lt;br /&gt;
See p291 of the 09.2001 C51 manual&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Charming, I&amp;#39;m sure.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using Pointer</title><link>https://community.arm.com/thread/121821?ContentTypeID=1</link><pubDate>Mon, 14 Oct 2002 04:44:44 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:68a171c7-fb6b-4105-9717-20e6387ac1f2</guid><dc:creator>Mik Kleshov</dc:creator><description>&lt;p&gt;Fair enough. I overlooked that option.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using Pointer</title><link>https://community.arm.com/thread/110115?ContentTypeID=1</link><pubDate>Sun, 13 Oct 2002 16:40:55 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5c4d3196-11ad-48a4-b90e-6f7c36f81148</guid><dc:creator>Andrew Neil</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;printf does not know how to print out pointers&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Nonsense!&lt;br /&gt;
See p291 of the 09.2001 C51 manual:&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&amp;quot;The &lt;/i&gt;type&lt;i&gt; field is a single character that specifies whether the argument is interpreted as a character, string, number, &lt;/i&gt;&lt;b&gt;or pointer&lt;/b&gt;&lt;i&gt;, as shown in the following table...&lt;br /&gt;
&amp;quot;&lt;b&gt;p generic *&lt;/b&gt; Pointer using the format &lt;/i&gt;t:aaaa&lt;i&gt; where t is the memory type the&lt;br /&gt;
pointer references (c: code, i: data/idata, x: xdata, p: pdata) and aaaa is the hexadecimal address&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using Pointer</title><link>https://community.arm.com/thread/95195?ContentTypeID=1</link><pubDate>Sat, 12 Oct 2002 06:33:24 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c565f069-c2f9-4403-a937-151afeaff8b8</guid><dc:creator>Mik Kleshov</dc:creator><description>&lt;p&gt;&lt;b&gt;printf&lt;/b&gt; does not know how to print out &lt;i&gt;pointers&lt;/i&gt;, but it knows how to print out &lt;i&gt;integers&lt;/i&gt;. Hence, you need to convert your pointer to integer and then you can pass it to &lt;b&gt;printf&lt;/b&gt;:&lt;br /&gt;
&lt;pre&gt;
printf(&amp;quot;addr1 = %d&amp;quot;, (int)addr); //address1
printf(&amp;quot;addr2 = %d&amp;quot;, (int)&amp;amp;VALUE); //address2
&lt;/pre&gt;
I don&amp;#39;t know what 8051 xdata pointers look like, so I&amp;#39;m not sure if all the information contained in the pointer is preserved during conversion to &lt;b&gt;int&lt;/b&gt;. Maybe you will have to convert them to &lt;b&gt;long&lt;/b&gt;. Try both.&lt;br /&gt;
- Mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using Pointer</title><link>https://community.arm.com/thread/54740?ContentTypeID=1</link><pubDate>Fri, 11 Oct 2002 23:30:58 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:bd3f5b48-fced-4441-829d-bfa0a097a4c5</guid><dc:creator>Jimmy   S</dc:creator><description>&lt;p&gt;Could you be more specific of which &lt;br /&gt;
parameter I should use with the pointers&lt;br /&gt;
in conjunction with printf statement.&lt;br /&gt;
&lt;br /&gt;
I have read manual several times but&lt;br /&gt;
I still don&amp;#39;t get it.&lt;br /&gt;
&lt;br /&gt;
Regards,&lt;br /&gt;
&lt;br /&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using Pointer</title><link>https://community.arm.com/thread/39267?ContentTypeID=1</link><pubDate>Fri, 11 Oct 2002 17:12:40 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b6b59a00-f34a-4e5e-a7a1-3b754bb09738</guid><dc:creator>Andrew Neil</dc:creator><description>&lt;p&gt;Please read the &amp;quot;Tips for Posting Messages&amp;quot; before you post a message - particularly the bit about using &amp;#39;pre&amp;#39; and &amp;#39;/pre&amp;#39; tags when posting source code!&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;addr&lt;/b&gt; and &lt;b&gt;&amp;amp;VALUE&lt;/b&gt; are &lt;b&gt;&lt;i&gt;pointers&lt;/i&gt;&lt;/b&gt;, but the &lt;b&gt;%d&lt;/b&gt; printf format expects an &lt;b&gt;int&lt;/b&gt; - you can&amp;#39;t expect to get the right results if you supply the wrong sort of argument!&lt;br /&gt;
&lt;br /&gt;
Go back to the &lt;b&gt;manual&lt;/b&gt; and carefully read the sections on pointers and the printf formats.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>