-
Notifications
You must be signed in to change notification settings - Fork 3
/
CPU_Highest_Extended.asm
80 lines (63 loc) · 1.65 KB
/
CPU_Highest_Extended.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
;==============================================================================
;
; 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
CPU_HIGHEST_EXTENDED_LEVEL DQ -1
.CODE
UASM64_ALIGN
;------------------------------------------------------------------------------
; CPU_Highest_Extended
;
; Returns the highest value for extended processor information available.
;
; Parameters:
;
; There are no parameters.
;
; Returns:
;
; 0 if CPUID is not supported, otherwise the highest extended information (the
; value used in eax for CPUID to obtain extended information from a particular
; leaf = 80000000h upwards)
;
;------------------------------------------------------------------------------
CPU_Highest_Extended PROC FRAME USES RBX RCX RDX
Invoke CPU_CPUID_Supported
.IF rax == FALSE
mov CPU_HIGHEST_EXTENDED_LEVEL, 0
jmp CPU_Highest_Extended_Error
.ENDIF
mov rax, CPU_HIGHEST_EXTENDED_LEVEL
.IF CPU_HIGHEST_EXTENDED_LEVEL == -1
xor rax, rax
xor rbx, rbx
xor rcx, rcx
xor rdx, rdx
mov eax, 080000000h
cpuid
mov CPU_HIGHEST_EXTENDED_LEVEL, rax
.ELSE
; save result so we dont have to keep doing cpuid call
mov rax, CPU_HIGHEST_EXTENDED_LEVEL
.ENDIF
jmp CPU_Highest_Extended_Exit
CPU_Highest_Extended_Error:
mov rax, 0
CPU_Highest_Extended_Exit:
ret
CPU_Highest_Extended ENDP
END