[cvs] / xvidcore / src / utils / x86_asm / cpuid.asm Repository:
ViewVC logotype

Annotation of /xvidcore/src/utils/x86_asm/cpuid.asm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (view) (download)

1 : Isibaar 1.1 ;/******************************************************************************
2 : edgomez 1.3 ; *
3 :     ; * Copyright (C) 2001 - Michael Militzer <isibaar@xvid.org>
4 :     ; *
5 :     ; * This file is part of XviD, a free MPEG-4 video encoder/decoder
6 :     ; *
7 :     ; * XviD is free software; you can redistribute it and/or modify it
8 :     ; * under the terms of the GNU General Public License as published by
9 :     ; * the Free Software Foundation; either version 2 of the License, or
10 :     ; * (at your option) any later version.
11 :     ; *
12 :     ; * This program is distributed in the hope that it will be useful,
13 :     ; * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 :     ; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 :     ; * GNU General Public License for more details.
16 :     ; *
17 :     ; * You should have received a copy of the GNU General Public License
18 :     ; * along with this program; if not, write to the Free Software
19 :     ; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 :     ; *
21 :     ; * Under section 8 of the GNU General Public License, the copyright
22 :     ; * holders of XVID explicitly forbid distribution in the following
23 :     ; * countries:
24 :     ; *
25 :     ; * - Japan
26 :     ; * - United States of America
27 :     ; *
28 :     ; * Linking XviD statically or dynamically with other modules is making a
29 :     ; * combined work based on XviD. Thus, the terms and conditions of the
30 :     ; * GNU General Public License cover the whole combination.
31 :     ; *
32 :     ; * As a special exception, the copyright holders of XviD give you
33 :     ; * permission to link XviD with independent modules that communicate with
34 :     ; * XviD solely through the VFW1.1 and DShow interfaces, regardless of the
35 :     ; * license terms of these independent modules, and to copy and distribute
36 :     ; * the resulting combined work under terms of your choice, provided that
37 :     ; * every copy of the combined work is accompanied by a complete copy of
38 :     ; * the source code of XviD (the version of XviD used to produce the
39 :     ; * combined work), being distributed under the terms of the GNU General
40 :     ; * Public License plus this exception. An independent module is a module
41 :     ; * which is not derived from or based on XviD.
42 :     ; *
43 :     ; * Note that people who make modified versions of XviD are not obligated
44 :     ; * to grant this special exception for their modified versions; it is
45 :     ; * their choice whether to do so. The GNU General Public License gives
46 :     ; * permission to release a modified version without this exception; this
47 :     ; * exception also makes it possible to release a modified version which
48 :     ; * carries forward this exception.
49 :     ; *
50 :     ; * $Id$
51 : Isibaar 1.1 ; ******************************************************************************/
52 :    
53 :     bits 32
54 :    
55 :     %define CPUID_TSC 0x00000010
56 :     %define CPUID_MMX 0x00800000
57 :     %define CPUID_SSE 0x02000000
58 :     %define CPUID_SSE2 0x04000000
59 :    
60 :     %define EXT_CPUID_3DNOW 0x80000000
61 :     %define EXT_CPUID_AMD_3DNOWEXT 0x40000000
62 :     %define EXT_CPUID_AMD_MMXEXT 0x00400000
63 :    
64 :     %define XVID_CPU_MMX 0x00000001
65 :     %define XVID_CPU_MMXEXT 0x00000002
66 :     %define XVID_CPU_SSE 0x00000004
67 :     %define XVID_CPU_SSE2 0x00000008
68 :     %define XVID_CPU_3DNOW 0x00000010
69 :     %define XVID_CPU_3DNOWEXT 0x00000020
70 :     %define XVID_CPU_TSC 0x00000040
71 :    
72 :    
73 : suxen_drol 1.2 %macro cglobal 1
74 : Isibaar 1.1 %ifdef PREFIX
75 : suxen_drol 1.2 global _%1
76 : Isibaar 1.1 %define %1 _%1
77 :     %else
78 :     global %1
79 :     %endif
80 :     %endmacro
81 :    
82 :     ALIGN 32
83 :    
84 :     section .data
85 :    
86 :     vendorAMD db "AuthenticAMD"
87 :    
88 :     %macro CHECK_FEATURE 3
89 :    
90 :     mov ecx, %1
91 :     and ecx, edx
92 :     neg ecx
93 :     sbb ecx, ecx
94 :     and ecx, %2
95 : suxen_drol 1.2 or %3, ecx
96 : Isibaar 1.1
97 :     %endmacro
98 :    
99 :     section .text
100 :    
101 :     ; int check_cpu_feature(void)
102 :    
103 :     cglobal check_cpu_features
104 :     check_cpu_features:
105 : suxen_drol 1.2
106 :     push ebx
107 :     push esi
108 :     push edi
109 :     push ebp
110 :    
111 :     xor ebp,ebp
112 : Isibaar 1.1
113 :     ; CPUID command ?
114 : suxen_drol 1.2 pushfd
115 : Isibaar 1.1 pop eax
116 :     mov ecx, eax
117 :     xor eax, 0x200000
118 :     push eax
119 :     popfd
120 :     pushfd
121 :     pop eax
122 :     cmp eax, ecx
123 :    
124 :     jz near .cpu_quit ; no CPUID command -> exit
125 :    
126 :    
127 :     ; get vendor string, used later
128 :     xor eax, eax
129 : suxen_drol 1.2 cpuid
130 :     mov [esp-12], ebx ; vendor string
131 :     mov [esp-12+4], edx
132 :     mov [esp-12+8], ecx
133 : Isibaar 1.1 test eax, eax
134 :    
135 :     jz near .cpu_quit
136 :    
137 : suxen_drol 1.2 mov eax, 1
138 : Isibaar 1.1 cpuid
139 :    
140 :     ; RDTSC command ?
141 : suxen_drol 1.2 CHECK_FEATURE CPUID_TSC, XVID_CPU_TSC, ebp
142 : Isibaar 1.1
143 :     ; MMX support ?
144 : suxen_drol 1.2 CHECK_FEATURE CPUID_MMX, XVID_CPU_MMX, ebp
145 : Isibaar 1.1
146 :     ; SSE support ?
147 : suxen_drol 1.2 CHECK_FEATURE CPUID_SSE, (XVID_CPU_MMXEXT|XVID_CPU_SSE), ebp
148 : Isibaar 1.1
149 :     ; SSE2 support?
150 : suxen_drol 1.2 CHECK_FEATURE CPUID_SSE2, XVID_CPU_SSE2, ebp
151 : Isibaar 1.1
152 :     ; extended functions?
153 :     mov eax, 0x80000000
154 :     cpuid
155 :     cmp eax, 0x80000000
156 :     jbe near .cpu_quit
157 :    
158 :     mov eax, 0x80000001
159 :     cpuid
160 :    
161 :     ; AMD cpu ?
162 :     lea esi, [vendorAMD]
163 : suxen_drol 1.2 lea edi, [esp-12]
164 : Isibaar 1.1 mov ecx, 12
165 :     cld
166 :     repe cmpsb
167 :     jnz .cpu_quit
168 :    
169 : suxen_drol 1.2 ; 3DNow! support ?
170 :     CHECK_FEATURE EXT_CPUID_3DNOW, XVID_CPU_3DNOW, ebp
171 :    
172 : Isibaar 1.1 ; 3DNOW extended ?
173 : suxen_drol 1.2 CHECK_FEATURE EXT_CPUID_AMD_3DNOWEXT, XVID_CPU_3DNOWEXT, ebp
174 : Isibaar 1.1
175 :     ; extended MMX ?
176 : suxen_drol 1.2 CHECK_FEATURE EXT_CPUID_AMD_MMXEXT, XVID_CPU_MMXEXT, ebp
177 :    
178 :     .cpu_quit:
179 :    
180 :     mov eax, ebp
181 :    
182 :     pop ebp
183 :     pop edi
184 :     pop esi
185 :     pop ebx
186 :    
187 : Isibaar 1.1 ret
188 : suxen_drol 1.2
189 :    
190 :    
191 :     ; sse/sse2 operating support detection routines
192 :     ; these will trigger an invalid instruction signal if not supported.
193 :    
194 :     cglobal sse_os_trigger
195 :     align 16
196 :     sse_os_trigger:
197 :     xorps xmm0, xmm0
198 :     ret
199 :    
200 :    
201 :     cglobal sse2_os_trigger
202 :     align 16
203 :     sse2_os_trigger:
204 :     xorpd xmm0, xmm0
205 :     ret
206 :    

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