<?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>topic CW and Cortex-M4 command SMLALD in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/CW-and-Cortex-M4-command-SMLALD/m-p/183748#M6323</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;The CW doen't handle correctly inline asm command SMLALD.&lt;/P&gt;&lt;P&gt;CW version is 10.2 Special Edition. CPU is Kinetis K10, CPU-selection in compiler settings is cortex-m4.&lt;/P&gt;&lt;P&gt;CW doesn't recognize that arguments RdLo and RdHi are input/output parameters.&lt;/P&gt;&lt;P&gt;It handles those "output only" and uses CPU registers wrongly. "+r" doesn't help.&lt;/P&gt;&lt;P&gt;Operation can be corrected by adding dummy-command SMUAD, which uses RE_LO and RE_HI&lt;/P&gt;&lt;P&gt;and prevents optimization to rearrange CPU registers.&lt;/P&gt;&lt;P&gt;But those extra commands waste time in our time critical loop.&lt;/P&gt;&lt;P&gt;Can this bug corrected by patching some compiler file(s)?&lt;/P&gt;&lt;P&gt;Is this corrected in CW version 10.3?&lt;/P&gt;&lt;P&gt;~Mark&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In header file:&lt;/P&gt;&lt;P&gt;#define ASM_SMUAD(Rd, Rn, Rm) \&lt;BR /&gt;&amp;nbsp; ({ asm volatile { smuad Rd, Rn, Rm } })&lt;/P&gt;&lt;P&gt;#define ASM_SMLALD(RdLo, RdHi, Rn, Rm) \&lt;BR /&gt;&amp;nbsp; ({ asm volatile ( "smlald %0, %1, %2, %3" :&amp;nbsp; "+r" (RdLo), "+r" (RdHi) : "r" (Rn), "r" (Rm) ); }) &lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In application SW:&lt;/P&gt;&lt;P&gt;in for-loop:&lt;/P&gt;&lt;P&gt;&amp;nbsp; uint32_t dummy;&lt;BR /&gt;&amp;nbsp; ASM_SMUAD( dummy, RE_LO, RE_HI ); // Dummy instruction to correct SMLALD by using RE_LO, RE_HI&lt;BR /&gt;&amp;nbsp; ASM_SMLALD( RE_LO, RE_HI, X_VAL, COS_VAL );&lt;/P&gt;&lt;P&gt;&amp;nbsp; ASM_SMUAD( dummy, IM_LO, IM_HI ); // Dummy instruction to correct SMLALD by using IM_LO, IM_HI&lt;BR /&gt;&amp;nbsp; ASM_SMLALD( IM_LO, IM_HI, X_VAL, SIN_VAL );&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; &amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 22 Nov 2012 07:54:57 GMT</pubDate>
    <dc:creator>MarkP_</dc:creator>
    <dc:date>2012-11-22T07:54:57Z</dc:date>
    <item>
      <title>CW and Cortex-M4 command SMLALD</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/CW-and-Cortex-M4-command-SMLALD/m-p/183748#M6323</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;The CW doen't handle correctly inline asm command SMLALD.&lt;/P&gt;&lt;P&gt;CW version is 10.2 Special Edition. CPU is Kinetis K10, CPU-selection in compiler settings is cortex-m4.&lt;/P&gt;&lt;P&gt;CW doesn't recognize that arguments RdLo and RdHi are input/output parameters.&lt;/P&gt;&lt;P&gt;It handles those "output only" and uses CPU registers wrongly. "+r" doesn't help.&lt;/P&gt;&lt;P&gt;Operation can be corrected by adding dummy-command SMUAD, which uses RE_LO and RE_HI&lt;/P&gt;&lt;P&gt;and prevents optimization to rearrange CPU registers.&lt;/P&gt;&lt;P&gt;But those extra commands waste time in our time critical loop.&lt;/P&gt;&lt;P&gt;Can this bug corrected by patching some compiler file(s)?&lt;/P&gt;&lt;P&gt;Is this corrected in CW version 10.3?&lt;/P&gt;&lt;P&gt;~Mark&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In header file:&lt;/P&gt;&lt;P&gt;#define ASM_SMUAD(Rd, Rn, Rm) \&lt;BR /&gt;&amp;nbsp; ({ asm volatile { smuad Rd, Rn, Rm } })&lt;/P&gt;&lt;P&gt;#define ASM_SMLALD(RdLo, RdHi, Rn, Rm) \&lt;BR /&gt;&amp;nbsp; ({ asm volatile ( "smlald %0, %1, %2, %3" :&amp;nbsp; "+r" (RdLo), "+r" (RdHi) : "r" (Rn), "r" (Rm) ); }) &lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In application SW:&lt;/P&gt;&lt;P&gt;in for-loop:&lt;/P&gt;&lt;P&gt;&amp;nbsp; uint32_t dummy;&lt;BR /&gt;&amp;nbsp; ASM_SMUAD( dummy, RE_LO, RE_HI ); // Dummy instruction to correct SMLALD by using RE_LO, RE_HI&lt;BR /&gt;&amp;nbsp; ASM_SMLALD( RE_LO, RE_HI, X_VAL, COS_VAL );&lt;/P&gt;&lt;P&gt;&amp;nbsp; ASM_SMUAD( dummy, IM_LO, IM_HI ); // Dummy instruction to correct SMLALD by using IM_LO, IM_HI&lt;BR /&gt;&amp;nbsp; ASM_SMLALD( IM_LO, IM_HI, X_VAL, SIN_VAL );&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; &amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Nov 2012 07:54:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/CW-and-Cortex-M4-command-SMLALD/m-p/183748#M6323</guid>
      <dc:creator>MarkP_</dc:creator>
      <dc:date>2012-11-22T07:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: CW and Cortex-M4 command SMLALD</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/CW-and-Cortex-M4-command-SMLALD/m-p/183749#M6324</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Regarding to your issue:&lt;BR /&gt;There is a header file with name "cw_cortex_M4_dsp.h" which located in {CW 10.x}MCU\ARM_EABI_Support\ewl\EWL_Runtime\Runtime_ARM\Common_Includes.&lt;BR /&gt;This file defined these instructions like SMLALD.&lt;/P&gt;&lt;P&gt;Please just include this header into your application and then you can call __SMLALD directly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you are using a CW 10.3, then, GCC compiler is also supported in this version of CW.&lt;/P&gt;&lt;P&gt;you can select GCC as the compiler tool chain when creating a new project.&lt;/P&gt;&lt;P&gt;for GCC compiler, you can use SMLALD as you did.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Hope it helps!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Mar 2013 06:37:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/CW-and-Cortex-M4-command-SMLALD/m-p/183749#M6324</guid>
      <dc:creator>Rick_Li</dc:creator>
      <dc:date>2013-03-26T06:37:35Z</dc:date>
    </item>
  </channel>
</rss>

