title: How to return a value of a register from ARM assembly to a C function?
body: <p>for example </p>
  
  <pre><code>extern int addfunction(int,int);
  main() {
    int a = 5, b = 6, z;
    z = addfunction(a, b);
    printf("%d", c);
  }
  </code></pre>
  
  <p><code>addfunction()</code>'s defintion in another .s file like</p>
  
  <pre><code>.global addfunction
  addfunction:
      @ value a will be in R0 &amp; R1 respectively
      add r2, r0, r1    @ r2=r0+r1
  </code></pre>
  
  <p>Now how to return value stored <code>r2</code> so that variable <code>z</code> in the C program will get correct the value? I am able to do with pointer from C and update the address in asm. I don't want this way. Help! </p>