[svn] / branches / dev-api-4 / xvidcore / src / utils / x86_asm / cpuid.asm Repository:
ViewVC logotype

Annotation of /branches/dev-api-4/xvidcore/src/utils/x86_asm/cpuid.asm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 886 - (view) (download)

1 : Isibaar 3 ;/******************************************************************************
2 : edgomez 851 ; * *
3 :     ; * This file is part of XviD, a free MPEG-4 video encoder/decoder *
4 :     ; * *
5 :     ; * XviD is an implementation of a part of one or more MPEG-4 Video tools *
6 :     ; * as specified in ISO/IEC 14496-2 standard. Those intending to use this *
7 :     ; * software module in hardware or software products are advised that its *
8 :     ; * use may infringe existing patents or copyrights, and any such use *
9 :     ; * would be at such party's own risk. The original developer of this *
10 :     ; * software module and his/her company, and subsequent editors and their *
11 :     ; * companies, will have no liability for use of this software or *
12 :     ; * modifications or derivatives thereof. *
13 :     ; * *
14 :     ; * XviD is free software; you can redistribute it and/or modify it *
15 :     ; * under the terms of the GNU General Public License as published by *
16 :     ; * the Free Software Foundation; either version 2 of the License, or *
17 :     ; * (at your option) any later version. *
18 :     ; * *
19 :     ; * XviD is distributed in the hope that it will be useful, but *
20 :     ; * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 :     ; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22 :     ; * GNU General Public License for more details. *
23 :     ; * *
24 :     ; * You should have received a copy of the GNU General Public License *
25 :     ; * along with this program; if not, write to the Free Software *
26 :     ; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
27 :     ; * *
28 : Isibaar 3 ; ******************************************************************************/
29 : edgomez 851 ;
30 :     ;/******************************************************************************
31 :     ; * *
32 :     ; * cpuid.asm, check cpu features *
33 :     ; * *
34 :     ; * Copyright (C) 2001 - Michael Militzer <isibaar@xvid.org>, *
35 :     ; * *
36 :     ; * For more information visit the XviD homepage: http://www.xvid.org *
37 :     ; * *
38 :     ; ******************************************************************************/
39 :     ;
40 :     ;/******************************************************************************
41 :     ; * *
42 :     ; * Revision history: *
43 :     ; * *
44 :     ; * 17.12.2001 initial version (Isibaar) *
45 :     ; * *
46 :     ; ******************************************************************************/
47 : Isibaar 3
48 :     bits 32
49 :    
50 :     %define CPUID_TSC 0x00000010
51 :     %define CPUID_MMX 0x00800000
52 :     %define CPUID_SSE 0x02000000
53 :     %define CPUID_SSE2 0x04000000
54 :    
55 :     %define EXT_CPUID_3DNOW 0x80000000
56 :     %define EXT_CPUID_AMD_3DNOWEXT 0x40000000
57 :     %define EXT_CPUID_AMD_MMXEXT 0x00400000
58 :    
59 :     %define XVID_CPU_MMX 0x00000001
60 :     %define XVID_CPU_MMXEXT 0x00000002
61 :     %define XVID_CPU_SSE 0x00000004
62 :     %define XVID_CPU_SSE2 0x00000008
63 :     %define XVID_CPU_3DNOW 0x00000010
64 :     %define XVID_CPU_3DNOWEXT 0x00000020
65 :     %define XVID_CPU_TSC 0x00000040
66 :    
67 :    
68 : suxen_drol 309 %macro cglobal 1
69 : Isibaar 3 %ifdef PREFIX
70 : suxen_drol 309 global _%1
71 : Isibaar 3 %define %1 _%1
72 :     %else
73 :     global %1
74 :     %endif
75 :     %endmacro
76 :    
77 :     ALIGN 32
78 :    
79 :     section .data
80 :    
81 :     vendorAMD db "AuthenticAMD"
82 :    
83 :     %macro CHECK_FEATURE 3
84 :    
85 :     mov ecx, %1
86 :     and ecx, edx
87 :     neg ecx
88 :     sbb ecx, ecx
89 :     and ecx, %2
90 : suxen_drol 309 or %3, ecx
91 : Isibaar 3
92 :     %endmacro
93 :    
94 :     section .text
95 :    
96 :     ; int check_cpu_feature(void)
97 :    
98 :     cglobal check_cpu_features
99 :     check_cpu_features:
100 :    
101 : suxen_drol 309 push ebx
102 :     push esi
103 :     push edi
104 :     push ebp
105 :    
106 :     xor ebp,ebp
107 :    
108 : Isibaar 3 ; CPUID command ?
109 : suxen_drol 309 pushfd
110 : Isibaar 3 pop eax
111 :     mov ecx, eax
112 :     xor eax, 0x200000
113 :     push eax
114 :     popfd
115 :     pushfd
116 :     pop eax
117 :     cmp eax, ecx
118 :    
119 :     jz near .cpu_quit ; no CPUID command -> exit
120 :    
121 :    
122 :     ; get vendor string, used later
123 :     xor eax, eax
124 : suxen_drol 309 cpuid
125 :     mov [esp-12], ebx ; vendor string
126 :     mov [esp-12+4], edx
127 :     mov [esp-12+8], ecx
128 : Isibaar 3 test eax, eax
129 :    
130 :     jz near .cpu_quit
131 :    
132 : suxen_drol 309 mov eax, 1
133 : Isibaar 3 cpuid
134 :    
135 :     ; RDTSC command ?
136 : suxen_drol 309 CHECK_FEATURE CPUID_TSC, XVID_CPU_TSC, ebp
137 : Isibaar 3
138 :     ; MMX support ?
139 : suxen_drol 309 CHECK_FEATURE CPUID_MMX, XVID_CPU_MMX, ebp
140 : Isibaar 3
141 :     ; SSE support ?
142 : suxen_drol 309 CHECK_FEATURE CPUID_SSE, (XVID_CPU_MMXEXT|XVID_CPU_SSE), ebp
143 : Isibaar 3
144 :     ; SSE2 support?
145 : suxen_drol 309 CHECK_FEATURE CPUID_SSE2, XVID_CPU_SSE2, ebp
146 : Isibaar 3
147 :     ; extended functions?
148 :     mov eax, 0x80000000
149 :     cpuid
150 :     cmp eax, 0x80000000
151 :     jbe near .cpu_quit
152 :    
153 :     mov eax, 0x80000001
154 :     cpuid
155 :    
156 :     ; AMD cpu ?
157 :     lea esi, [vendorAMD]
158 : suxen_drol 309 lea edi, [esp-12]
159 : Isibaar 3 mov ecx, 12
160 :     cld
161 :     repe cmpsb
162 :     jnz .cpu_quit
163 :    
164 : suxen_drol 309 ; 3DNow! support ?
165 :     CHECK_FEATURE EXT_CPUID_3DNOW, XVID_CPU_3DNOW, ebp
166 :    
167 : Isibaar 3 ; 3DNOW extended ?
168 : suxen_drol 309 CHECK_FEATURE EXT_CPUID_AMD_3DNOWEXT, XVID_CPU_3DNOWEXT, ebp
169 : Isibaar 3
170 :     ; extended MMX ?
171 : suxen_drol 309 CHECK_FEATURE EXT_CPUID_AMD_MMXEXT, XVID_CPU_MMXEXT, ebp
172 : Isibaar 3
173 : suxen_drol 309 .cpu_quit:
174 :    
175 :     mov eax, ebp
176 :    
177 :     pop ebp
178 :     pop edi
179 :     pop esi
180 :     pop ebx
181 :    
182 : Isibaar 3 ret
183 : suxen_drol 309
184 :    
185 :    
186 :     ; sse/sse2 operating support detection routines
187 :     ; these will trigger an invalid instruction signal if not supported.
188 :    
189 :     cglobal sse_os_trigger
190 :     align 16
191 :     sse_os_trigger:
192 :     xorps xmm0, xmm0
193 :     ret
194 :    
195 :    
196 :     cglobal sse2_os_trigger
197 :     align 16
198 :     sse2_os_trigger:
199 :     xorpd xmm0, xmm0
200 :     ret
201 :    
202 : edgomez 851
203 :     ; enter/exit mmx state
204 :    
205 :     cglobal emms_mmx
206 :     align 16
207 :     emms_mmx:
208 :     emms
209 :     ret
210 :    
211 :     ; faster enter/exit mmx state
212 :    
213 :     cglobal emms_3dn
214 :     align 16
215 :     emms_3dn:
216 :     femms
217 :     ret

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4