This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

asm inserts

Hello! How can i insert necessary for me asm comands like push/pop? for example i got example from here www.keil.com/.../armclang_ref_chr1383658400125.htm

int add(int i, int j)
{
  int res = 0;
  __asm (
    "ADD %[result], %[input_i], %[input_j]"
    : [result] "=r" (res)
    : [input_i] "r" (i), [input_j] "r" (j)
  );
  return res;
}

int main(void)
{
  int a = 1;
  int b = 2;
  int c = 0;

  c = add(a,b);
}


End got a error: Source\main.c(21): error: #18: expected a ")" :D .

But it was strange syntax for me. Then I do next:

int main(void)
{
   __asm
   {
      nop
      nop
   }

}


So it works well, but as sson as I add push/pop or use any registers automaticly catch error

   __asm
   {
      push {lr}       //!!!
      nop
      nop
      add  r0, r1     //!!!
      pop  {lr}       //!!!
   }


Can i dissable this error? I'll be able to cortol stack by myself.

Parents Reply Children