1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
__declspec(naked) int my_bitcount(unsigned long long a ){
__asm {
push ebp
mov ebp, esp
sub esp, __LOCAL_SIZE
push ecx
xor eax, eax
mov edx, dword ptr 8[ebp]
test edx, edx
je SHORT L2
L1:
mov ecx, edx
sub edx, 1
add eax, 1
and edx, ecx
jne SHORT L1
L2:
mov edx, dword ptr 8[ebp + 4]
test edx, edx
je SHORT L4
L3:
mov ecx, edx
sub edx, 1
add eax, 1
and edx, ecx
jne SHORT L3
L4:
pop ecx
mov esp, ebp
pop ebp
ret
}
}
|