-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCPU_CPUID_Supported.asm
More file actions
86 lines (72 loc) · 1.79 KB
/
CPU_CPUID_Supported.asm
File metadata and controls
86 lines (72 loc) · 1.79 KB
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
82
83
84
85
;==============================================================================
;
; 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
.DATA
CPUID_SUPPORTED DQ -1
.CODE
UASM64_ALIGN
;------------------------------------------------------------------------------
; CPU_CPUID_Supported
;
; Check if the CPUID instruction is supported.
;
; Parameters:
;
; There are no parameters.
;
; Returns:
;
; TRUE if the CPUID instruction is supported, or FALSE otherwise.
;
; Notes:
;
; https://en.wikipedia.org/wiki/CPUID
;
; See Also:
;
; CPU_Manufacturer, CPU_ManufacturerID, CPU_Signature, CPU_Brand, CPU_Logical_Cores
;
;------------------------------------------------------------------------------
CPU_CPUID_Supported PROC FRAME USES RBX RCX RDX
.IF CPUID_SUPPORTED == -1
; do this once
xor rax, rax
xor rbx, rbx
xor rcx, rcx
xor rdx, rdx
pushfq ; push rflags on the stack
pop rax ; pop them into rax
xor rax, 200000h ; toggle bit 21
push rax ; push the toggled rflags
popfq ; pop them back into rflags
pushfq ; push rflags
pop rax ; pop them back into rax
cmp rax, rbx ; see if bit 21 was reset
jz CPU_CPUID_Supported_No
mov CPUID_SUPPORTED, 1
mov rax, 1
.ELSE
mov rax, CPUID_SUPPORTED
.ENDIF
jmp CPU_CPUID_Supported_Exit
CPU_CPUID_Supported_No:
mov CPUID_SUPPORTED, 0
xor rax, rax
CPU_CPUID_Supported_Exit:
ret
CPU_CPUID_Supported ENDP
END