Guest User

Untitled

a guest
Oct 13th, 2017
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.  
  5.  
  6. int x = 0xba13;
  7. int y;
  8.  
  9. asm volatile(
  10.  
  11. ".intel_syntax noprefix;"
  12. "mov eax, %1;"
  13. "xor ebx,ebx;" //zerowanie ebx
  14. "petla:"
  15. "shr eax,1;"
  16. "jnc skok;"
  17. "shr eax,0;"
  18. "jnc skok2;"
  19. "shr eax,1;"
  20. "jnc skok3;"
  21. "inc ebx;"
  22. "skok:"
  23. "cmp eax,0;"
  24. "jnz petla;"
  25. "skok2:"
  26. "cmp eax,0;"
  27. "jz petla;"
  28. "skok3:"
  29. "cmp eax,0;"
  30. "jnz petla;"
  31. "mov %0, ebx;"
  32. ".att_syntax prefix;"
  33. :"=r"(y)
  34. :"r"(x)
  35. :"eax","ebx"
  36.  
  37. );
  38.  
  39. printf("x = %x\ny = %d\n",x,y);
  40. return 0;
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment