I have one to check ht support and core count, but is fasm. The only significant difference between fasm and masm is the use of brackets, so its not much difference.
; checks if HTT is supported on the cpu
; returns 0 in eax if not supported and 1 otherwise
proc HTSupport
xor eax,eax
cpuid
; check that functions 0-1 is at least supported as these are the ones we will use
cmp eax,1
jb .fail
; check that GenuineIntel, because intel is the only one that have hyper threading
cmp ebx,$756e6547 ; Genu
jne .fail
cmp edx,$49656e69 ; ineI
jne .fail
cmp ecx,$6c65746e ; ntel
jne .fail
; Now get HT flag in edx at bit 28 (zero based)
mov eax,1
cpuid
test edx,$10000000
jnz .succ
.fail: xor eax,eax
ret
.succ: mov eax,1
.bye: ret
endp
; Return the accurate number of cores (HT is checked too)
proc CoreCount
local ht rd 1
local s SYSTEM_INFO
stdcall HTSupport
mov [ht],eax
lea eax,[s]
invoke GetSystemInfo,eax
mov eax,[s.dwNumberOfProcessors]
mov ecx,[ht]
test ecx,ecx
jz @F
shr eax,1
@@: ret
endp