<?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: C5906: Subtraction with zero</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/C5906-Subtraction-with-zero/m-p/145225#M3263</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hmm. It seems I confused the disassebly with volatile for the one without it. If LDAB is performed on "volatile id" later on, yeah then it behaves correctly.&lt;BR /&gt;&lt;BR /&gt;(Assuming a 8-bit access and a 16-bit access gives the same result. I can't remember if there is some case on the HCS12 where it doesn't, but when it comes to timer registers and similar, I'm not so sure.)&lt;BR /&gt;&lt;BR /&gt;So I guess I just do #pragma MESSAGE DISABLE C5906 on this function and pretend I never saw that warning.&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 15 Feb 2007 18:18:44 GMT</pubDate>
    <dc:creator>Lundin</dc:creator>
    <dc:date>2007-02-15T18:18:44Z</dc:date>
    <item>
      <title>C5906: Subtraction with zero</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/C5906-Subtraction-with-zero/m-p/145215#M3253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Using CW3.1 for HCS12 DG128.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I get a strange warning "C5906: Subtraction with zero" which I don't understand where it comes from. I have the following code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(Gah, it is hopeless to post any kind of source code on this site, please check attached file instead.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code seems to work, but I like to know where that warning came from. According to the helpfile you may get it from the tree optimizer:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"This message may be generated during tree optimizations (Option -Ont to switch it off)."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I disabled that one and the warning disappeared. I still don't understand why I got it, there seems to be nothing wrong with the code and if I look at the asm code, no subtraction with zero is taking place. Everything looks ok even though the subraction is done inside the if-condition rather than at the line where the value is assigned:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;07ba ec8f LDD 15,SP&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;07bc 830300 SUBD #768&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;07bf 8c001f CPD #31&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;07c2 226a BHI *+108 ;abs = 082e&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Feb 2007 18:53:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/C5906-Subtraction-with-zero/m-p/145215#M3253</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2007-02-14T18:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: C5906: Subtraction with zero</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/C5906-Subtraction-with-zero/m-p/145216#M3254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;You have&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;#define DCAN_MSG_FEEDBACK0&amp;nbsp; 0x0300&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;and&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;dsip_id = (uint8)(id - DCAN_MSG_FEEDBACK0); /* WARNING C5906 */&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This ^^ expression may be rewritten as&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;dsip_id = (uint8)id - (uint8)0x300;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;(uint8)0x300 == 0&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Feb 2007 19:24:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/C5906-Subtraction-with-zero/m-p/145216#M3254</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2007-02-14T19:24:26Z</dc:date>
    </item>
    <item>
      <title>Re: C5906: Subtraction with zero</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/C5906-Subtraction-with-zero/m-p/145217#M3255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Hello,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;How to post code easily is explained in the following thread.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;A id="subjects" name="subjects" target="_blank"&gt;&lt;/A&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="1" class="main_table" id="main_table" style="WIDTH: 78%" width="78%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="cell_hi" width="10"&gt;&lt;IMG alt="This is a thread that you have replied to" border="0" src="http://forums.freescale.com/freescale/i/skins/freescale/icon_thread_reply.gif" title="This is a thread that you have replied to" /&gt;&lt;/TD&gt;&lt;TD class="cell_hi" style="PADDING-RIGHT: 2px; PADDING-LEFT: 2px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px" width="1%"&gt;&lt;TABLE border="0" cellpadding="1" cellspacing="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;IMG height="21" src="http://forums.freescale.com/i/p.gif" width="14" /&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/TD&gt;&lt;TD class="cell_hi" style="PADDING-LEFT: 5px"&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0"&gt;&lt;TBODY&gt;&lt;TR valign="top"&gt;&lt;TD&gt;&lt;IMG src="http://www.freescale.com/shared/images/misc/bullet_square1.gif" /&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="100%"&gt;&lt;A class="subj_read" href="http://forums.freescale.com/freescale/board/message?board.id=FORUMUSE&amp;amp;message.id=294" target="_blank"&gt;&lt;FONT color="#51626F"&gt;[How To] Post source code correctly !&lt;/FONT&gt;&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/TD&gt;&lt;TD class="cell_hi" nowrap=""&gt;&lt;A class="auth_text" href="http://forums.freescale.com/freescale/view_profile?user.id=313" target="_blank"&gt;&lt;IMG alt="Main Moderator" border="0" src="http://forums.freescale.com/i/rank_icons/moderator.gif" title="Main Moderator" /&gt;&lt;STRONG&gt;&lt;FONT color="#D01033"&gt;&lt;/FONT&gt;&lt;SPAN style="COLOR: #d00c33"&gt;Alban&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/A&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD class="cell_hi"&gt;&lt;IMG alt="1 rating - 5.0 average" border="0" src="http://forums.freescale.com/freescale/i/skins/freescale/icon_rating_5.gif" title="1 rating - 5.0 average" /&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD class="cell_small_hi" nowrap=""&gt;&lt;SPAN class="date_text"&gt;2006-08-31&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;10:16 AM&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;P&gt;There has never been any problem reported with this procedure I use daily to correct code un-correctly posted.&lt;/P&gt;&lt;P&gt;&lt;IMG src="http://forums.freescale.com/i/global/post_src.gif" /&gt;&amp;nbsp;is in the editor toolbar.&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Alban.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Feb 2007 19:50:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/C5906-Subtraction-with-zero/m-p/145217#M3255</guid>
      <dc:creator>Alban</dc:creator>
      <dc:date>2007-02-14T19:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: C5906: Subtraction with zero</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/C5906-Subtraction-with-zero/m-p/145218#M3256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;No, it may not be rewritten as that, the parenthesis takes precedence. The subtraction is done first and since both operands are 16 bit, that means that the result will be 16 bit. Then it is casted to 8 bit, since I know that the result will be less than 256.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;EDIT: From Codewarriors own help file:&lt;BR /&gt;&lt;BR /&gt;Order of Operand Evaluation&lt;BR /&gt;&lt;BR /&gt;"Operators Associativity&lt;BR /&gt;&lt;BR /&gt;() [] -&amp;gt; . left to right&lt;BR /&gt;! ~ ++ -- + - * &amp;amp; (type) sizeof right to left"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;It is a bit tricky to cite ANSI C since they don't have a summary of the operator priorities, the priority is set by the chapter order. See chaper 6.5 in ISO/IEC 9899:1999.&lt;P&gt;Message Edited by Lundin on &lt;SPAN class="date_text"&gt;2007-02-14&lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;01:15 PM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Feb 2007 20:02:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/C5906-Subtraction-with-zero/m-p/145218#M3256</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2007-02-14T20:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: C5906: Subtraction with zero</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/C5906-Subtraction-with-zero/m-p/145219#M3257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I've read that and tried it. No use. I'm using Opera, so that might have something to do with it. The forum assumes that you use IE.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Feb 2007 20:04:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/C5906-Subtraction-with-zero/m-p/145219#M3257</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2007-02-14T20:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: C5906: Subtraction with zero</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/C5906-Subtraction-with-zero/m-p/145220#M3258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;I agree that according to C rules subtraction must be done first in your code. But optimizer is absolutely right&amp;nbsp;that&amp;nbsp;always&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;(uint8)(uint16 - uint16) == (uint8)uint16 - (uint8)uint16&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I'm not sure about warning, maybe it shouldn't appear since you didn't really - 0, you did - 0x300. But since you are choping upper 8 bits of difference, it's same as if you subtracted 0...&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Feb 2007 20:53:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/C5906-Subtraction-with-zero/m-p/145220#M3258</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2007-02-14T20:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: C5906: Subtraction with zero</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/C5906-Subtraction-with-zero/m-p/145221#M3259</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;The thing is, the optimizer was the one who decided to remove 0x300 from the id variable and store the result in acc D. Then further down, it decides to use&lt;BR /&gt;&lt;BR /&gt;D - 0 which is indeed equal to id - 0x300.&lt;BR /&gt;&lt;BR /&gt;And then it complains subraction with zero.&lt;BR /&gt;&lt;BR /&gt;Creepy, unexpected warnings like this make me nervous and make me suspect that the "tree optimizer" isn't tested properly. Creepier still, setting all variables involved to volatile doesn't help. To be on the safe side, I think I'll disable this optimizer option for all my projects.&lt;BR /&gt;&lt;BR /&gt;---&lt;BR /&gt;&lt;BR /&gt;How much easier things would have been if Metrowerks/Freescale didn't force us to debug optimized code. As I have said countless of times: CW is the only compiler out there that has optimization enabled by default and no simple way to turn it off.&lt;BR /&gt;&lt;BR /&gt;Last time I went in and tried to disable all the optimizer options, I accidently removed one option too much and the code started to behave in unexpected, non-standard ways. The Metrowerks support was clueless, they obviously didn't know about this particular compiler option. Neither did I, so I yelled at them about compiler bugs and then one month later or so I found the compiler option by experimenting on my own.&lt;BR /&gt;&lt;BR /&gt;It can't be awfully hard for the person who knows the details about all 555 optimizer options to write another option "disable optimizer". As things are now, all users who don't like to debug optimized code must read in detail about 555 optimizer options they don't intend to use, or else their programs might behave in weird or random ways when they disable them.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Feb 2007 22:02:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/C5906-Subtraction-with-zero/m-p/145221#M3259</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2007-02-14T22:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: C5906: Subtraction with zero</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/C5906-Subtraction-with-zero/m-p/145222#M3260</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;HR /&gt;Lundin wrote:&lt;BR /&gt;The thing is, the optimizer was the one who decided to remove 0x300 from the id variable and store the result in acc D. Then further down, it decides to use&lt;BR /&gt;&lt;BR /&gt;D - 0 which is indeed equal to id - 0x300.&lt;BR /&gt;&lt;BR /&gt;And then it complains subraction with zero.&lt;BR /&gt;&lt;BR /&gt;Creepy, unexpected warnings like this make me nervous and make me suspect that the "tree optimizer" isn't tested properly. Creepier still, setting all variables involved to volatile doesn't help. To be on the safe side, I think I'll disable this optimizer option for all my projects.&lt;BR /&gt;&lt;BR /&gt;---&lt;BR /&gt;&lt;HR /&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;/DIV&gt;&lt;DIV&gt;Optimizer removed 0x300 not in the line you are getting warning from.&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;SPAN class="msg_source_code"&gt;v4.5 disassembly&lt;/SPAN&gt;&lt;PRE&gt;   80:  if(id &amp;gt;= DCAN_MSG_FEEDBACK0  &amp;amp;&amp;amp;  0002 830300       [2]     SUBD  #768  0005 8c001f       [2]     CPD   #31  0008 2204         [3/1]   BHI   *+6 ;abs = 000e   81:     id &amp;lt; (DCAN_MSG_FEEDBACK0+FEEDBACK_MSG_N))   82:  {   83:     84:    dsip_id = (unsigned char)(id - DCAN_MSG_FEEDBACK0); /* WARNING C5906 */  000a e681         [3]     LDAB  1,SP  000c 6b82         [2]     STAB  2,SP   85:  }&lt;/PRE&gt;&lt;DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;Optimizer removed 0x300 while checking if uint16 id is in the range FEEDBACK0 to FEEDBACK0+N. Nice optimization indeed.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;C5906 warning comes from line 84:. Subtraction -0 is removed completely, only LDAB id&amp;nbsp; and STAB dsip_id are here.&lt;BR /&gt;&lt;/DIV&gt;&lt;DIV&gt;I understand your frustration but sometimes we need to be more objective.&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 08:46:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/C5906-Subtraction-with-zero/m-p/145222#M3260</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2020-10-29T08:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: C5906: Subtraction with zero</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/C5906-Subtraction-with-zero/m-p/145223#M3261</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Still I wonder why I get the warning when changing all variables to volatile. If I make variable "id" volatile, it is still placed in acc D and said optimization occurs later on, when the variable is used a second time. CW decides to optimize volatile variables, despite ANSI C.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;ISO 9899:1999 5.1.2.3.5&lt;BR /&gt;&lt;BR /&gt;"The least requirements on a conforming implementation are:&lt;BR /&gt;&lt;BR /&gt;— At sequence points, volatile objects are stable in the sense that previous accesses are complete and subsequent accesses have not yet occurred."&lt;BR /&gt;&lt;BR /&gt;I can't find any documentation about the tree optimizer where it is stated that keeping it enabled will stop the code from being ANSI/ISO compilant.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Feb 2007 16:44:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/C5906-Subtraction-with-zero/m-p/145223#M3261</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2007-02-15T16:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: C5906: Subtraction with zero</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/C5906-Subtraction-with-zero/m-p/145224#M3262</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;OK, id is volatile now. Say me what's not ANSI here&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="msg_source_code"&gt;&lt;SPAN class="text_smallest"&gt;Code:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;PRE&gt;   81:  if(id &amp;gt;= DCAN_MSG_FEEDBACK0  &amp;amp;&amp;amp;  0001 fc0000       [3]     LDD   id  0004 8c0300       [2]     CPD   #768  0007 250d         [3/1]   BCS   *+15 ;abs = 0016   82:     id &amp;lt; (DCAN_MSG_FEEDBACK0+FEEDBACK_MSG_N))  0009 fc0000       [3]     LDD   id  000c 8c0320       [2]     CPD   #800  000f 2405         [3/1]   BCC   *+7 ;abs = 0016   83:  {   84:     85:    dsip_id = (unsigned char)(id - DCAN_MSG_FEEDBACK0); /* WARNING C5906 */  0011 f60000       [3]     LDAB  id:1  0014 6b80         [2]     STAB  0,SP&lt;/PRE&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;id is reloaded as many times as id is mentioned in the code. But volatile doesn't and shouldn't prevent optimization on line 85:.&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 08:46:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/C5906-Subtraction-with-zero/m-p/145224#M3262</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2020-10-29T08:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: C5906: Subtraction with zero</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/C5906-Subtraction-with-zero/m-p/145225#M3263</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hmm. It seems I confused the disassebly with volatile for the one without it. If LDAB is performed on "volatile id" later on, yeah then it behaves correctly.&lt;BR /&gt;&lt;BR /&gt;(Assuming a 8-bit access and a 16-bit access gives the same result. I can't remember if there is some case on the HCS12 where it doesn't, but when it comes to timer registers and similar, I'm not so sure.)&lt;BR /&gt;&lt;BR /&gt;So I guess I just do #pragma MESSAGE DISABLE C5906 on this function and pretend I never saw that warning.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Feb 2007 18:18:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/C5906-Subtraction-with-zero/m-p/145225#M3263</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2007-02-15T18:18:44Z</dc:date>
    </item>
    <item>
      <title>Re: C5906: Subtraction with zero</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/C5906-Subtraction-with-zero/m-p/145226#M3264</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;HR /&gt;Lundin wrote:&lt;BR /&gt;(Assuming a 8-bit access and a 16-bit access gives the same result. I can't remember if there is some case on the HCS12 where it doesn't, but when it comes to timer registers and similar, I'm not so sure.)&lt;BR /&gt;&lt;HR /&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;DIV&gt;Yes, in this case 8-bit access and 16-bit access gives the same result.&lt;/DIV&gt;&lt;DIV&gt;TCNT is special in that it's free running and 16-bit access is not the same as reading upper and lower bytes and combining them into single 16-bit value. Of course it takes longer to do&amp;nbsp;two 8-bit accesses, but problem is not&amp;nbsp;the +- a couple of timer ticks error, but +- multiplies of 256 timer ticks. Suppose lower part of TCNT is close to 8-bit overflow, for example TCNT is 0x04FD. Reading TCNT&amp;nbsp;high byte first can give you something like 0x0403, reading it low byte first can give you something like 0x05FE. But if you are interested only in lower 8bits of TCNT, then it's OK to access just&amp;nbsp;8-bits of it.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regarding C5906, yes, I would just #pragma MESSAGE DISABLE it. But I&amp;nbsp;agree with you that it would be nice if we wouldn't need to guess the matter of these weird warnings. If such a warning from the middle/end of optimization appears, then it should be shown how did optimizer transform my code. Probably it's not so easy to implement. If so then these warnings should be disabled by default.&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Feb 2007 19:12:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/C5906-Subtraction-with-zero/m-p/145226#M3264</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2007-02-15T19:12:27Z</dc:date>
    </item>
  </channel>
</rss>

