Cooler_

ASM error wtf

Mar 19th, 2012
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.33 KB | None | 0 0
  1. /*
  2.  * to run,  "gcc -o code code.c -masm=intel"
  3.  * Cooler's ASM test
  4.  *
  5.  */
  6. #include <stdio.h>
  7.  
  8. int Add(int x, int y)
  9. {
  10.  __asm__(
  11.   ".intel_syntax noprefix"
  12.   "mov eax,x"
  13.   "mov ebx,y"
  14.   "add eax,ebx"
  15.   "mov x,eax"
  16.   ".att_syntax"
  17.  );
  18.    
  19.  return x;
  20. }
  21.  
  22. int main()
  23. {
  24.  printf(" resultado: %d \n",Add(2,3));
  25.  return 0;
  26. }
  27. /*
  28. ERROR LOG WTF
  29. [cooler@coolerlab asm]$ gcc -o add add.c -masm=intel
  30. /tmp/ccCmXEA3.s: Assembler messages:
  31. /tmp/ccCmXEA3.s:34: Error: too many memory references for `mov'
  32. /tmp/ccCmXEA3.s:54: Error: too many memory references for `mov'
  33. /tmp/ccCmXEA3.s:56: Error: too many memory references for `and'
  34. /tmp/ccCmXEA3.s:57: Error: too many memory references for `sub'
  35. /tmp/ccCmXEA3.s:58: Error: junk `PTR [esp+4]' after expression
  36. /tmp/ccCmXEA3.s:58: Error: too many memory references for `mov'
  37. /tmp/ccCmXEA3.s:59: Error: junk `PTR [esp]' after expression
  38. /tmp/ccCmXEA3.s:59: Error: too many memory references for `mov'
  39. /tmp/ccCmXEA3.s:61: Error: too many memory references for `mov'
  40. /tmp/ccCmXEA3.s:62: Error: junk `PTR [esp+4]' after expression
  41. /tmp/ccCmXEA3.s:62: Error: too many memory references for `mov'
  42. /tmp/ccCmXEA3.s:63: Error: junk `PTR [esp]' after expression
  43. /tmp/ccCmXEA3.s:63: Error: too many memory references for `mov'
  44. /tmp/ccCmXEA3.s:65: Error: too many memory references for `mov'
  45. */
Advertisement
Add Comment
Please, Sign In to add comment