<?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: Multiply 32b x 32b in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiply-32b-x-32b/m-p/300799#M12604</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Martyn&lt;/P&gt;&lt;P&gt;This code not work too. The code "((long long) a * b)" is made with MUL instruction and result 32 bits.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;Vinicius&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 21 Mar 2014 16:45:01 GMT</pubDate>
    <dc:creator>ViniciusHoff</dc:creator>
    <dc:date>2014-03-21T16:45:01Z</dc:date>
    <item>
      <title>Multiply 32b x 32b</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiply-32b-x-32b/m-p/300797#M12602</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to multiply quickly two 32 bits operands and store in a 64 bits operand with GCC. I think that the faster mode to do this, is using the SMULL instruction of the processor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But GCC never uses the SMULL instruction.&lt;/P&gt;&lt;P&gt;If I just multiply two 32 bits operands and store in a 64 bits operand, the GCC uses the MULL instruction and the result will be wrong, of 32 bits.&lt;/P&gt;&lt;P&gt;If I cast both operands to 64 bits, the result is correct, but is much longer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How do I do this multiplication using SMULL instruction with GCC?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Mar 2014 23:18:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiply-32b-x-32b/m-p/300797#M12602</guid>
      <dc:creator>ViniciusHoff</dc:creator>
      <dc:date>2014-03-20T23:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: Multiply 32b x 32b</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiply-32b-x-32b/m-p/300798#M12603</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would try doing this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_13954136858964637 jive_text_macro jive_macro_code" jivemacro_uid="_13954136858964637" modifiedtitle="true"&gt;
&lt;P&gt;int a;&lt;/P&gt;
&lt;P&gt;int b;&lt;/P&gt;
&lt;P&gt;long c;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;a = /* a number*/;&lt;/P&gt;
&lt;P&gt;b = /* a number*/;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;c = ((long long) a * b);&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This should invoke the SMULL instruction.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know if this does or does not work for you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Martyn&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Mar 2014 14:57:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiply-32b-x-32b/m-p/300798#M12603</guid>
      <dc:creator>martynhunt</dc:creator>
      <dc:date>2014-03-21T14:57:01Z</dc:date>
    </item>
    <item>
      <title>Re: Multiply 32b x 32b</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiply-32b-x-32b/m-p/300799#M12604</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Martyn&lt;/P&gt;&lt;P&gt;This code not work too. The code "((long long) a * b)" is made with MUL instruction and result 32 bits.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;Vinicius&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Mar 2014 16:45:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiply-32b-x-32b/m-p/300799#M12604</guid>
      <dc:creator>ViniciusHoff</dc:creator>
      <dc:date>2014-03-21T16:45:01Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Multiply 32b x 32b</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiply-32b-x-32b/m-p/300800#M12605</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for your reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did some testing and found that this works on my system with optimizations set to Level 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13954327003556162" jivemacro_uid="_13954327003556162"&gt;
&lt;P&gt;volatile int a;&lt;/P&gt;
&lt;P&gt;volatile int b;&lt;/P&gt;
&lt;P&gt;volatile long long c;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;a = /* A number */;&lt;/P&gt;
&lt;P&gt;b = /* A number */;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;c = ((long long a * b);&lt;/P&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hopefully this works for you as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In case this doesn't work for you, would you mind sharing your version of GCC tools?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Martyn&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Mar 2014 20:11:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiply-32b-x-32b/m-p/300800#M12605</guid>
      <dc:creator>martynhunt</dc:creator>
      <dc:date>2014-03-21T20:11:33Z</dc:date>
    </item>
    <item>
      <title>Re: Multiply 32b x 32b</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiply-32b-x-32b/m-p/300801#M12606</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Now this works for me too. Really, the optimization must be set to Level 2. I was working with level 1 optimization, so the GCC doesn't use SMULL instruction.&lt;/P&gt;&lt;P&gt;I think that GCC should always use SMULL instruction, but, that way, my problem is solved.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you Martyn&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Mar 2014 21:27:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiply-32b-x-32b/m-p/300801#M12606</guid>
      <dc:creator>ViniciusHoff</dc:creator>
      <dc:date>2014-03-21T21:27:14Z</dc:date>
    </item>
  </channel>
</rss>

