; Taken from original Intel cpucount.cpp code
%macro cglobal 1
%ifdef PREFIX
global _%1
%define %1 _%1
%else
global %1
%endif
%endmacro
SECTION .text
;.....................................................
cglobal __MaxCorePerPhysicalProc__
;.....................................................
__MaxCorePerPhysicalProc__:
xor eax, eax
cpuid
cmp eax, 4 ;check if cpuid supports leaf 4
jl single_core ;Single core
mov eax, 4
mov ecx, 0 ;start with index = 0; Leaf 4 reports
cpuid ;at least one valid cache level
jmp multi_core
single_core:
xor eax, eax
multi_core:
ret
;.....................................................
cglobal __find_maskwidth__
;.....................................................
__find_maskwidth__:
enter 0, 0
push ebx ;\
push ecx ;\
push edx ;\
push edi ;\
push esi
mov eax, [ebp+8] ; first parameter to function
mov ecx, 0
dec eax
bsr cx, ax
jz next
inc cx
mov eax, ecx
next:
pop esi ;\
pop edi ;\
pop edx ;\
pop ecx ;\
pop ebx ;\
leave
ret
;.....................................................