<?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: Check bits in the CCR</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Check-bits-in-the-CCR/m-p/162993#M4585</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Right... there is no bit in the CCR, but you could clear index register Y before executing EMUL, then check if Y is different from zero afterwards. It would still have to be done in assembler.&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Jun 2008 13:23:36 GMT</pubDate>
    <dc:creator>Lundin</dc:creator>
    <dc:date>2008-06-11T13:23:36Z</dc:date>
    <item>
      <title>Check bits in the CCR</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Check-bits-in-the-CCR/m-p/162990#M4582</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm sorry if this has been answered before but i could not find a solution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Background, using CodeWarrior 5.7, Chip is type HC12S and programming in C.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm performing a 16bit x 16bit multiplication and need to check if there is an overflow. I assume i should just check the relevant bits in the CCR but i'm not sure how to do this programmically.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help would be much appericiated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Chris&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jun 2008 19:12:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Check-bits-in-the-CCR/m-p/162990#M4582</guid>
      <dc:creator>Chris_UTS</dc:creator>
      <dc:date>2008-06-10T19:12:54Z</dc:date>
    </item>
    <item>
      <title>Re: Check bits in the CCR</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Check-bits-in-the-CCR/m-p/162991#M4583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;You will indeed have to check the CCR through inline assembler, there is no obvious way to check for overflow in C.&lt;BR /&gt;&lt;BR /&gt;I suppose you could do like this:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;#include &amp;lt;limits.h&amp;gt;

uint16 a;
uint16 b;
uint32 a32 = a;
uint32 b32 = b;
uint32 result = a32 * b32;

if(result &amp;gt; UINT_MAX)
{
  /*  a*b will give overflow  */
}
&lt;/PRE&gt;&lt;BR /&gt;Though the assembler version will be way more efficient.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:09:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Check-bits-in-the-CCR/m-p/162991#M4583</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2020-10-29T09:09:07Z</dc:date>
    </item>
    <item>
      <title>Re: Check bits in the CCR</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Check-bits-in-the-CCR/m-p/162992#M4584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;The HW of the S12 implements a 16x16=32 multiplication, therefore there is no overflow, and no&lt;BR /&gt;bit in the CCS to test.&lt;BR /&gt;&lt;BR /&gt;Instead try a 16*16=32 bit multiplication in C and check if the resulting long fits into 16 bit.&lt;BR /&gt;If performance is critical, then note that not the multiplication is the expensive operation here but everything else &lt;IMG alt="Smiley Happy" class="emoticon emoticon-smileyhappy" id="smileyhappy" src="https://community.nxp.com/i/smilies/16x16_smiley-happy.png" title="Smiley Happy" /&gt;.&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;Code:#include &amp;lt;limits.h&amp;gt;unsigned int a,b,c;unsigned char overflow;void mul() {  unsigned long ab = (unsigned long)a * b;  if (ab &amp;gt; UINT_MAX) {    overflow = TRUE;  } else {    c = (unsigned int)ab;      }}&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:09:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Check-bits-in-the-CCR/m-p/162992#M4584</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2020-10-29T09:09:09Z</dc:date>
    </item>
    <item>
      <title>Re: Check bits in the CCR</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Check-bits-in-the-CCR/m-p/162993#M4585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Right... there is no bit in the CCR, but you could clear index register Y before executing EMUL, then check if Y is different from zero afterwards. It would still have to be done in assembler.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jun 2008 13:23:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Check-bits-in-the-CCR/m-p/162993#M4585</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2008-06-11T13:23:36Z</dc:date>
    </item>
  </channel>
</rss>

