Advertisement
Artcik

Untitled

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