<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>LPCXpresso IDE中的主题 Re: Regarding startup code</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/Regarding-startup-code/m-p/531229#M2401</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Rob65 on Tue Jul 12 00:03:58 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Sherry,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: sherrysamuel&lt;/STRONG&gt;&lt;BR /&gt;But "pullDest" is a local variable and as far I know it will not be allocated in .bss section.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes indeed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[I][B]As far as i know[/B][/I] you are right.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Good to see that there are still people who know how a compiler behaves (should behave...) :D&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rob&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Jun 2016 01:39:25 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-16T01:39:25Z</dc:date>
    <item>
      <title>Regarding startup code</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Regarding-startup-code/m-p/531226#M2398</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by sherrysamuel on Sun Jul 10 19:08:48 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am new to LPC xpresso. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I was going through the start up code. In the Reset routine I could find the loop where the data is copied to RAM. But below that I could find the comment regarding the initialization of variables in BSS segment:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; "// Zero fill the bss segment.&amp;nbsp; This is done with inline assembly since this&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // will clear the value of pulDest if it is not kept in a register."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you please explain why ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;What puzzles me more is why the code for copying the data variables to RAM is in C and other code for initializing BSS segment is in inline assembly ?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 01:39:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Regarding-startup-code/m-p/531226#M2398</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding startup code</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Regarding-startup-code/m-p/531227#M2399</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Rob65 on Sun Jul 10 23:14:43 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: sherrysamuel&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;What puzzles me more is why the code for copying the data variables to RAM is in C and other code for initializing BSS segment is in inline assembly ?&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Assembly is not the easiest language to use.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Maintainability of assembly is not always easy - I have programmed quite a bit of ARM (32-bits and Thumb1) assembly and I used to be the only person who was able to maintain the assembly code we wrote in a team with 10 software engineers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So we tried to create C-code as much as possible within our projects.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Writing the code to clear the BSS segment would loook like this in C-code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; for(pulDest = &amp;amp;_bss; pulDest &amp;lt; &amp;amp;_ebss; )
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *pulDest++ = 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;SPAN&gt;But depending on the compiler and compiler optimizations, pullDest may be one of the variables that is places in the bss segment. So this could mean that pullDest is being reset to 0, resulting in invalid memory access.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;That is the reason why this piece of code is written in Assembly and not in C.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rob&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 01:39:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Regarding-startup-code/m-p/531227#M2399</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:39:24Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding startup code</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Regarding-startup-code/m-p/531228#M2400</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by sherrysamuel on Mon Jul 11 19:04:07 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Rob&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thx for your quick reply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[PHP][/CODE]But depending on the compiler and compiler optimizations, pullDest may be one of the variables that is places in the bss segment. So this could mean that pullDest is being reset to 0, resulting in invalid memory access.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;That is the reason why this piece of code is written in Assembly and not in C.[/PHP]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But "pullDest" is a local variable and as far I know it will not be allocated in .bss section. It will be allocated in stack as it is local to function.Please correct me if I am wrong. So how will it result in invalid memory access. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sherry&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 01:39:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Regarding-startup-code/m-p/531228#M2400</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: Regarding startup code</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Regarding-startup-code/m-p/531229#M2401</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Rob65 on Tue Jul 12 00:03:58 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Sherry,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: sherrysamuel&lt;/STRONG&gt;&lt;BR /&gt;But "pullDest" is a local variable and as far I know it will not be allocated in .bss section.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes indeed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[I][B]As far as i know[/B][/I] you are right.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Good to see that there are still people who know how a compiler behaves (should behave...) :D&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rob&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 01:39:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Regarding-startup-code/m-p/531229#M2401</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:39:25Z</dc:date>
    </item>
  </channel>
</rss>

