fork download
  1. #include <stdio.h>
  2.  
  3. void swap(int &p, int &q){
  4. int temp;
  5. temp = p;
  6. p = q;
  7. q = temp;
  8. }
  9.  
  10. void swap_asm(int &p, int &q){
  11. __asm{
  12. mov eax, p
  13. mov ebx, q
  14. mov q, eax
  15. mov p, ebx
  16. };
  17. }
  18.  
  19. int main(){
  20. int p, q;
  21.  
  22. p = 2;
  23. q = 3;
  24. /*__asm{
  25. mov eax, p
  26. mov ebx, q
  27. mov q, eax
  28. mov p, ebx
  29. };*/
  30.  
  31. swap_asm(p, q);
  32.  
  33.  
  34. printf("p = %d, q = %d", p, q);
  35. scanf("%d", &p);
  36. return 0;
  37. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'void swap_asm(int&, int&)':
prog.cpp:11:7: error: expected '(' before '{' token
  __asm{
       ^
prog.cpp:12:3: error: 'mov' was not declared in this scope
   mov eax, p
   ^
stdout
Standard output is empty