<?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: CW code generation in CodeWarrior for QorIQ</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157086#M2139</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, after I saw that main.c contained the exact source you presented, I loaded the project, right-clicked on main.c and recompiled, then right-clicked again and disassembled.&lt;/P&gt;&lt;P&gt;(Before that, I just disassembled and saw your code as presented.)&lt;/P&gt;&lt;P&gt;It came out just like I said in a previous message.&lt;/P&gt;&lt;P&gt;So maybe all you have to do is recompile unconditionally, and then disassemble again. There maybe some remains from a previous compilation(?) using different options or processor type, different source code, whatever...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HTH,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Johan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Mar 2009 16:02:40 GMT</pubDate>
    <dc:creator>jbezem</dc:creator>
    <dc:date>2009-03-10T16:02:40Z</dc:date>
    <item>
      <title>CW code generation</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157056#M2109</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i've got a problem with code generation by CW 7.1 build 14.&lt;/P&gt;&lt;P&gt;Some settings:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;__fourbyteints__ 0 (defined 0, by clearing ' 4-byte integers' checkbox on the setting panel )&lt;/LI&gt;&lt;LI&gt;MCF52235&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Very simple clearing of a bit:&lt;/P&gt;&lt;P&gt;Enable int. by clearing corresp. bit mask:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 1;"&gt;MCF_INTC0_IMRL &amp;amp;= ~(MCF_INTC_IMRL_INT_MASK15 | MCF_INTC_IMRL_MASKALL );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Used definitions:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 1;"&gt;#define MCF_INTC0_IMRL &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; (*(vuint32*)(&amp;amp;__IPSBAR[0xC0C]))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 1;"&gt;#define MCF_INTC_IMRL_INT_MASK15 &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (0x8000)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 1;"&gt;#define MCF_INTC_IMRL_MASKALL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (0x1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 1;"&gt;MCF_INTC0_IMRL &amp;amp;= ~ (MCF_INTC_IMRL_INT_MASK15 | MCF_INTC_IMRL_MASKALL );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Generated code:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;; 398: MCF_INTC0_IMRL &amp;amp;= ~(MCF_INTC_IMRL_INT_MASK15 | MCF_INTC_IMRL_MASKALL );&lt;/SPAN&gt; &lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x000000D4&amp;nbsp; 0x41F900000000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lea&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ___IPSBAR+3084,a0&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x000000DA&amp;nbsp; 0x203C&lt;SPAN style="color: #ff0000;"&gt;&lt;SPAN&gt;00007FFE&lt;/SPAN&gt;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; move.l&amp;nbsp;&amp;nbsp; #32766,d0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; '....'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x000000E0&amp;nbsp; 0xC190&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and.l&amp;nbsp;&amp;nbsp;&amp;nbsp; d0,(a0)&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;This also clears b31...16; and THAT was not intended. It seems that 'it' generated the mask 16 bit wide.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When you clear f.e. b14 then there's no problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 1;"&gt;MCF_INTC0_IMRL &amp;amp;= ~ (MCF_INTC_IMRL_INT_MASK14 | MCF_INTC_IMRL_MASKALL );&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;;397: MCF_INTC0_IMRL &amp;amp;= ~ (MCF_INTC_IMRL_INT_MASK14 | MCF_INTC_IMRL_MASKALL );&lt;/SPAN&gt; &lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x000000C6&amp;nbsp; 0x41F900000000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lea&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ___IPSBAR+3084,a0&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x000000CC&amp;nbsp; 0x203C&lt;SPAN style="color: #008000;"&gt;&lt;SPAN&gt;FFFFBFFE&lt;/SPAN&gt;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; move.l&amp;nbsp;&amp;nbsp; #-16386,d0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; '....'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x000000D2&amp;nbsp; 0xC190&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and.l&amp;nbsp;&amp;nbsp;&amp;nbsp; d0,(a0)&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also when you cast to a uint32 the code is correct.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 1;"&gt;MCF_INTC0_IMRL &amp;amp;= ~ (uint32)(MCF_INTC_IMRL_INT_MASK15 | MCF_INTC_IMRL_MASKALL );&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;;399:MCF_INTC0_IMRL &amp;amp; = ~(uint32 (MCF_INTC_IMRL_INT_MASK15 |&amp;nbsp; MCF_INTC_IMRL_MASKALL );&lt;/SPAN&gt; &lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x000000E2&amp;nbsp; 0x41F900000000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lea&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ___IPSBAR+3084,a0&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x000000E8&amp;nbsp; 0x203C&lt;SPAN style="color: #008000;"&gt;&lt;SPAN&gt;FFFF7FFE&lt;/SPAN&gt;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; move.l&amp;nbsp;&amp;nbsp; #-32770,d0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; '....'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x000000EE&amp;nbsp; 0xC190&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and.l&amp;nbsp;&amp;nbsp;&amp;nbsp; d0,(a0)&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Also when you try to clear b31, the compiler uses 64 bit sizes??&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;;400: MCF_INTC0_IMRL &amp;amp;= ~ (MCF_INTC_IMRL_INT_MASK31 | MCF_INTC_IMRL_MASKALL );&lt;/SPAN&gt; &lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x000000F0&amp;nbsp; 0x4DF900000000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lea&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ___IPSBAR+3084,a6&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x000000F6&amp;nbsp; 0x2F560004&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; move.l&amp;nbsp;&amp;nbsp; (a6),4(a7)&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x000000FA&amp;nbsp; 0x41EF0014&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lea&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20(a7),a0&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x000000FE&amp;nbsp; 0x2E88&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; move.l&amp;nbsp;&amp;nbsp; a0,(a7)&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x00000100&amp;nbsp; 0x4EB900000000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; jsr&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ___rt_ultoi64&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x00000106&amp;nbsp; 0x72FF&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; moveq&amp;nbsp;&amp;nbsp;&amp;nbsp; #-1,d1&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x00000108&amp;nbsp; 0x203C7FFFFFFE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; move.l&amp;nbsp;&amp;nbsp; #2147483646,d0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; '....'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x0000010E&amp;nbsp; 0x2F400010&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; move.l&amp;nbsp;&amp;nbsp; d0,16(a7)&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x00000112&amp;nbsp; 0x2F41000C&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; move.l&amp;nbsp;&amp;nbsp; d1,12(a7)&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x00000116&amp;nbsp; 0x2010&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; move.l&amp;nbsp;&amp;nbsp; (a0),d0&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x00000118&amp;nbsp; 0x2F6800040008&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; move.l&amp;nbsp;&amp;nbsp; 4(a0),8(a7)&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x0000011E&amp;nbsp; 0x2F400004&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; move.l&amp;nbsp;&amp;nbsp; d0,4(a7)&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x00000122&amp;nbsp; 0x41EF001C&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lea&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 28(a7),a0&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x00000126&amp;nbsp; 0x2E88&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; move.l&amp;nbsp;&amp;nbsp; a0,(a7)&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x00000128&amp;nbsp; 0x4EB900000000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; jsr&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ___rt_and64&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x0000012E&amp;nbsp; 0x2CA80004&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; move.l&amp;nbsp;&amp;nbsp; 4(a0),(a6)&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;;&amp;nbsp; 401:&amp;nbsp; MCF_INTC0_IMRL &amp;amp;= ~ (uint32)(MCF_INTC_IMRL_INT_MASK31 | MCF_INTC_IMRL_MASKALL );&lt;/SPAN&gt; &lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x00000132&amp;nbsp; 0x41F900000000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lea&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ___IPSBAR+3084,a0&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x00000138&amp;nbsp; 0x203C&lt;SPAN style="color: #008000;"&gt;&lt;SPAN&gt;7FFFFFFE&lt;/SPAN&gt;&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; move.l&amp;nbsp;&amp;nbsp; #2147483646,d0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ; '....'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;0x0000013E&amp;nbsp; 0xC190&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and.l&amp;nbsp;&amp;nbsp;&amp;nbsp; d0,(a0)&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new,courier'; font-size: 1;"&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when you: #define __fourbyteints__ 1&lt;/P&gt;&lt;P&gt;then the generated code is ok.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is, how can avoid this code generation error without the need of&lt;/P&gt;&lt;P&gt;explicitly casting when there seems no need to do so.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;René&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:01:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157056#M2109</guid>
      <dc:creator>badaboom</dc:creator>
      <dc:date>2020-10-29T09:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: CW code generation</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157057#M2110</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sounds like an you should submit a service request for this (if you not already did)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.freescale.com/webapp/servicerequest.create_SR.framework?regFlag=fromOpenSR" rel="nofollow" target="_blank"&gt;https://www.freescale.com/webapp/servicerequest.create_SR.framework?regFlag=fromOpenSR&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is how could any user of the compiler know how to safely workaround the issue?&lt;/P&gt;&lt;P&gt;Pretty much only a compiler engineer working on that compiler can give you a&amp;nbsp; safe answer. Also it's&lt;/P&gt;&lt;P&gt;important to get such issues fixed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Feb 2009 00:05:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157057#M2110</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2009-02-27T00:05:38Z</dc:date>
    </item>
    <item>
      <title>Re: CW code generation</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157058#M2111</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I didn't check any settings of the compiler and your variant, but if you clear '__fourbyteints__', you'd have 16-bit integers, I assume. That means that your 0x8000 bit definition is taken to be a negative number (signed!).&lt;/P&gt;&lt;P&gt;Bitwise negation of signed numbers is never a good idea, but since we're operating on 16-bit integers, the negated mask becomes 0x7FFE (positive again!), and the generated code seems OK to me, even if it is not what you intended.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With 4-byte integers the situation is different: 0x8000 is effectively 0x00008000, so your inverted bit-mask becomes 0xFFFF7FFE, what you intended.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To remedy this without too many casts, you could use 0x8000U, which in case of 2-byte ints would be converted to long (still signed, but 32-bit!), and everything would work as expected; I didn't verify this, though.&lt;/P&gt;&lt;P&gt;In case of 4-byte ints this mask gets converted to 'unsigned int', so it will work also.&lt;/P&gt;&lt;P&gt;Or you add at least one cast to convert one of the bit-masks to the type of your target, like ((vuint32)0x8000U), to make everything clear.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IMHO this is not a compiler problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HTH,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Johan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Feb 2009 15:40:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157058#M2111</guid>
      <dc:creator>jbezem</dc:creator>
      <dc:date>2009-02-27T15:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: CW code generation</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157059#M2112</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Silly me, I did not realize that the compiler actually was correct.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With 16 bit ints, the constant 0x8000 has type unsigned int, hence the expression&lt;/P&gt;&lt;P&gt;(0x8000 | 1) has type unsigned int to and the value 0x8001u.&lt;/P&gt;&lt;P&gt;Therefore the complement (still type unsigned int) has the value 0x7FFEu, and&amp;nbsp; &amp;amp;= 0x7FFEu does indeed clear the more significant 16 bits too.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure why the compiler uses 64 bit for clearing the 31st bit. How are the constants defined?&lt;/P&gt;&lt;P&gt;That could also be a compiler issue, although not wrong, just inefficient.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the operation should always work on at least 32 bits I would make the constants of type unsigned long by using&lt;/P&gt;&lt;P&gt;a uL suffix&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="1"&gt;&amp;gt; #define MCF_INTC_IMRL_INT_MASK15 &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (0x8000uL)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Feb 2009 15:55:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157059#M2112</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2009-02-27T15:55:19Z</dc:date>
    </item>
    <item>
      <title>Re: CW code generation</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157060#M2113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the replies..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think it's better to cast at the operation then&lt;/P&gt;&lt;P&gt;to check the 'Coldfire module header files' for all '0x8000's&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MCF_INTC0_IMRL &amp;amp;= ~ (uint32)(MCF_INTC_IMRL_INT_MASK15 | MCF_INTC_IMRL_MASKALL );&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MCF_INTC0_IMRL &amp;amp;= ~ (uint32)(MCF_INTC_IMRL_INT_MASK31 | MCF_INTC_IMRL_MASKALL );&lt;BR /&gt;&amp;nbsp;becomes:&lt;/P&gt;&lt;PRE&gt;
;398: MCF_INTC0_IMRL &amp;amp;= ~(uint32)(MCF_INTC_IMRL_INT_MASK15|
                                  MCF_INTC_IMRL_MASKALL);
;
0x000000DC  0x41F900000000           lea      ___IPSBAR+3084,a0
0x000000E2  0x203C&lt;SPAN&gt;FFFF7FFE&lt;/SPAN&gt;           move.l   #-32770,d0            ; '....'
0x000000E8  0xC190                   and.l    d0,(a0)
;
;399: MCF_INTC0_IMRL &amp;amp;= ~(uint32)(MCF_INTC_IMRL_INT_MASK31 |
                                  MCF_INTC_IMRL_MASKALL);
;
0x000000EA  0x41F900000000           lea      ___IPSBAR+3084,a0
0x000000F0  0x203C&lt;SPAN&gt;7FFFFFFE&lt;/SPAN&gt;           move.l   #2147483646,d0        ; '....'
0x000000F6  0xC190                   and.l    d0,(a0)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just redefining the constant as: #define MCF_INTC_IMRL_INT_MASK15 (0x8000&lt;SPAN&gt;u&lt;/SPAN&gt;) doesn't force the compiler to use unsigned. After negation the result is positive and will fit in THE 16bit wide int, and therefore clearing the high word (as positive result).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Only making it 32 bit wide solves this.&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;#define MCF_INTC_IMRL_INT_MASK15 &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (0x8000&lt;SPAN&gt;uL&lt;/SPAN&gt;) or&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;#define MCF_INTC_IMRL_INT_MASK15 &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (uint32)(0x8000)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I agree it's not a compiler issue but let's say I wasn't forwarned because the operation output is an &lt;SPAN&gt;vuint32&lt;/SPAN&gt; and there's wasn't a compiler warning "Implicit arithmetic conversion from 'signed xxx' to 'unsigned&amp;nbsp; xxx'.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;René&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:01:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157060#M2113</guid>
      <dc:creator>badaboom</dc:creator>
      <dc:date>2020-10-29T09:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: CW code generation</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157061#M2114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;badaboom wrote:&lt;BR /&gt;...&lt;P&gt;I think it's better to cast at the operation ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;Agreed.&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;...&lt;BR /&gt;&lt;P&gt;Just redefining the constant as: #define MCF_INTC_IMRL_INT_MASK15 (0x8000&lt;SPAN&gt;u&lt;/SPAN&gt;) doesn't force the compiler to use unsigned.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;Yes, it does, but contrary to what I suggested, it doesn't convert to 'signed long', but leaves it to be an 'unsigned int'; my mistake. So it remains 16-bit wide until after the negation, and then gets zero-extended to 32-bits before and-ing with the resulting value. Not what you intended.&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;...&lt;BR /&gt;&lt;P&gt;Only making it 32 bit wide solves this.&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;#define MCF_INTC_IMRL_INT_MASK15 &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (0x8000&lt;SPAN&gt;uL&lt;/SPAN&gt;) or&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;#define MCF_INTC_IMRL_INT_MASK15 &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (uint32)(0x8000)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#3366FF"&gt;Correct. I'd use the cast as you initially indicated, since it will provide correct results independent from the size of an 'int'. Using 'uL' may prove to extend to 64-bits when using 4-byte ints, which works, but is an exaggeration and slow. If you don't care about portability, though, you may go ahead.&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I agree it's not a compiler issue but let's say I wasn't forwarned because the operation output is an &lt;SPAN&gt;vuint32&lt;/SPAN&gt; and there's wasn't a compiler warning "Implicit arithmetic conversion from 'signed xxx' to 'unsigned&amp;nbsp; xxx'.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;...&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;&lt;FONT color="#3366FF"&gt;That's why I use PC Lint from Gimpel.&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;&lt;FONT color="#3366FF"&gt;&amp;nbsp;BR,&lt;/FONT&gt;&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;&lt;FONT color="#3366FF"&gt;&amp;nbsp;Johan&lt;/FONT&gt;&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Feb 2009 21:44:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157061#M2114</guid>
      <dc:creator>jbezem</dc:creator>
      <dc:date>2009-02-27T21:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: CW code generation</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157062#M2115</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;CompilerGuru wrote:&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With 16 bit ints, the constant 0x8000 has type unsigned int, hence the expression&lt;/P&gt;&lt;P&gt;(0x8000 | 1) has type unsigned int to and the value 0x8001u.&lt;/P&gt;&lt;P&gt;Therefore the complement (still type unsigned int) has the value 0x7FFEu, and&amp;nbsp; &amp;amp;= 0x7FFEu does indeed clear the more significant 16 bits too.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;EM&gt;If&lt;/EM&gt; that were true, then 0x4000|1 would result in the complement&amp;nbsp;0xCFFEu.&lt;/P&gt;&lt;P&gt;Extending 0xCFFE&lt;EM&gt;u&lt;/EM&gt; to 32 bits would result in 0x0000CFFE&lt;EM&gt;u&lt;/EM&gt;.&lt;/P&gt;&lt;P&gt;It does not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem starts with the fact&amp;nbsp;that then 16bit int constant is apparently signed.&lt;/P&gt;&lt;P&gt;When this is expanded to 32bits because &amp;amp;= other argument is 32bit, the compiler does not take in account that this other argument&amp;nbsp;and the destination&amp;nbsp;is NOT signed (it is vuint32).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what happens:&lt;/P&gt;&lt;P&gt;0x4000|1 = 0x4001, ~0x4001 = 0xCFFE, -&amp;gt;32bit = 0xFFFFCFFE,&amp;nbsp; &amp;amp;=&lt;/P&gt;&lt;P&gt;0x8000|1 = 0x8001, ~0x8001 = 0x7FFE, -&amp;gt;32bit = 0x00007FFE,&amp;nbsp; &amp;amp;=&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The conversion to 32 bits is not done at the same point as the conversion to unsigned.&lt;/P&gt;&lt;P&gt;The compiler seems to think it is signed.&lt;/P&gt;&lt;P&gt;This does not make sense to me as the result is stored in a vuint32.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by MrBean on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-03-03 13:34&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;01:34 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Mar 2009 20:32:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157062#M2115</guid>
      <dc:creator>MrBean</dc:creator>
      <dc:date>2009-03-03T20:32:00Z</dc:date>
    </item>
    <item>
      <title>Re: CW code generation</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157063#M2116</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;MrBean wrote:&lt;BR /&gt;...&lt;BR /&gt;&lt;P&gt;This is what happens:&lt;/P&gt;&lt;P&gt;0x4000|1 = 0x4001, ~0x4001 = 0xCFFE, -&amp;gt;32bit = 0xFFFFCFFE,&amp;nbsp; &amp;amp;=&lt;/P&gt;&lt;P&gt;0x8000|1 = 0x8001, ~0x8001 = 0x7FFE, -&amp;gt;32bit = 0x00007FFE,&amp;nbsp; &amp;amp;=&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;Sorry to disagree:&lt;P&gt;0x4000|1 = 0x4001, ~0x4001 = 0x&lt;FONT color="#ff0000"&gt;B&lt;/FONT&gt;FFE, -&amp;gt;32bit = 0xFFFF&lt;FONT color="#ff0000"&gt;B&lt;/FONT&gt;FFE,&amp;nbsp; &amp;amp;=&lt;/P&gt;&lt;P&gt;0x8000|1 = 0x8001, ~0x8001 = 0x7FFE, -&amp;gt;32bit = 0x00007FFE,&amp;nbsp; &amp;amp;=&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Note the 'B' instead of 'C'). Other than that, for 16-bit ints, I agree.&lt;/P&gt;&lt;P&gt;And AFAIK, unadorned constants are (usually?/always?/must be?) considered 'int' and signed, even according to the Standard.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FWIW,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Johan&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Mar 2009 20:49:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157063#M2116</guid>
      <dc:creator>jbezem</dc:creator>
      <dc:date>2009-03-03T20:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: CW code generation</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157064#M2117</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;IMG alt=":smileyhappy:" class="emoticon emoticon-smileyhappy" id="smileyhappy" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-happy.gif" title="Smiley Happy" /&gt; sorry for the calculation typo, BFFE is right.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But still, i think it should either warn or not do it in this fashion.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Mar 2009 20:52:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157064#M2117</guid>
      <dc:creator>MrBean</dc:creator>
      <dc:date>2009-03-03T20:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: CW code generation</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157065#M2118</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To show how inconsistent the behaviour is to me, try explaining this one :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;
;  401:  MCF_INTC0_IMRL = ~( ~MCF_INTC0_IMRL |  ( MCF_INTC_IMRL_INT_MASK15 | MCF_INTC_IMRL_MASKALL ) ;
0x0000017E  0x203900000000           move.l   ___IPSBAR+3084,d00x00000184  0x4680                   not.l    d00x00000186  0x008000008001           ori.l    #0x8001,d0            ; '....'0x0000018C  0x4680                   not.l    d00x0000018E  0x23C000000000           move.l   d0,___IPSBAR+3084&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by MrBean on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-03-03 15:05&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;03:05 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:01:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157065#M2118</guid>
      <dc:creator>MrBean</dc:creator>
      <dc:date>2020-10-29T09:01:32Z</dc:date>
    </item>
    <item>
      <title>Re: CW code generation</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157066#M2119</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, assuming ints are 16-bit:&lt;/P&gt;&lt;P&gt;- in the bit-or expression, the negation of&amp;nbsp; MCF_INTC0_IMRL has the highest precedence; the macro has type uint32, and is loaded into d0.&lt;/P&gt;&lt;P&gt;- then the negation is performed using d0.&lt;/P&gt;&lt;P&gt;- since the negated expression still has the type uint32, the integer 0x8000 is implicitly converted to uint32 (left-to-right associativity of operator bit-or); however, I read-up on conversion of constants: Since the constant is given as 0x8000 (and not 32768, the same value but a different notation!) it is considered of type 'unsigned int', not signed. See H&amp;amp;S 5th edition, 2.7.1: "An interesting point to note ... is that integers in the range of 2^15 through 2^16-1 will have positive values when written as decimal constants but negative values when written as octal or hexadecimal constants (and cast to type 'int')");&amp;nbsp;&lt;/P&gt;&lt;P&gt;- and or-ed into the result (later optimized and taken together with the next constant)&lt;/P&gt;&lt;P&gt;- then 0x0001 is taken (type: signed int), and also converted to uint32 (sign-extension is trivial here), and ored into the result.&lt;/P&gt;&lt;P&gt;And finally the result is negated again, and stored into the variable/register.&lt;/P&gt;&lt;P&gt;QED IMHO.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FWIW,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Johan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Mar 2009 22:40:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157066#M2119</guid>
      <dc:creator>jbezem</dc:creator>
      <dc:date>2009-03-03T22:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: CW code generation</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157067#M2120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;BTW, isn't there a parenthesis missing in the commented source-line? I see two opening and only one closing paren. Cut&amp;amp;Paste error?&lt;/P&gt;&lt;P&gt;The reasoning remains almost the same even if the evaluation order changes a little; the anomaly lies in the difference between 0x8000 and 32768.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Johan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Mar 2009 22:44:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157067#M2120</guid>
      <dc:creator>jbezem</dc:creator>
      <dc:date>2009-03-03T22:44:16Z</dc:date>
    </item>
    <item>
      <title>Re: CW code generation</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157068#M2121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;EM&gt;&amp;gt; If&lt;/EM&gt; that were true, then 0x4000|1 would result in the complement&amp;nbsp;0xCFFEu.&lt;/P&gt;&lt;P&gt;&amp;gt; Extending 0xCFFE&lt;EM&gt;u&lt;/EM&gt; to 32 bits would result in 0x0000CFFE&lt;EM&gt;u&lt;/EM&gt;.&lt;/P&gt;&lt;P&gt;&amp;gt; It does not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Well my text was using 0x8000 not 0x4000. Different number, different rule :smileyhappy:.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The constant 0x8000 has type unsigned int because it does not fit into a (16 bit signed) int type.&lt;/P&gt;&lt;P&gt;The constant 0x4000 fits, and therefore has type (signed) int. Therefore the extension to long in&lt;/P&gt;&lt;P&gt;(long)(~(0x4000+1))&lt;/P&gt;&lt;P&gt;is a sign extension, the long gets negative.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following expressions though will result in a positive long &amp;lt;= 0xFFFF, the extension to long was done from a unsigned type (assuming 16 bit ints):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(long)(~(0x4000u+1))&lt;/P&gt;&lt;P&gt;(long)((unsigned int)~(0x4000+1))&lt;/P&gt;&lt;P&gt;(long)(~(0x8000 - 0x4000 + 1))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So if you intend to use 32 bit arithmetic in ANSI-C I would recommend to use 32 bit constants, say with a 16 bit int type to write it in one of those forms:&lt;/P&gt;&lt;P&gt;0x4000L&lt;/P&gt;&lt;P&gt;0x4000uL&lt;/P&gt;&lt;P&gt;(long)0x4000&lt;/P&gt;&lt;P&gt;(unsigned long)0x4000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2009 00:00:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157068#M2121</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2009-03-04T00:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: CW code generation</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157069#M2122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt;The reasoning remains almost the same even if the evaluation order changes a little;&lt;/P&gt;&lt;P&gt;&amp;gt; the anomaly lies in the difference between 0x8000 and 32768&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is that not the same?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2009 00:02:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157069#M2122</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2009-03-04T00:02:29Z</dc:date>
    </item>
    <item>
      <title>Re: CW code generation</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157070#M2123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Stop seeing all my typo's &lt;IMG alt=":smileywink:" class="emoticon emoticon-smileywink" id="smileywink" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-wink.gif" title="Smiley Wink" /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;jbezem wrote:&lt;BR /&gt;&lt;P&gt;The reasoning remains almost the same even if the evaluation order changes a little; the anomaly lies in the difference between 0x8000 and 32768.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;The 0x8000 and 32768 difference is a result, not a cause, it is compiler ouput.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;The definitions are not changed.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;The output indeed shows that evaluation order is of influence.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;The logic of it is still unclear to me.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;For completeness:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;PRE&gt;
;  394: MCF_INTC0_IMRL = ~( ~MCF_INTC0_IMRL |   ( MCF_INTC_IMRL_INT_MASK14 | MCF_INTC_IMRL_MASKALL )) ;
;
0x00000150  0x203900000000           move.l   ___IPSBAR+3084,d0
0x00000156  0x4680                   not.l    d0
0x00000158  0x008000004001           ori.l    #0x4001,d0            ; &lt;A href="mailto:'..@.'" rel="nofollow noopener noreferrer noopener noreferrer" target="_blank"&gt;'..@.'&lt;/A&gt;
0x0000015E  0x4680                   not.l    d0
0x00000160  0x23C000000000           move.l   d0,___IPSBAR+3084
;
;  395: MCF_INTC0_IMRL = ~( ~MCF_INTC0_IMRL |   ( MCF_INTC_IMRL_INT_MASK15 | MCF_INTC_IMRL_MASKALL )) ;
;  396: 
;
0x00000166  0x203900000000           move.l   ___IPSBAR+3084,d0
0x0000016C  0x4680                   not.l    d0
0x0000016E  0x008000008001           ori.l    #0x8001,d0            ; '....'
0x00000174  0x4680                   not.l    d0
0x00000176  0x23C000000000           move.l   d0,___IPSBAR+3084
;
;  397: MCF_INTC0_IMRL =  (  MCF_INTC0_IMRL &amp;amp;  ~( MCF_INTC_IMRL_INT_MASK14 | MCF_INTC_IMRL_MASKALL )) ;
;
0x0000017C  0x203CFFFFBFFE           move.l   #-16386,d0            ; '....'
0x00000182  0xC1B900000000           and.l    d0,___IPSBAR+3084
;
;  398: MCF_INTC0_IMRL =  (  MCF_INTC0_IMRL &amp;amp;  ~( MCF_INTC_IMRL_INT_MASK15 | MCF_INTC_IMRL_MASKALL )) ;
;0x00000188  0x203C00007FFE           move.l   #32766,d0             ; '....'0x0000018E  0xC1B900000000           and.l    d0,___IPSBAR+3084;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by MrBean on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-03-03 17:12&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;05:12 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:01:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157070#M2123</guid>
      <dc:creator>MrBean</dc:creator>
      <dc:date>2020-10-29T09:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: CW code generation</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157071#M2124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I didn't check the 'for completeness' yet, but the difference between 0x8000 and 32768 is in the language definition, and therefore in the compiler. The quote I gave is from " C A Reference Manual" by Harbison and Steele, the best reference on C I have ever seen.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To make it even more clear: The compiler _has_ to interpret 0x8000 and 32768 differently.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll have a look at the rest later.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Johan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2009 00:19:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157071#M2124</guid>
      <dc:creator>jbezem</dc:creator>
      <dc:date>2009-03-04T00:19:05Z</dc:date>
    </item>
    <item>
      <title>Re: CW code generation</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157072#M2125</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hmm.. maybe it has to do with a 2's complement being not exactly the same as a bitwise not ...&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2009 00:21:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157072#M2125</guid>
      <dc:creator>MrBean</dc:creator>
      <dc:date>2009-03-04T00:21:30Z</dc:date>
    </item>
    <item>
      <title>Re: CW code generation</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157073#M2126</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;From what I've seen, and IMHO, the compiler is correct in all cases, and I'll explain why:&lt;/P&gt;&lt;P&gt;- the first is trivial: MASK14 means a signed int 0x4000 is used, or-ed with a signed int 0x0001 to produce a positive signed int, and then sign-extended and or-ed with the negated uint32: 0x0004001 is correct.&lt;/P&gt;&lt;P&gt;- the second is a repetition of your previous post; my argument changes a little because of the parentheses: 0x8000 is unsigned int, combined with 0x0001 as signed int, gives an unsigned int 0x8001; zero-extended to be combined with a negated uint32: 0x00008001 is correct.&lt;/P&gt;&lt;P&gt;- the third combines two signed int values into a signed int 0x4001, negates all bits to get a signed int 0xBFFE (negative!), and gets sign-extended to uint32: 0xFFFFBFFE is correct.&lt;/P&gt;&lt;P&gt;- the fourth case is different again: 0x8000 is unsigned int, combined with signed int 0x0001 to give unsigned int 0x8001, all bis negated to unsigned int 0x7FFE, and zero-extended to be combined with uint32: 0x00007FFE is correct.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any objections?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FWIW,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Johan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2009 00:39:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157073#M2126</guid>
      <dc:creator>jbezem</dc:creator>
      <dc:date>2009-03-04T00:39:18Z</dc:date>
    </item>
    <item>
      <title>Re: CW code generation</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157074#M2127</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;From a mathematical point of view, they are the same, but on a 16-bit integer machine, unadorned constants between 2^15 and 2^16-1 are treated differently if specified as hex/octal (0xFFFF is unsigned int) or if specified in decimal (65535 is signed long).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Did I write 'long'? Yes I did, and correctly so... I may have to revise my four answers then once again. Sorry, MrBean! The day was long, I'll leave that for tomorrow.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff"&gt;Update: No, of course not. All constants in the four cases of MrBean were in hex, so I do not have to revise my answers. OK, shut down the machine and relax a bit.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bye,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Johan&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by jbezem on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-03-03&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;05:59 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2009 00:49:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157074#M2127</guid>
      <dc:creator>jbezem</dc:creator>
      <dc:date>2009-03-04T00:49:24Z</dc:date>
    </item>
    <item>
      <title>Re: CW code generation</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157075#M2128</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;CompilerGuru wrote:&lt;BR /&gt;&lt;P&gt;The constant 0x8000 has type unsigned int because it does not fit into a (16 bit signed) int type.&lt;/P&gt;&lt;P&gt;The constant 0x4000 fits, and therefore has type (signed) int. Therefore the extension to long in&lt;/P&gt;&lt;P&gt;(long)(~(0x4000+1))&lt;/P&gt;&lt;P&gt;is a sign extension&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;*That* makes sense !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That&amp;nbsp;also means all header files provided by Freescale are wrong/dangerous,&amp;nbsp;once the&amp;nbsp;'4-byte integers' checkbox on the setting panel is switched off.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So: Leave the checkbox on, or change all header files so that constants have a type that fits the register they are meant for.&lt;/P&gt;&lt;P&gt;The first is easiest, the latter would be more correct.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanx for all the input everyone !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by MrBean on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-03-03 18:48&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;06:48 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2009 01:41:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-QorIQ/CW-code-generation/m-p/157075#M2128</guid>
      <dc:creator>MrBean</dc:creator>
      <dc:date>2009-03-04T01:41:52Z</dc:date>
    </item>
  </channel>
</rss>

