r.c 395 B

123456789101112131415161718192021222324
  1. // r2 contains the return value, r4 contains the argument
  2. int asmReturn(int x)
  3. {
  4. int retval = 0;
  5. asm("load 4 r3\n"
  6. "add r4 r3 r2 ;adding two regs\n"
  7. "sub r2 1 r2 ;remove one to get 10\n"
  8. "write -4 r14 r2 ;write to stack to return");
  9. return retval;
  10. }
  11. int main()
  12. {
  13. int a = asmReturn(7);
  14. return a; // should now be 10
  15. }
  16. void interrupt()
  17. {
  18. }