comparison mp3lib/d_cpu.s @ 1:3b5f5d1c5041

Initial revision
author arpi_esp
date Sat, 24 Feb 2001 20:28:24 +0000
parents
children bab1d9b1056a
comparison
equal deleted inserted replaced
0:c1bb2c071d63 1:3b5f5d1c5041
1
2 / ---------------------------------------------------------------------------
3 / Cpu function detect by Pontscho/fresh!mindworkz
4 / (c) 2000 - 2000
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
22 movl $1,%eax
23 cpuid
24
25 popl %edx
26 popl %ecx
27 popl %ebx
28 ret
29
30 / ---------------------------------------------------------------------------
31 / in C: unsigled long ipentium( void );
32 / return: 0 if the processor is not P5 or above else above 1.
33 / ---------------------------------------------------------------------------
34 ipentium:
35 pushl %ebx
36 pushl %ecx
37 pushl %edx
38 pushfl
39 popl %eax
40 movl %eax,%ebx
41 xorl $0x00200000,%eax
42 pushl %eax
43 popfl
44 pushfl
45 popl %eax
46 cmpl %eax,%ebx
47 jz no_cpuid
48 movl $1,%eax
49 cpuid
50 shrl $8,%eax
51 cmpl $5,%eax
52 jb no_cpuid
53 movl $1,%eax
54 jmp exit
55 no_cpuid:
56 xorl %eax,%eax
57 exit:
58 popl %edx
59 popl %ecx
60 popl %ebx
61 ret
62
63 / ---------------------------------------------------------------------------
64 / in C: unsigned long a3dnow( void );
65 / return: 0 if this processor not requiment 3dnow! else above 1.
66 / ---------------------------------------------------------------------------
67 a3dnow:
68 pushl %ebx
69 pushl %edx
70 pushl %ecx
71
72
73 call ipentium
74 shrl $1,%eax
75 jnc no_3dnow
76
77 movl $0x80000000,%eax
78 cpuid
79 cmpl $0x80000000,%eax
80 jbe no_3dnow
81 movl $0x80000001,%eax
82 cpuid
83 testl $0x80000000,%edx
84 jz no_3dnow
85 movl $1,%eax
86 jmp exit2
87 no_3dnow:
88 xorl %eax,%eax
89 exit2:
90
91 popl %ecx
92 popl %edx
93 popl %ebx
94 ret