-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCPU_Logical_Cores.asm
82 lines (66 loc) · 1.47 KB
/
CPU_Logical_Cores.asm
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
;==============================================================================
;
; UASM64 Library
;
; https://github.com/mrfearless/UASM64-Library
;
;==============================================================================
.686
.MMX
.XMM
.x64
option casemap : none
IF @Platform EQ 1
option win64 : 11
ENDIF
option frame : auto
include UASM64.inc
.CODE
UASM64_ALIGN
;------------------------------------------------------------------------------
; CPU_Logical_Cores
;
; Return the number of logical cores, if supported.
;
; Parameters:
;
; There are no parameters.
;
; Returns:
;
; RAX contains number of logical cores if supported, or 0 otherwise.
;
; Notes:
;
; https://en.wikipedia.org/wiki/CPUID#EAX=4_and_EAX=Bh:_Intel_thread/core_and_cache_topology
;
; See Also:
;
; CPU_Basic_Features, CPU_Signature, CPU_CPUID_Supported, CPU_HTT_Supported
;
;------------------------------------------------------------------------------
CPU_Logical_Cores PROC FRAME USES RBX RCX RDX
Invoke CPU_CPUID_Supported
.IF rax == FALSE
jmp CPU_Logical_Cores_Error
.ENDIF
Invoke CPU_HTT_Supported
.IF rax == FALSE
jmp CPU_Logical_Cores_Error
.ENDIF
xor rax, rax
xor rbx, rbx
xor rcx, rcx
xor rdx, rdx
mov eax, 1
cpuid
and ebx, 00FF0000h
mov eax, ebx
shr eax, 16
jmp CPU_Logical_Cores_Exit
CPU_Logical_Cores_Error:
mov rax, 0
CPU_Logical_Cores_Exit:
ret
CPU_Logical_Cores ENDP
END