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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
[BITS 64]
segment .data
GenuineIntel db "GenuineIntel",0
AuthenticAMD db "AuthenticAMD",0
segment .bss
segment .text
global ?Init@CpuInfo@zwl@@QEAAXXZ
extern strcmp
;void zwl::CpuInfo::Init(void)
?Init@CpuInfo@zwl@@QEAAXXZ:
push rbp
mov rbp, rsp
push rbx
push rsi
%ifdef ZEWEL_SYSTEM_WINDOWS
mov rsi, rcx;put this into rsi
%endif
%ifdef ZEWEL_SYSTEM_LINUX
mov rsi, rdi
%endif
mov eax, 0
cpuid
mov [rsi], ebx
mov [rsi+4], edx
mov [rsi+8], ecx
mov byte [rsi+12], 0;brandName is now known
mov eax, 1
cpuid;going to test the support of some instructions sets
; supportMMX = true;
; supportSSE = true;
; supportSSE2 = true;
; if(ecx & 00000001h != 0)
; {
; supportSSE3 = true;
; }
mov byte [rsi+13], 1
mov byte [rsi+17], 1
mov byte [rsi+18], 1
test ecx, 00000001h
jz NO_SSE3
mov byte [rsi+19], 1
NO_SSE3:
;if(strcmp(brandName, "GenuineIntel", 12) == 0)
;{
; cpuid 1h_eax
; if(ecx & 00000200h != 0)
; {
; supportSSSE3 = true;
; if(ecx & 00080000h != 0)
; {
; supportSSE4 = true;
; }
; }
;}
%ifdef ZEWEL_SYSTEM_WINDOWS
mov rcx, rsi
mov rdx, GenuineIntel
%endif
%ifdef ZEWEL_SYSTEM_LINUX
push rsi
mov rdi, rsi
mov rsi, GenuineIntel
%endif
call strcmp
%ifdef ZEWEL_SYSTEM_LINUX
pop rsi
%endif
cmp rax, 0
jne NOT_INTEL_PROC
mov eax, 1
cpuid
test ecx, 00000200h
jz NO_SSSE3
mov byte [rsi+20], 1
test ecx, 00080000h
jz NO_SSE4
mov byte [rsi+21], 1
NO_SSE4:
NO_SSSE3:
NOT_INTEL_PROC:
;if(strcmp(brandName, "AuthenticAmd) == 0)
;{
; cpuid 80000001h_eax
; if(edx & 00800000h != 0)
; {
; supportMMXExt = true;
; }
; if(edx & 80000000h != 0)
; {
; support3DNOW = true;
; if(edx & 40000000h != 0)
; {
; support3DNOWExt = true;
; }
; }
;}
%ifdef ZEWEL_SYSTEM_WINDOWS
mov rcx, rsi
mov rdx, AuthenticAMD
%endif
%ifdef ZEWEL_SYSTEM_LINUX
push rsi
mov rdi, rsi
mov rsi, AuthenticAMD
%endif
call strcmp
%ifdef ZEWEL_SYSTEM_LINUX
pop rsi
%endif
cmp rax, 0
jne NOT_AMD_PROC
mov eax, 80000001h
cpuid
test edx, 00800000h
jz NO_MMXEXT
mov byte [rsi+14], 1
NO_MMXEXT:
test edx, 80000000h
jz NO_3DNOW
mov byte [rsi+15], 1
test edx, 40000000h
jz NO_3DNOWEXT
mov byte [rsi+16], 1
NO_3DNOW:
NO_3DNOWEXT
NOT_AMD_PROC:
pop rsi
pop rbx
pop rbp
ret |
Partager