Cooler_

lol

Mar 20th, 2012
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. /*
  2.  
  3. how to fix this ?
  4.  
  5. [cooler@coolerlab asm]$ gcc -o test test.c -masm=intel
  6. /tmp/ccpTHIx9.s: Assembler messages:
  7. /tmp/ccpTHIx9.s:60: Error: junk `PTR [ebp+8]' after expression
  8. /tmp/ccpTHIx9.s:60: Error: too many memory references for `mov'
  9. /tmp/ccpTHIx9.s:61: Error: too many memory references for `mov'
  10. [cooler@coolerlab asm]$ cat test.c
  11. */
  12. #include <stdio.h>
  13.  
  14. int Add(int x, int y);
  15.  
  16. int main()
  17. {
  18.  printf("%d \n",  add(2,3));
  19.  return 0;
  20. }
  21.  
  22. int Add(int x, int y)
  23. {
  24.  __asm__(
  25.  ".intel_syntax noprefix\n"
  26.  "mov eax,%1\n"
  27.  "mov ebx,%2\n"
  28.  "add eax,ebx\n"
  29.  "mov %0,eax\n"
  30.  ".att_syntax\n"
  31.  : "=r"(x) : "a"(x), "b"(y)
  32.  );
  33.     return x;
  34. }
  35. [cooler@coolerlab asm]$
Advertisement
Add Comment
Please, Sign In to add comment