Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.     int x = 250;
  5.     int y;
  6.  
  7.     asm volatile(
  8.         ".intel_syntax noprefix;"
  9.         "mov eax, %1;"
  10.         "mov ebx, 33;"
  11.         "xor edx, edx;"
  12.         "xor ecx, ecx;"
  13.         "loopstart:"
  14.         "xor edx, edx;"
  15.         "dec ebx;"
  16.         "jz finish;"
  17.         "innerloop:"
  18.         "shl eax, 1;"
  19.         "jnc loopstart;"
  20.         "inc edx;"
  21.         "cmp edx, ecx;"
  22.         "jl innerloop;"
  23.         "mov ecx, edx;"
  24.         "jmp innerloop;"
  25.         "finish:"
  26.         "mov %0, ecx;"
  27.         ".att_syntax prefix;"
  28.         :"=r"(y)
  29.         :"r"(x)
  30.         :"eax", "ebx", "ecx", "edx"
  31.         );
  32.  
  33.         printf("y=%i\n", y);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement