1 |
;/****************************************************************************** |
;/****************************************************************************** |
2 |
; * * |
; * |
3 |
; * This file is part of XviD, a free MPEG-4 video encoder/decoder * |
; * Copyright (C) 2001 - Michael Militzer <isibaar@xvid.org> |
4 |
; * * |
; * |
5 |
; * XviD is an implementation of a part of one or more MPEG-4 Video tools * |
; * This file is part of XviD, a free MPEG-4 video encoder/decoder |
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 * |
; * XviD is free software; you can redistribute it and/or modify it |
8 |
; * use may infringe existing patents or copyrights, and any such use * |
; * under the terms of the GNU General Public License as published by |
9 |
; * would be at such party's own risk. The original developer of this * |
; * the Free Software Foundation; either version 2 of the License, or |
10 |
; * software module and his/her company, and subsequent editors and their * |
; * (at your option) any later version. |
11 |
; * companies, will have no liability for use of this software or * |
; * |
12 |
; * modifications or derivatives thereof. * |
; * This program is distributed in the hope that it will be useful, |
13 |
; * * |
; * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
; * XviD is free software; you can redistribute it and/or modify it * |
; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
; * under the terms of the GNU General Public License as published by * |
; * GNU General Public License for more details. |
16 |
; * the Free Software Foundation; either version 2 of the License, or * |
; * |
17 |
; * (at your option) any later version. * |
; * 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 |
; * XviD is distributed in the hope that it will be useful, but * |
; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 |
; * WITHOUT ANY WARRANTY; without even the implied warranty of * |
; * |
21 |
; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
; * Under section 8 of the GNU General Public License, the copyright |
22 |
; * GNU General Public License for more details. * |
; * holders of XVID explicitly forbid distribution in the following |
23 |
; * * |
; * countries: |
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 * |
; * - Japan |
26 |
; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * |
; * - 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 |
; * cpuid.asm, check cpu features * |
; * As a special exception, the copyright holders of XviD give you |
33 |
; * * |
; * permission to link XviD with independent modules that communicate with |
34 |
; * Copyright (C) 2001 - Michael Militzer <isibaar@xvid.org>, * |
; * 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 |
; * For more information visit the XviD homepage: http://www.xvid.org * |
; * 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 |
; * Revision history: * |
; * |
43 |
; * * |
; * Note that people who make modified versions of XviD are not obligated |
44 |
; * 17.12.2001 initial version (Isibaar) * |
; * 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 |
; ******************************************************************************/ |
; ******************************************************************************/ |
52 |
|
|
53 |
bits 32 |
bits 32 |
83 |
|
|
84 |
section .data |
section .data |
85 |
|
|
|
features dd 0 |
|
|
|
|
|
vendor dd 0,0,0 |
|
86 |
vendorAMD db "AuthenticAMD" |
vendorAMD db "AuthenticAMD" |
87 |
|
|
88 |
%macro CHECK_FEATURE 3 |
%macro CHECK_FEATURE 3 |
92 |
neg ecx |
neg ecx |
93 |
sbb ecx, ecx |
sbb ecx, ecx |
94 |
and ecx, %2 |
and ecx, %2 |
95 |
or [%3], ecx |
or %3, ecx |
96 |
|
|
97 |
%endmacro |
%endmacro |
98 |
|
|
103 |
cglobal check_cpu_features |
cglobal check_cpu_features |
104 |
check_cpu_features: |
check_cpu_features: |
105 |
|
|
106 |
pushad |
push ebx |
107 |
pushfd |
push esi |
108 |
|
push edi |
109 |
|
push ebp |
110 |
|
|
111 |
|
xor ebp,ebp |
112 |
|
|
113 |
; CPUID command ? |
; CPUID command ? |
114 |
|
pushfd |
115 |
pop eax |
pop eax |
116 |
mov ecx, eax |
mov ecx, eax |
117 |
xor eax, 0x200000 |
xor eax, 0x200000 |
127 |
; get vendor string, used later |
; get vendor string, used later |
128 |
xor eax, eax |
xor eax, eax |
129 |
cpuid |
cpuid |
130 |
mov [vendor], ebx ; vendor string |
mov [esp-12], ebx ; vendor string |
131 |
mov [vendor+4], edx |
mov [esp-12+4], edx |
132 |
mov [vendor+8], ecx |
mov [esp-12+8], ecx |
133 |
test eax, eax |
test eax, eax |
134 |
|
|
135 |
jz near .cpu_quit |
jz near .cpu_quit |
137 |
mov eax, 1 |
mov eax, 1 |
138 |
cpuid |
cpuid |
139 |
|
|
|
|
|
140 |
; RDTSC command ? |
; RDTSC command ? |
141 |
CHECK_FEATURE CPUID_TSC, XVID_CPU_TSC, features |
CHECK_FEATURE CPUID_TSC, XVID_CPU_TSC, ebp |
142 |
|
|
143 |
; MMX support ? |
; MMX support ? |
144 |
CHECK_FEATURE CPUID_MMX, XVID_CPU_MMX, features |
CHECK_FEATURE CPUID_MMX, XVID_CPU_MMX, ebp |
145 |
|
|
146 |
; SSE support ? |
; SSE support ? |
147 |
CHECK_FEATURE CPUID_SSE, (XVID_CPU_MMXEXT+XVID_CPU_SSE), features |
CHECK_FEATURE CPUID_SSE, (XVID_CPU_MMXEXT|XVID_CPU_SSE), ebp |
148 |
|
|
149 |
; SSE2 support? |
; SSE2 support? |
150 |
CHECK_FEATURE CPUID_SSE2, XVID_CPU_SSE2, features |
CHECK_FEATURE CPUID_SSE2, XVID_CPU_SSE2, ebp |
|
|
|
151 |
|
|
152 |
; extended functions? |
; extended functions? |
153 |
mov eax, 0x80000000 |
mov eax, 0x80000000 |
158 |
mov eax, 0x80000001 |
mov eax, 0x80000001 |
159 |
cpuid |
cpuid |
160 |
|
|
|
; 3DNow! support ? |
|
|
CHECK_FEATURE EXT_CPUID_3DNOW, XVID_CPU_3DNOW, features |
|
|
|
|
161 |
; AMD cpu ? |
; AMD cpu ? |
162 |
lea esi, [vendorAMD] |
lea esi, [vendorAMD] |
163 |
lea edi, [vendor] |
lea edi, [esp-12] |
164 |
mov ecx, 12 |
mov ecx, 12 |
165 |
cld |
cld |
166 |
repe cmpsb |
repe cmpsb |
167 |
jnz .cpu_quit |
jnz .cpu_quit |
168 |
|
|
169 |
|
; 3DNow! support ? |
170 |
|
CHECK_FEATURE EXT_CPUID_3DNOW, XVID_CPU_3DNOW, ebp |
171 |
|
|
172 |
; 3DNOW extended ? |
; 3DNOW extended ? |
173 |
CHECK_FEATURE EXT_CPUID_AMD_3DNOWEXT, XVID_CPU_3DNOWEXT, features |
CHECK_FEATURE EXT_CPUID_AMD_3DNOWEXT, XVID_CPU_3DNOWEXT, ebp |
174 |
|
|
175 |
; extended MMX ? |
; extended MMX ? |
176 |
CHECK_FEATURE EXT_CPUID_AMD_MMXEXT, XVID_CPU_MMXEXT, features |
CHECK_FEATURE EXT_CPUID_AMD_MMXEXT, XVID_CPU_MMXEXT, ebp |
177 |
|
|
178 |
.cpu_quit: |
.cpu_quit: |
179 |
|
|
180 |
popad |
mov eax, ebp |
181 |
|
|
182 |
mov eax, [features] |
pop ebp |
183 |
|
pop edi |
184 |
|
pop esi |
185 |
|
pop ebx |
186 |
|
|
187 |
ret |
ret |
188 |
|
|
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 |
|
|