Cooler_

wtf asm

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