title: Why this asm code not doubling the value the pointer points
body: <p>I am trying to interface c code with asm.
  But it is not working correctly and I am not able to find the problem.</p>
  
  <p><strong>program.c</strong></p>
  
  <pre><code>#include&lt;stdio.h&gt;
  int *asm_multi(int *ptr);
  
  int main()
  {
    int i=10;
    int *p=&amp;i;
    asm_multi(p);
    printf("%d\n",*p);
    return 0;
  }
  </code></pre>
  
  <p><strong>code.asm</strong></p>
  
  <pre><code>.section .text
  .global asm_multi
  .type asm_multi,@function
  asm_multi:
      pushl %ebp
      movl %esp,%ebp
      movl 8(%ebp),%eax
      movl %eax,%edx
      leal (%edx,%edx,1),%edx
      movl %edx,%eax
      movl %ebp,%esp
      popl %ebp
      ret
  </code></pre>
  
  <p>I am creating the final executable by</p>
  
  <pre><code>as code.asm -o code.o
  gcc program.c code.o -o  output
  ./output
  </code></pre>
  
  <blockquote>
    <p>The output it prints is :10 whereas I am expecting: 20</p>
  </blockquote>
  
  <p>What is the problem in the code? Don't consider the efficiency of the program. I have just started asm programming.</p>
  
  <p>I created above code after reading from a more complex example kept at <a href="https://banisterfiend.wordpress.com/2008/08/15/calling-an-asm-function-from-c/" rel="nofollow">this link</a>. This works perfectly.</p>