<?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 Re: Strange __asm code. in LPCXpresso IDE</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/Strange-asm-code/m-p/574346#M21841</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by domen on Mon Jun 07 10:19:52 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Interesting.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Compiler name and version?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And please a whole chuck of asm code, so if someone cares enough he can try to compile it himself.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 22:31:16 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T22:31:16Z</dc:date>
    <item>
      <title>Strange __asm code.</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Strange-asm-code/m-p/574343#M21838</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by micrio on Mon Jun 07 06:47:42 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;[FONT=Courier New]I get some weird code coming from the inline assembler. [/FONT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[FONT=Courier New]I have the following source;[/FONT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[FONT=Courier New][B][COLOR=#7f0055][COLOR=#7f0055]#define [/COLOR][/COLOR][/B]DOUBLE_TOGGLE [B][COLOR=#7f0055][COLOR=#7f0055]__asm[/COLOR][/COLOR][/B]( \[/FONT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[FONT=Courier New][COLOR=#2a00ff][COLOR=#2a00ff]"[U]mov[/U] %0, %[on_dly]\n\t"[/COLOR][/COLOR]\ [/FONT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[LEFT][FONT=Courier New][COLOR=#2a00ff][COLOR=#2a00ff]"[U]mov[/U] %1, %[mux_addr]\n\t"[/COLOR][/COLOR]\[/FONT][/LEFT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[FONT=Courier New][COLOR=#2a00ff][COLOR=#2a00ff]"[U]mov[/U] %2, %[bit_pat]\n\t"[/COLOR][/COLOR]\[/FONT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[FONT=Courier New][COLOR=#2a00ff][COLOR=#2a00ff]"[U]mov[/U] %3, %[off_dly]\n\t"[/COLOR][/COLOR]\[/FONT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[FONT=Courier New][COLOR=#2a00ff][COLOR=#2a00ff]"[U]str[/U] %2, [%1, #0]\n\t"[/COLOR][/COLOR] \[/FONT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[LEFT][FONT=Courier New]...[/FONT][/LEFT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[FONT=Courier New]The resulting code is; [/FONT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[LEFT][FONT=Courier New]ldr r3, [pc, #92] (0x544 &amp;lt;dly_428+20&amp;gt;)[/FONT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[FONT=Courier New]ldr r0, [r4, #0][/FONT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[FONT=Courier New]ldr r1, [r3, #12][/FONT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[FONT=Courier New]ldr r3, [pc, #88] (0x548 &amp;lt;dly_428+24&amp;gt;)[/FONT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[FONT=Courier New]ldr r2, [r3, #0][/FONT][/LEFT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[FONT=Courier New]ldr r3, [pc, #88] (0x54c &amp;lt;dly_428+28&amp;gt;)[/FONT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[FONT=Courier New]adds r0, r0, #0[/FONT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[FONT=Courier New]adds r3, r3, #0[/FONT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[FONT=Courier New]adds r1, r1, #0[/FONT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[FONT=Courier New]adds r2, r2, #0[/FONT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[FONT=Courier New]str r1, [r3, #0][/FONT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[FONT=Courier New]The MOV opcodes get translated to LDR which is OK. The loaded values are correct. [/FONT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[FONT=Courier New]The STR opcode is unchanged. However what are the ADDS opcodes for?[/FONT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[SIZE=2][FONT=Courier New][SIZE=3]They serve to test the incoming values but are not needed. [/SIZE][/FONT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[FONT=Courier New][SIZE=3]I am trying to save every machine cycle and this is just a waste. [/SIZE][/FONT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[FONT=Courier New][SIZE=3]Is there some way that I can eliminate them?[/SIZE][/FONT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(I can't explain the odd formatting of this message, there must be some invisible char messing things up!)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[/SIZE]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:31:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Strange-asm-code/m-p/574343#M21838</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: Strange __asm code.</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Strange-asm-code/m-p/574344#M21839</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by micrio on Mon Jun 07 09:16:36 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I have changed my code but still have (different) problems.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When I do inline assembly I want to write the code and have&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;in inserted in the routine. I don't want the compiler to fool&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;with it. I want the opcodes inserted as I wrote them. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't want the compiler to "optimize" it. If I wanted&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;optimization I would it write in C.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Do I need to put this in a different source file and set the optimization&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;parameter to -O0?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:31:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Strange-asm-code/m-p/574344#M21839</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: Strange __asm code.</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Strange-asm-code/m-p/574345#M21840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by domen on Mon Jun 07 10:19:22 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Interesting.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Compiler name and version?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And please a whole chuck of asm code, so if someone cares enough he can try to compile it himself.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:31:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Strange-asm-code/m-p/574345#M21840</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: Strange __asm code.</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Strange-asm-code/m-p/574346#M21841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by domen on Mon Jun 07 10:19:52 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Interesting.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Compiler name and version?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And please a whole chuck of asm code, so if someone cares enough he can try to compile it himself.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:31:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Strange-asm-code/m-p/574346#M21841</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: Strange __asm code.</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Strange-asm-code/m-p/574347#M21842</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by CodeRedSupport on Wed Jun 09 01:37:11 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: micrio&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;[FONT=Courier New]The MOV opcodes get translated to LDR which is&amp;nbsp; OK. The loaded values are correct. [/FONT]&lt;BR /&gt;[FONT=Courier New]The STR opcode is unchanged. However what are&amp;nbsp; the ADDS opcodes for?[/FONT]&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Without a buildable example (and info on which MCU you are using), I imagine that the compiler considers that the MOV is actually a MOVS (which sets the flags). Thus as an LDR doesn't set the flags, the compiler has to add in an instruction which will. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: micrio&lt;/STRONG&gt;&lt;BR /&gt;I have changed my code but still have (different) problems.&lt;BR /&gt;When I do inline assembly I want to write the code and have&lt;BR /&gt;in inserted in the routine. I don't want the compiler to fool&lt;BR /&gt;with it. I want the opcodes inserted as I wrote them. &lt;BR /&gt;I don't want the compiler to "optimize" it. If I wanted&lt;BR /&gt;optimization I would it write in C.&lt;BR /&gt; &lt;BR /&gt;Do I need to put this in a different source file and set the optimization&lt;BR /&gt;parameter to -O0?&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you write assembler within your C source, then yes, you will see some optimisation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The gcc docs give more information on this, and the following document is also quite useful:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://"&gt;http://www.ethernut.de/en/documents/arm-inline-asm.html&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;[though note that IIRC all the examples given are ARM code, rather than Thumb/Thumb2]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you still have problems with what the compiler does, then perhaps you should consider writing an actual assembler file. There are some previous forum posts on doing this. Google something like '[I]assembly site:knowledgebase.nxp.com[/I]' to find them.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you want further help via the forum, please post a buildable example (and make sure you include build options, especially the target MCU).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CodeRedSupport&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:31:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Strange-asm-code/m-p/574347#M21842</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:31:17Z</dc:date>
    </item>
  </channel>
</rss>

