int Math::test_iadd(int a, int { __asm volatile ( "add r0, %0, %1 \n\t" : : "r" (a), "r" ( : "r0" );}
int Math::test_iadd2(int a, int { int ret; __asm volatile ( "add %0, %1, %2 \n\t" : "=r" (ret) : "r" (a), "r" ( : "r0" ); return ret;}
I could be wrong, but I believe that this code does not actually guarantee that the output ends up in r0. The register identities in the assembler are symbolic rather than actual register names, and I'm not sure how they actually get resolved to real registers. It's the logical output however, so it happens to work.Your second function is certainly the way I would write the return code.