<?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: (DSC) (56800EX) Bug in register optimization when using long long variables</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/DSC-56800EX-Bug-in-register-optimization-when-using-long-long/m-p/807636#M14768</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Lorenzo Micheletto,&lt;/P&gt;&lt;P&gt;From your fix, I believe your issue is due to optimization. Compiler performs optimization by default. Your method is the right way of avoiding it.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Jun Zhang&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 19 Dec 2018 02:44:02 GMT</pubDate>
    <dc:creator>ZhangJennie</dc:creator>
    <dc:date>2018-12-19T02:44:02Z</dc:date>
    <item>
      <title>(DSC) (56800EX) Bug in register optimization when using long long variables</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/DSC-56800EX-Bug-in-register-optimization-when-using-long-long/m-p/807633#M14765</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Discovered bug while using Codewarrior for MCU 11.01 with DSC toolchain for 56800EX cores. (MC56F847xxx).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When a long long variable is initialized with a long long constant and then used in function call, instead of putting its 64bit value on stack, the compiler copies TWICE the higher 32bit word.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That is, when compiling the following code with -v3&amp;nbsp; -opt level=4&amp;nbsp; &amp;nbsp;-opt speed -inline auto -inline level=8&amp;nbsp;optimizations:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;long long a1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a1 = 0x1122334455667788LL;&lt;/P&gt;&lt;P&gt;RDebug_T(a1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;( RDebug is declared as void RDebug_T(long long n); )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the DSC compiler generates the following assembly output: (added some comments to explain what happens)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;moveu.w #F__ConstToInitArray_1,R0&amp;nbsp; // load R0 with address of location containing 0x1122334455667788&lt;BR /&gt; move.l X:(R0)+,B // load low 32bit word into B/B10 register&lt;BR /&gt; move.l X:(R0)+,A //&amp;nbsp;&lt;SPAN&gt;load&amp;nbsp;high 32bit word into B/B10 register&lt;/SPAN&gt;&lt;BR /&gt; move.l B10,X:&amp;gt;Fsa1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//&amp;nbsp; &amp;nbsp;store A:B ( 0x1122334455667788) into sa1&lt;BR /&gt; move.l A10,X:&amp;gt;Fsa1+2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//&lt;BR /&gt; adda #&amp;lt;4,SP&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // allocate space on stack for RDebug_T parameter to pass sa1 to it&lt;BR /&gt; move.l A10,X:(SP-2)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // BUG: instead of putting A:B on stack it puts A:A&lt;BR /&gt; move.l A10,X:(SP)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//&lt;BR /&gt; jsr &amp;gt;FRDebug_T&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // subroutine will receive 0x1122334411223344 instead of 0x1122334455667788&lt;BR /&gt; suba #&amp;lt;4,SP&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It seems like it's a bug with register coloring when handling 64bit values.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Dec 2018 14:22:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/DSC-56800EX-Bug-in-register-optimization-when-using-long-long/m-p/807633#M14765</guid>
      <dc:creator>Lorenzo_Mch_IT</dc:creator>
      <dc:date>2018-12-17T14:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: (DSC) (56800EX) Bug in register optimization when using long long variables</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/DSC-56800EX-Bug-in-register-optimization-when-using-long-long/m-p/807634#M14766</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Lorenzo,&lt;/P&gt;&lt;P&gt;Please upload your demo project here. I will check it directly from my side.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Jun Zhang&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Dec 2018 03:17:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/DSC-56800EX-Bug-in-register-optimization-when-using-long-long/m-p/807634#M14766</guid>
      <dc:creator>ZhangJennie</dc:creator>
      <dc:date>2018-12-18T03:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: (DSC) (56800EX) Bug in register optimization when using long long variables</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/DSC-56800EX-Bug-in-register-optimization-when-using-long-long/m-p/807635#M14767</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can't do that right now. It happened with experimental code I'm not allowed to disclose.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;As soon as I can come up with a clean demo reproducing the problem I will post it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I provisionally fixed the problem by declaring a1 as volatile (i.e. volatile long long a1 ) to force reloading its value from memory instead of usign the copy cached into internal registers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another fix is to disable optimization, that's why it seems something related to register optimization.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Dec 2018 11:06:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/DSC-56800EX-Bug-in-register-optimization-when-using-long-long/m-p/807635#M14767</guid>
      <dc:creator>Lorenzo_Mch_IT</dc:creator>
      <dc:date>2018-12-18T11:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: (DSC) (56800EX) Bug in register optimization when using long long variables</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/DSC-56800EX-Bug-in-register-optimization-when-using-long-long/m-p/807636#M14768</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Lorenzo Micheletto,&lt;/P&gt;&lt;P&gt;From your fix, I believe your issue is due to optimization. Compiler performs optimization by default. Your method is the right way of avoiding it.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Jun Zhang&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Dec 2018 02:44:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/DSC-56800EX-Bug-in-register-optimization-when-using-long-long/m-p/807636#M14768</guid>
      <dc:creator>ZhangJennie</dc:creator>
      <dc:date>2018-12-19T02:44:02Z</dc:date>
    </item>
  </channel>
</rss>

