-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCPU_Brand.asm
134 lines (114 loc) · 2.83 KB
/
CPU_Brand.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
;==============================================================================
;
; 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
;DEBUG64 EQU 1
;
;IFDEF DEBUG64
; PRESERVEXMMREGS equ 1
; includelib \UASM\lib\x64\Debug64.lib
; DBG64LIB equ 1
; DEBUGEXE textequ <'\UASM\bin\DbgWin.exe'>
; include \UASM\include\debug64.inc
; .DATA
; RDBG_DbgWin DB DEBUGEXE,0
; .CODE
;ENDIF
include UASM64.inc
.DATA
qwCPU_Brand_Run DQ -1
szCPU_Brand_String DB 48 DUP (0)
.CODE
UASM64_ALIGN
;------------------------------------------------------------------------------
; CPU_Brand
;
; Return a string with the CPU brand.
;
; Parameters:
;
; There are no parameters.
;
; Returns:
;
; RAX contains a pointer to a string containing the CPU brand or 0 if not
; supported.
;
; Notes:
;
; https://en.wikipedia.org/wiki/CPUID#EAX=80000002h,80000003h,80000004h:_Processor_Brand_String
;
; See Also:
;
; CPU_Manufacturer, CPU_ManufacturerID, CPU_Signature, CPU_CPUID_Supported, CPU_Logical_Cores
;
;------------------------------------------------------------------------------
CPU_Brand PROC FRAME USES RBX RCX RDX RDI
LOCAL idx:QWORD
Invoke CPU_CPUID_Supported
.IF rax == FALSE
jmp CPU_Brand_Error
.ENDIF
Invoke CPU_Highest_Extended
.IF rax == 0 || sqword ptr rax < 080000004h
jmp CPU_Brand_Error
.ENDIF
.IF qwCPU_Brand_Run == -1
; Only need to do this once
xor rax, rax
xor rbx, rbx
xor rcx, rcx
xor rdx, rdx
mov eax, 80000002h
cpuid
; Zero out string
lea rdi, szCPU_Brand_String
mov rax, 0
mov qword ptr [rdi+00d], rax
;mov qword ptr [rdi+04d], rax
mov qword ptr [rdi+08d], rax
;mov qword ptr [rdi+12d], rax
mov qword ptr [rdi+16d], rax
;mov qword ptr [rdi+20d], rax
mov qword ptr [rdi+24d], rax
;mov qword ptr [rdi+28d], rax
mov qword ptr [rdi+32d], rax
;mov qword ptr [rdi+36d], rax
mov qword ptr [rdi+40d], rax
;mov qword ptr [rdi+44d], rax
mov idx, 80000002h
CPU_Brand_Next:
xor rax, rax
mov rax, idx
cpuid
mov dword ptr [rdi], eax
mov dword ptr [rdi+4], ebx
mov dword ptr [rdi+8], ecx
mov dword ptr [rdi+12], edx
add rdi, 16
add idx, 1
cmp idx, 80000004h
jna CPU_Brand_Next
mov qwCPU_Brand_Run, 1
.ENDIF
lea rax, szCPU_Brand_String
jmp CPU_Brand_Exit
CPU_Brand_Error:
mov qwCPU_Brand_Run, 0
mov rax, 0
CPU_Brand_Exit:
ret
CPU_Brand ENDP
END