<?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>LPCXpresso IDE中的主题 Re: Hardware multiply and divide</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545852#M9422</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 Thu Jan 06 04:44:14 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;The Cortex-M0 has a choice of multiply implementations as the following information from the Cortex-M0 Technical Reference Manual states:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;The MULS instruction provides a 32-bit x 32-bit multiply that yields the least-significant 32-bits. The processor can implement MULS in one of two ways:&lt;BR /&gt;• as a fast single-cycle array&lt;BR /&gt;• as a 32-cycle iterative multiplier.&lt;/SPAN&gt;&lt;HR /&gt;&lt;SPAN&gt;[Links to ARM documentation at &lt;/SPAN&gt;&lt;A href="http://"&gt;http://support.code-red-tech.com/CodeRedWiki/ArmCpuInfo]&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Unfortunately, GCC currently assumes that you have the slower multiplier (even though the LPC11xx actually uses the fast implementation), and thus when it sees a multiplication by a constant, it will do this using adds/shifts - which it thinks will be faster.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Unfortunately I don't believe there is currently any way of modifiying this behaviour by the compiler.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[Note that multiplying two variables together will cause the generation of a MULS instruction, as in such cases the compiler has no way of knowing what combination of add/shifts to use.]&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:01:28 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T22:01:28Z</dc:date>
    <item>
      <title>Hardware multiply and divide</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545845#M9415</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by JohnR on Tue Aug 10 05:21:31 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Probably a stupid question but do the LPC1311/43 series contain a hardware multiplier or dvider. There is no mention of one in the product literature but since the corresponding ARM Cortex-M3 offerings from ST and TI(LuminaryMicro) do have multipliers and, in some cases, dividers, I wondered if these capabilities had been overlooked in the NXP literature?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;John.&lt;/SPAN&gt;&lt;P&gt;&lt;STRONG&gt;Original Attachment has been moved to: &lt;A _jive_internal="true" href="https://community.nxp.com/docs/DOC-338190"&gt;1100591_LPC17xx.txt.zip&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:01:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545845#M9415</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: Hardware multiply and divide</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545846#M9416</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 Tue Aug 10 05:34:57 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, hardware divide and multiply are standard on the Cortex-M3.&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:01:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545846#M9416</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: Hardware multiply and divide</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545847#M9417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by igorsk on Tue Aug 10 07:00:58 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Cortex-M0 (such as LPC1xxx) has only 32x32-&amp;gt;32 bit multiply (MUL). Cortex-M3 chips additionally support multiply-accumulate/subtract (MLA/MLS), 32x32-&amp;gt;64 multiply (SMULL/UMULL) and hardware divide (SDIV/UDIV). Interestingly, hardware divide is NOT present in the "big" cores like Cortex-A8.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;For more details, see ARMv7M Architecture Reference Manual (&lt;/SPAN&gt;&lt;A href="http://http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0403c/index.html"&gt;DDI 0403&lt;/A&gt;&lt;SPAN&gt;).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:01:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545847#M9417</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: Hardware multiply and divide</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545848#M9418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by leon_heller on Tue Aug 10 07:11:27 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;They have a Cortex-M3 core so will have hardware divide and 32-bit multiply:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://"&gt;http://www.arm.com/products/processors/cortex-m/cortex-m3.php&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:01:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545848#M9418</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:26Z</dc:date>
    </item>
    <item>
      <title>Re: Hardware multiply and divide</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545849#M9419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by JohnR on Wed Aug 11 05:41:00 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you all.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Maybe somebody could nudge NXP into updating their specsheets for the -M3 devices with the fact that the hardware multiplier/divider is present. This omission had me sidelining NXP for use in a new project for the apparent lack of this capability.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;John.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:01:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545849#M9419</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:27Z</dc:date>
    </item>
    <item>
      <title>Re: Hardware multiply and divide</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545850#M9420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by cyberstudio on Wed Jan 05 17:56:48 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Does LPC1114 have a single cycle multiply or a 32-cycle multiply? Wasn't clear to me from the user manual, with ARM saying 1 cycle or 32-cycle depending on (NXP's) multiplier implementation.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:01:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545850#M9420</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:27Z</dc:date>
    </item>
    <item>
      <title>Re: Hardware multiply and divide</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545851#M9421</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by cyberstudio on Wed Jan 05 20:41:51 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I just looked at some assembly code from lpcxpresso. The test is to multiply a constant to a 32-bit integer. The compiler turns the constant multiply to up to about 3 sets shift and add-or-subtract instructions. The compiler does an outstanding job of finding the smallest chunk of shift and add/subtract instructions, but if multiply is single cycle on LPC1114, it would always be cheaper than any shift/add combination.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:01:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545851#M9421</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: Hardware multiply and divide</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545852#M9422</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 Thu Jan 06 04:44:14 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;The Cortex-M0 has a choice of multiply implementations as the following information from the Cortex-M0 Technical Reference Manual states:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;The MULS instruction provides a 32-bit x 32-bit multiply that yields the least-significant 32-bits. The processor can implement MULS in one of two ways:&lt;BR /&gt;• as a fast single-cycle array&lt;BR /&gt;• as a 32-cycle iterative multiplier.&lt;/SPAN&gt;&lt;HR /&gt;&lt;SPAN&gt;[Links to ARM documentation at &lt;/SPAN&gt;&lt;A href="http://"&gt;http://support.code-red-tech.com/CodeRedWiki/ArmCpuInfo]&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Unfortunately, GCC currently assumes that you have the slower multiplier (even though the LPC11xx actually uses the fast implementation), and thus when it sees a multiplication by a constant, it will do this using adds/shifts - which it thinks will be faster.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Unfortunately I don't believe there is currently any way of modifiying this behaviour by the compiler.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[Note that multiplying two variables together will cause the generation of a MULS instruction, as in such cases the compiler has no way of knowing what combination of add/shifts to use.]&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:01:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545852#M9422</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: Hardware multiply and divide</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545853#M9423</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by fastmapper on Thu Jan 06 22:37:31 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: CodeRedSupport&lt;/STRONG&gt;&lt;BR /&gt;Unfortunately, GCC currently assumes that you have the slower multiplier (even though the LPC11xx actually uses the fast implementation), and thus when it sees a multiplication by a constant, it will do this using adds/shifts - which it thinks will be faster.&lt;BR /&gt;&lt;BR /&gt;Unfortunately I don't believe there is currently any way of modifiying this behaviour by the compiler.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My understanding is that LPCxpresso by default uses GCC version 4.3.3 and Cortex-M0 support was added with GCC version 4.5.0.&amp;nbsp; I expect this may have some influence on code generation for Cortex-M0.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:01:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545853#M9423</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:29Z</dc:date>
    </item>
    <item>
      <title>Re: Hardware multiply and divide</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545854#M9424</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 Fri Jan 07 09:02:18 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I believe that the "mainstream" version of gcc 4.3.3 did not have Cortex-M0 support. However the version that is used by LPCXPresso does.&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:01:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545854#M9424</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: Hardware multiply and divide</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545855#M9425</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by cyberstudio on Thu Jun 06 14:30:33 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Since 5.1.0, LPCXpresso has been using gcc 4.6.2, so it is supposed to have Cortex M0 support, but it is still generating many shifts instead of using the single cycle multiply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It is up to the chip implementor to choose between the fast multiplier and the slow multiplier, so there's got to be a way to tell the compiler the choice, so there's got to be a compiler command-line option to differentiate between the two, no?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:01:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545855#M9425</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: Hardware multiply and divide</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545856#M9426</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by R2D2 on Thu Jun 06 14:42:07 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: cyberstudio&lt;/STRONG&gt;&lt;BR /&gt;Since 5.1.0, LPCXpresso has been using gcc 4.6.2, so it is supposed to have Cortex M0 support, but it is still generating many shifts instead of using the single cycle multiply.&lt;BR /&gt;&lt;BR /&gt;It is up to the chip implementor to choose between the fast multiplier and the slow multiplier, so there's got to be a way to tell the compiler the choice, so there's got to be a compiler command-line option to differentiate between the two, no?&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;:confused:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure what you are talking about. My&amp;nbsp; LPCXpresso v5.2.4 [Build 2122] [2013-04-29]&amp;nbsp;&amp;nbsp; is using a clear MULS. Are we talking about LPCXpresso?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:01:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545856#M9426</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: Hardware multiply and divide</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545857#M9427</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by cyberstudio on Thu Jun 06 17:58:25 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using LPCXpresso 5.2.4 too, and just to make sure we are talking about the same thing,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1, the chip I used was LPC1114 (this discussion does NOT apply to Cortex M3), and,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2, the multiplied constant must be simple, with only 2 or 3 ones in the multiplied constant, otherwise the compiler would reason that MULS is cheaper for multiplying a complicated constant than a series of shifts and adds.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I searched through my disassmebly listing - the only time the compiler generate a plain MULS was when both operands are variables but not constants.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We know the root cause of this is the compiler assumes MULS takes 32 cycles to execute when in reality it takes only one on LPC1114. Even if gcc now supports Cortex M0, it still needs to be told that LPC1114's particular implementation is single cycle not 32, and it seems like no one has ever told the compiler about that, no?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:01:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545857#M9427</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: Hardware multiply and divide</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545858#M9428</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 Fri Jun 07 13:15:46 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure why you are complaining. As far as I can tell the compiler shipped in LPCXpresso 5.2.4 will use a MUL instruction for multiply by constants except in very simple cases. But where it uses a shift (plus potentially an addition/subtraction) as far as I can tell this does not increase the cycle count or the code size. Note that compilers for ARM have always historically done multiplies by powers of 2 (+/- 1) in this way.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example if I compile this simple function...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;int mymul (int x) {
return (x * MYCONST);
}&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;this compiles to&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;#define MYCONST 42
&amp;nbsp; 00000000 &amp;lt;mymul&amp;gt;:
&amp;nbsp;&amp;nbsp; 0:232a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; movsr3, #42; 0x2a
&amp;nbsp;&amp;nbsp; 2:4358&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mulsr0, r3
&amp;nbsp;&amp;nbsp; 4:4770&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bxlr&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;or&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;#define MYCONST 3
00000000 &amp;lt;mymul&amp;gt;:
&amp;nbsp;&amp;nbsp; 0:0043&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lslsr3, r0, #1
&amp;nbsp;&amp;nbsp; 2:1818&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; addsr0, r3, r0
&amp;nbsp;&amp;nbsp; 4:4770&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bxlr&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you think there is a problem, then please provide an example.&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:01:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545858#M9428</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:33Z</dc:date>
    </item>
    <item>
      <title>Re: Hardware multiply and divide</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545859#M9429</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by cyberstudio on Fri Jun 07 16:38:37 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for your reply, technical support.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I used the example you provided and did a lot of experimentation. It seems like the compiler is using the following rules.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1, if the constant fits within 8 bits and at least 2 bits are ones, a muls instruction is issued. This proves the compiler knows about fast multiply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2, if the constant does not fit within 8 bits, and there are only 2 ones, shifts and adds are generated. Only 3 instructions so this is the same as or cheaper than muls because the constant cannot be loaded with a single instruction anyway.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, to generate the "strange" case, the constant must not fit within 8 bits, and there must be more than 3 ones. BUT, here is the strange constant.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
#define MYCONST 0x555U
int main(int x) {
return x * MYCONST ;
 300:0043&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lslsr3, r0, #1
 302:1818&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; addsr0, r3, r0
 304:00c3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lslsr3, r0, #3
 306:1a18&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; subsr0, r3, r0
 308:0183&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lslsr3, r0, #6
 30a:18c0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; addsr0, r0, r3
}
 30c:4770&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bxlr
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I really doubt if a load instruction is so expensive that 6 shift/add instructions are better.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:01:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545859#M9429</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: Hardware multiply and divide</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545860#M9430</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 Mon Jun 10 02:21:26 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Your 0x555 example looks like an optimisation oddity when compiling -Os. If you compile at other optimisation levels (e.g. [FONT=Courier New]-O0[/FONT] or [FONT=Courier New]-O2[/FONT]), then a mul instruction will get used.&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:01:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Hardware-multiply-and-divide/m-p/545860#M9430</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:01:36Z</dc:date>
    </item>
  </channel>
</rss>

