title: Recursive function in x86-assembly
body: <p>I have a method <code>method(int a, int b)</code> in x86 assembly code:</p>
  
  <pre><code>method:
    pushl  %ebx
    subl   $24 , %esp
    movl   32(%esp ) , %ebx
    movl   36(%esp ) , %edx
    movl   $1 , %eax
    testl  %edx , %edx
    je     .L2
    subl   $1 , %edx
    movl   %edx , 4(%esp )
    movl   %ebx , (%esp )
    call   method
    imull  %ebx , %eax
  .L2:
    addl   $24 , %esp
    popl   %ebx
    ret
  </code></pre>
  
  <p>But I just cant wrap my head around its function.</p>
  
  <p><code>a</code> is written on <code>%ebx</code>, <code>b</code> is written on <code>%edx</code>.</p>
  
  <p><code>%eax</code> is initialized with 1.</p>
  
  <p>If <code>%edx</code> is not 0, I substract 1 from <code>%edx</code> and push <code>%edx</code> and <code>%ebx</code> on the stack and call <code>method</code> again. I just dont understand what it does. And isn't it impossible to reach the line <code>imull %ebx, %eax</code>?</p>
  
  <p>I would be really happy, if someone could explain the basic function of this method to me.</p>