title: Is there another way to calculate (a^3) * b + 5*(b^2) without so many mul instructions?
body: <p>I'm starting to learn assembly, could someone please review my solution?</p>
  <p>Exercise :</p>
  <blockquote>
  <p>You are given eax=a, ebx=b.<br />
  Calculate (a^3) * b + 5*(b^2), and store
  the result inside eax.<br />
  (Here * means multiplication, and c^d means c to the
  power of d).</p>
  </blockquote>
  <p>Here's my solution :</p>
  <pre><code>;Init the values
  mov eax,3
  mov ebx,2
  
  ;3,2 =&gt;(3^3)*2 + 5*(2^2) = 27*2 + 5*4 = 54+20 = 74
  ;5,2 =&gt;(5^3)*2 + 5*(2^2) = 125*2 + 5*4 = 250 + 20 = 270
  
  ;(a^3)*b 
  mov esi,eax
  mul eax
  mul esi
  mul ebx
  ;Store the value
  mov esi,eax
  ;5*(b^2)
  mov eax,ebx
  mul ebx
  mov ebx,5
  mul ebx
  ;Calculate (a^3)*b + 5*(b^2)
  lea eax,[esi + eax]
  </code></pre>
  <p>Is there a way to solve this with less instructions?</p>