<?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>Digital Signal ControllersのトピックRe: Codewarrior for MCU 11.1 - inline assembler  bug  when zeroing DSC accumulator extension registe</title>
    <link>https://community.nxp.com/t5/Digital-Signal-Controllers/Codewarrior-for-MCU-11-1-inline-assembler-bug-when-zeroing-DSC/m-p/1706409#M2804</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I am sorry for misunderstanding you, this is a bug of the compiler.&lt;/P&gt;
&lt;P&gt;The assembly move.w #0,BB.2&lt;/P&gt;
&lt;P&gt;should be translated as:&lt;/P&gt;
&lt;P&gt;move.w #0,B2,&lt;/P&gt;
&lt;P&gt;but it is translated as&lt;/P&gt;
&lt;P&gt;move.w #0,B&lt;/P&gt;
&lt;P&gt;I will report the issue to compiler team&lt;/P&gt;
&lt;P&gt;Thank you for pointing out the bug.&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Xiangjun Rong&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 17 Aug 2023 08:18:21 GMT</pubDate>
    <dc:creator>xiangjun_rong</dc:creator>
    <dc:date>2023-08-17T08:18:21Z</dc:date>
    <item>
      <title>Codewarrior for MCU 11.1 - inline assembler  bug  when zeroing DSC accumulator extension register</title>
      <link>https://community.nxp.com/t5/Digital-Signal-Controllers/Codewarrior-for-MCU-11-1-inline-assembler-bug-when-zeroing-DSC/m-p/1705678#M2801</link>
      <description>&lt;P&gt;The following source code exposes a bug in the inline assembler of DSC's compiler:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;typedef unsigned long       UINT32;

inline void u64_SHR3(register UINT64 *RReg )
{
	register UINT32 AA;
	register UINT32 BB;
	__asm{
	move.l X:(RReg)+,AA
	move.l X:(RReg),BB
	move.w #0,BB.2
	asr BB
	ror.l AA
	asr BB
	ror.l AA
	asr BB
	ror.l AA
	move.l BB,X:(RReg)-
	move.l AA,X:(RReg)
	}
}

#define tick2mSec(tmp) {u64_SHR3(tmp);} // myRTC/8 --&amp;gt; time in mSec&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is an "optimized" triple right shift of a 64bit unsigned value, but when clearing the accumulator extension register, the generated code clears the whole 36bit accumulator:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;;  100: 		tick2mSec(&amp;amp;tp); // 8Khz ticks to milliSeconds 
;
0x00000036  0x8AB4FFFB             adda        #-5,SP,R0
0x00000038  0x8121                 tfra        R0,R1
0x00000039  0xF021                 move.l      X:(R1)+,A
0x0000003A  0xF135                 move.l      X:(R1),B
0x0000003B  0xE180                 move.w      #0,B
0x0000003C  0x70EB                 asr         B
0x0000003D  0x7647                 ror.l       A
0x0000003E  0x70EB                 asr         B
0x0000003F  0x7647                 ror.l       A
0x00000040  0x70EB                 asr         B
0x00000041  0x7647                 ror.l       A
0x00000042  0xD131                 move.l      B10,X:(R1)-
0x00000043  0xD035                 move.l      A10,X:(R1)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Notice what happens at offset 0x0000003B&lt;/EM&gt;:&lt;BR /&gt;instead of emitting an error because instruction&amp;nbsp;&lt;STRONG&gt;move.w #0,B2&lt;/STRONG&gt; (clear upper 4bits of 36bit accumulator B ) DOES NOT EXIST, or replacing it with the functionally equivalent&amp;nbsp;&lt;STRONG&gt;clr.w B2&lt;/STRONG&gt; ...&amp;nbsp;&lt;BR /&gt;the inline assembler emits &lt;STRONG&gt;move #0,B&lt;/STRONG&gt; clearing the whole 36bit accumulator B.&lt;/P&gt;&lt;P&gt;The obvious workaround is to use clr.w, but NXP personell working on DSC's compiler should give a look at the root cause of this bug, maybe it's a symptom of worse bugs still lurking around in the inline assembler.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2023 10:10:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Digital-Signal-Controllers/Codewarrior-for-MCU-11-1-inline-assembler-bug-when-zeroing-DSC/m-p/1705678#M2801</guid>
      <dc:creator>Lorenzo_Mch_IT</dc:creator>
      <dc:date>2023-08-16T10:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: Codewarrior for MCU 11.1 - inline assembler  bug  when zeroing DSC accumulator extension registe</title>
      <link>https://community.nxp.com/t5/Digital-Signal-Controllers/Codewarrior-for-MCU-11-1-inline-assembler-bug-when-zeroing-DSC/m-p/1706206#M2802</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;You want to implement that&amp;nbsp; the B2(4 bits) is zero, while B1/B0 remain intact.&lt;/P&gt;
&lt;P&gt;You can use the move.w #$0000, B2, it is okay.&lt;/P&gt;
&lt;P&gt;Hope it can help you&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;XiangJun Rong&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="xiangjun_rong_0-1692243732653.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/236776iAC1DB572931429E1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="xiangjun_rong_0-1692243732653.png" alt="xiangjun_rong_0-1692243732653.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 03:45:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Digital-Signal-Controllers/Codewarrior-for-MCU-11-1-inline-assembler-bug-when-zeroing-DSC/m-p/1706206#M2802</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2023-08-17T03:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: Codewarrior for MCU 11.1 - inline assembler  bug  when zeroing DSC accumulator extension registe</title>
      <link>https://community.nxp.com/t5/Digital-Signal-Controllers/Codewarrior-for-MCU-11-1-inline-assembler-bug-when-zeroing-DSC/m-p/1706401#M2803</link>
      <description>&lt;P&gt;Please excuse me, english is not my mother tongue; the issue is that the inline assembly instruction &lt;STRONG&gt;move.w #0,BB.2&lt;/STRONG&gt; is handled incorrectly by the compiler.&lt;BR /&gt;&lt;BR /&gt;Instead of emitting &lt;STRONG&gt;move.w #0,B2&lt;/STRONG&gt;, the inline assembler emits &lt;STRONG&gt;move.w #0,B&lt;/STRONG&gt; and &lt;U&gt;clears the whole accumulator B&lt;/U&gt;&amp;nbsp; (i.e. B2,B1 and B0).&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I guess either there is a bug in inline assembler integrated in the compiler ( maybe related to how the inline assembler handles references to register variables declared in the same function? ).&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 08:09:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Digital-Signal-Controllers/Codewarrior-for-MCU-11-1-inline-assembler-bug-when-zeroing-DSC/m-p/1706401#M2803</guid>
      <dc:creator>Lorenzo_Mch_IT</dc:creator>
      <dc:date>2023-08-17T08:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: Codewarrior for MCU 11.1 - inline assembler  bug  when zeroing DSC accumulator extension registe</title>
      <link>https://community.nxp.com/t5/Digital-Signal-Controllers/Codewarrior-for-MCU-11-1-inline-assembler-bug-when-zeroing-DSC/m-p/1706409#M2804</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I am sorry for misunderstanding you, this is a bug of the compiler.&lt;/P&gt;
&lt;P&gt;The assembly move.w #0,BB.2&lt;/P&gt;
&lt;P&gt;should be translated as:&lt;/P&gt;
&lt;P&gt;move.w #0,B2,&lt;/P&gt;
&lt;P&gt;but it is translated as&lt;/P&gt;
&lt;P&gt;move.w #0,B&lt;/P&gt;
&lt;P&gt;I will report the issue to compiler team&lt;/P&gt;
&lt;P&gt;Thank you for pointing out the bug.&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Xiangjun Rong&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 08:18:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Digital-Signal-Controllers/Codewarrior-for-MCU-11-1-inline-assembler-bug-when-zeroing-DSC/m-p/1706409#M2804</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2023-08-17T08:18:21Z</dc:date>
    </item>
  </channel>
</rss>

