<?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>IAP checksum read</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/42800/iap-checksum-read</link><description> Hi, 
 
I&amp;#39;m using the P89LPC932A1 and attempting to read the global checksum using IAP during normal program execution. I have used this knowledgebase article as my guide: 
 
 http://www.keil.com/support/docs/2554.htm 
 
So basically, I added this function</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: IAP checksum read</title><link>https://community.arm.com/thread/97999?ContentTypeID=1</link><pubDate>Mon, 17 Apr 2006 19:05:11 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f12e595a-d277-4c9c-adf7-671bada758e0</guid><dc:creator>Philip Garman</dc:creator><description>&lt;p&gt;Ouch.  Didn&amp;#39;t spot this.  I think this knowledgebase article has a typo:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;
long unsigned IAP_ReadGlobalCRC (void)

should be

unsigned long IAP_ReadGlobalCRC (void)
&lt;/pre&gt;
&lt;br /&gt;
After chaning, the code looks like it compiles correctly to:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;
             ; FUNCTION IAP_ReadGlobalCRC (BEGIN)
                                           ; SOURCE LINE # 80
                                           ; SOURCE LINE # 81
                                           ; SOURCE LINE # 82
0000 7406              MOV     A,#06H
                                           ; SOURCE LINE # 83
0002 12FF03            LCALL   0FF03H
                                           ; SOURCE LINE # 84
0005         ?C0007:
0005 22                RET
             ; FUNCTION IAP_ReadGlobalCRC (END)
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: IAP checksum read</title><link>https://community.arm.com/thread/73968?ContentTypeID=1</link><pubDate>Mon, 17 Apr 2006 18:50:42 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:59ac93f7-5e73-4605-9f32-513152ff138b</guid><dc:creator>Philip Garman</dc:creator><description>&lt;p&gt;Thank you for replying to my thread.  I think I might be &amp;quot;seeing the light&amp;quot;.  Below, I have posted what this compiles to.&lt;br /&gt;
&lt;br /&gt;
Basically it seems that after LCALL FF03, the 32-bit result should be in R4-R7 with the MSB being in R4.  But this code looks like it overwrites R4-R6 with 00&amp;#39;s and then leaves R7 as is.  This would explain why I get 0x000000XX as the return value.&lt;br /&gt;
&lt;br /&gt;
However, I&amp;#39;m a bit confused by this c code to begin with.  First, why would Keil say that this is the way to do it when the compiler generates code that overwrites the true result.  How *should* this be done using c?&lt;br /&gt;
&lt;br /&gt;
Much Thanks&lt;br /&gt;
Philip&lt;br /&gt;
&lt;br /&gt;
This is what it compiles to in my project:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;
             ; FUNCTION IAP_ReadGlobalCRC (BEGIN)
                                           ; SOURCE LINE # 80
                                           ; SOURCE LINE # 81
                                           ; SOURCE LINE # 82
0000 7406              MOV     A,#06H
                                           ; SOURCE LINE # 84
0002 12FF03            LCALL   0FF03H
0005 E4                CLR     A
0006 FC                MOV     R4,A
0007 FD                MOV     R5,A
0008 FE                MOV     R6,A
                                           ; SOURCE LINE # 85
0009         ?C0007:
0009 22                RET
             ; FUNCTION IAP_ReadGlobalCRC (END)
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: IAP checksum read</title><link>https://community.arm.com/thread/45902?ContentTypeID=1</link><pubDate>Mon, 17 Apr 2006 17:56:07 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:bd3f038d-555c-4ad5-bf86-a4b43599cda4</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;pre&gt;  return ((unsigned char (code *)(void)) 0xFF03)(); // LJMP 0FF03H&lt;/pre&gt;
Is this actually &lt;i&gt;guaranteed&lt;/i&gt; to compile to an LJMP? Could it not give an LCALL - unless common tail merge optimisation is enabled?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>