<?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>CodeWarrior for MCUのトピックRe: Call of function - compilation problem</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Call-of-function-compilation-problem/m-p/162607#M4563</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh, stupid mistake...Sorry.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 16 Mar 2009 20:39:54 GMT</pubDate>
    <dc:creator>gaminn</dc:creator>
    <dc:date>2009-03-16T20:39:54Z</dc:date>
    <item>
      <title>Call of function - compilation problem</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Call-of-function-compilation-problem/m-p/162605#M4561</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;My MCU is HCS08QG8 and I use CodeWarriror 5.9.0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a wait() function that I call in two files (main.c in main() function and handlers.c in handler() function). My problem is that wait() function called in handlers.c doesn't work. If i look at assembly code and search for assembly of both calls (they are the same - wait(209)&lt;A href="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" rel="nofollow noopener noreferrer noopener noreferrer" target="_blank"&gt;&lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt;&lt;/A&gt;, I can see for the&amp;nbsp;call in main.c:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;wait(209); // this is called in main file&amp;nbsp;&lt;/P&gt;&lt;P&gt;Assembly of this call:&amp;nbsp;&lt;/P&gt;&lt;P&gt;LDA&amp;nbsp; #0xD1&lt;/P&gt;&lt;P&gt;JSR&amp;nbsp; 0xEF91&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And for handlers.c file:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;wait(209); // this is called in handle file&lt;/P&gt;&lt;P&gt;Assembly of this call:&amp;nbsp;&lt;/P&gt;&lt;P&gt;LDX&amp;nbsp; #0xD1&lt;/P&gt;&lt;P&gt;CLRH&lt;/P&gt;&lt;P&gt;JSR&amp;nbsp; 0xEF91&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My wait() function looks like:&lt;/P&gt;&lt;PRE&gt;
void wait(unsigned char ms) {&amp;nbsp; unsigned char i;&amp;nbsp; for(i = 0 ; i &amp;lt; ms ; i++) {&amp;nbsp;&amp;nbsp;&amp;nbsp; wait_1ms();&amp;nbsp; }&amp;nbsp; }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Assembly (only beginning):&lt;/P&gt;&lt;P&gt;PSHA&lt;/P&gt;&lt;P&gt;PSHH&lt;/P&gt;&lt;P&gt;TSX&lt;/P&gt;&lt;P&gt;CLR&amp;nbsp; ,X&lt;/P&gt;&lt;P&gt;.......&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, I can see that parameter ms of wait() for the call in main.c&amp;nbsp;is&amp;nbsp;stored in register A, but for the call in handlers.c it is stored in register X. And wait() function is assembled in the way that register A is considered as the place where the ms parameter is located (and register X is the variable called i in wait()).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What can cause that compiler compiles my code in such a way (a way that doesn't work in handlers.c).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:08:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Call-of-function-compilation-problem/m-p/162605#M4561</guid>
      <dc:creator>gaminn</dc:creator>
      <dc:date>2020-10-29T09:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Call of function - compilation problem</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Call-of-function-compilation-problem/m-p/162606#M4562</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please make sure you have a prototype for function wait in module handlers.c prior to implementation of handler().&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CrasyCat&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Mar 2009 20:28:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Call-of-function-compilation-problem/m-p/162606#M4562</guid>
      <dc:creator>CrasyCat</dc:creator>
      <dc:date>2009-03-16T20:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: Call of function - compilation problem</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Call-of-function-compilation-problem/m-p/162607#M4563</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh, stupid mistake...Sorry.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Mar 2009 20:39:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Call-of-function-compilation-problem/m-p/162607#M4563</guid>
      <dc:creator>gaminn</dc:creator>
      <dc:date>2009-03-16T20:39:54Z</dc:date>
    </item>
  </channel>
</rss>

