title: Pass user input from C to Assembler
body: <p>I am new to ARM Assembler. Using qemu emulator.</p>
  
  <p>This <a href="https://stackoverflow.com/questions/4330604/pass-an-argument-from-c-to-assembly">solution</a> didn't work for me.</p>
  
  <p>I have this C file <strong>md1_main.c</strong>: </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include "md1.h"
  
      int main (void)
      {
              int n;
              scanf("%d", &amp;n);
              printf("Result = %u\n", asum(n));
              return 0;
      }
  </code></pre>
  
  <p>and .h file contains function prototype <code>unsigned int asum(unsigned int n);</code></p>
  
  <p>I am really confused, how to pass <code>n</code> into the assembler code.</p>
  
  <p>Assembler code is <strong>md1.s</strong>:</p>
  
  <pre><code>.text
  .align  2
  .global asum
  .type   asum, %function
  
  asum:
      mov r1, #0
      mov r2, #1
  
  loop:
      cmp r2, #3 ; instead of 3 there should be my input
      bgt end
      add r1, r1, r2
      add r2, r2, #1
      b loop
  
  end:
      mov r0, r1
      bx lr
  </code></pre>
  
  <p>Just can't get it.</p>