Advertisement
Guest User

Untitled

a guest
Jan 28th, 2015
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int powerOf2(int, int*){
  5.     _asm{
  6.         mov esi, [ebp + 12]
  7.             mov ecx, [ebp + 8]
  8.             xor eax, eax
  9.         _loop :
  10.         dec ecx
  11.             cmp ecx, 0
  12.             jl finish
  13.             mov edi, [esi + ecx*4]
  14.             cmp edi, 0
  15.             jz _loop
  16.             mov ebx, edi
  17.             dec ebx
  18.             and ebx, edi
  19.             jnz _loop
  20.             inc eax
  21.             jmp _loop
  22.         finish :
  23.  
  24.     }
  25. }
  26.  
  27. int main()
  28. {
  29.     int n, v[25], nr;
  30.     cin >> n;
  31.     for (int i = 0; i < n; i++)
  32.         cin >> v[i];
  33.     _asm
  34.     {
  35.         lea edi, v;
  36.         push v;
  37.         push n;
  38.         call powerOf2;
  39.         add esp, 8;
  40.         mov nr, eax;
  41.     }
  42.     cout << nr;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement