1
|
1
|
|
2 / ---------------------------------------------------------------------------
|
734
|
3 / Cpu function detect by Pontscho/fresh!mindworkz (c) 2000 - 2000
|
|
4 / 3dnow-dsp detection by Nick Kurshev (C) 2001
|
1
|
5 / ---------------------------------------------------------------------------
|
|
6
|
|
7 .text
|
|
8
|
|
9 .globl CpuDetect
|
|
10 .globl ipentium
|
|
11 .globl a3dnow
|
|
12
|
|
13 / ---------------------------------------------------------------------------
|
|
14 / in C: unsigned long CpuDetect( void );
|
|
15 / return: cpu ident number.
|
|
16 / ---------------------------------------------------------------------------
|
|
17 CpuDetect:
|
|
18 pushl %ebx
|
|
19 pushl %ecx
|
|
20 pushl %edx
|
|
21
|
738
|
22 pushfl
|
|
23 popl %eax
|
|
24 movl %eax,%ebx
|
|
25 xorl $0x00200000,%eax
|
|
26 pushl %eax
|
|
27 popfl
|
|
28 pushfl
|
|
29 popl %eax
|
|
30 cmpl %eax,%ebx
|
|
31 jz no_cpuid_cpudetect
|
|
32
|
|
33 movl $1,%eax
|
1
|
34 cpuid
|
738
|
35
|
|
36 jmp exit_cpudetect
|
|
37 no_cpuid_cpudetect:
|
|
38 xorl %eax,%eax
|
|
39 exit_cpudetect:
|
1
|
40
|
|
41 popl %edx
|
|
42 popl %ecx
|
|
43 popl %ebx
|
|
44 ret
|
|
45
|
|
46 / ---------------------------------------------------------------------------
|
|
47 / in C: unsigled long ipentium( void );
|
|
48 / return: 0 if the processor is not P5 or above else above 1.
|
|
49 / ---------------------------------------------------------------------------
|
|
50 ipentium:
|
|
51 pushl %ebx
|
|
52 pushl %ecx
|
|
53 pushl %edx
|
|
54 pushfl
|
|
55 popl %eax
|
|
56 movl %eax,%ebx
|
|
57 xorl $0x00200000,%eax
|
|
58 pushl %eax
|
|
59 popfl
|
|
60 pushfl
|
|
61 popl %eax
|
|
62 cmpl %eax,%ebx
|
|
63 jz no_cpuid
|
|
64 movl $1,%eax
|
|
65 cpuid
|
|
66 shrl $8,%eax
|
|
67 cmpl $5,%eax
|
|
68 jb no_cpuid
|
|
69 movl $1,%eax
|
|
70 jmp exit
|
|
71 no_cpuid:
|
|
72 xorl %eax,%eax
|
|
73 exit:
|
|
74 popl %edx
|
|
75 popl %ecx
|
|
76 popl %ebx
|
|
77 ret
|
|
78
|
|
79 / ---------------------------------------------------------------------------
|
|
80 / in C: unsigned long a3dnow( void );
|
734
|
81 / return: 0 if this processor does not support 3dnow!
|
|
82 / 1 otherwise
|
|
83 / 2 if this cpu supports 3dnow-dsp extension
|
1
|
84 / ---------------------------------------------------------------------------
|
|
85 a3dnow:
|
|
86 pushl %ebx
|
|
87 pushl %edx
|
|
88 pushl %ecx
|
|
89
|
|
90
|
|
91 call ipentium
|
734
|
92 testl %eax,%eax
|
|
93 jz exit2
|
1
|
94
|
|
95 movl $0x80000000,%eax
|
|
96 cpuid
|
|
97 cmpl $0x80000000,%eax
|
734
|
98 jbe exit2
|
1
|
99 movl $0x80000001,%eax
|
|
100 cpuid
|
734
|
101 xorl %eax,%eax
|
1
|
102 testl $0x80000000,%edx
|
734
|
103 jz exit2
|
|
104 /// eax=1 - K6 3DNow!
|
|
105 inc %eax
|
|
106 testl $0x40000000,%edx
|
|
107 jz exit2
|
|
108 /// eax=2 - K7 3DNowEx!
|
|
109 inc %eax
|
1
|
110 exit2:
|
|
111
|
|
112 popl %ecx
|
|
113 popl %edx
|
|
114 popl %ebx
|
|
115 ret
|