28 |
%macro cglobal 1 |
%macro cglobal 1 |
29 |
%ifdef PREFIX |
%ifdef PREFIX |
30 |
%ifdef MARK_FUNCS |
%ifdef MARK_FUNCS |
31 |
global _%1:function |
global _%1:function %1.endfunc-%1 |
32 |
%define %1 _%1:function |
%define %1 _%1:function %1.endfunc-%1 |
33 |
|
%define ENDFUNC .endfunc |
34 |
%else |
%else |
35 |
global _%1 |
global _%1 |
36 |
%define %1 _%1 |
%define %1 _%1 |
37 |
|
%define ENDFUNC |
38 |
%endif |
%endif |
39 |
%else |
%else |
40 |
%ifdef MARK_FUNCS |
%ifdef MARK_FUNCS |
41 |
global %1:function |
global %1:function %1.endfunc-%1 |
42 |
|
%define ENDFUNC .endfunc |
43 |
%else |
%else |
44 |
global %1 |
global %1 |
45 |
|
%define ENDFUNC |
46 |
%endif |
%endif |
47 |
%endif |
%endif |
48 |
%endmacro |
%endmacro |
55 |
%define CPUID_MMX 0x00800000 |
%define CPUID_MMX 0x00800000 |
56 |
%define CPUID_SSE 0x02000000 |
%define CPUID_SSE 0x02000000 |
57 |
%define CPUID_SSE2 0x04000000 |
%define CPUID_SSE2 0x04000000 |
58 |
|
%define CPUID_SSE3 0x00000001 |
59 |
|
|
60 |
%define EXT_CPUID_3DNOW 0x80000000 |
%define EXT_CPUID_3DNOW 0x80000000 |
61 |
%define EXT_CPUID_AMD_3DNOWEXT 0x40000000 |
%define EXT_CPUID_AMD_3DNOWEXT 0x40000000 |
66 |
%define XVID_CPU_MMXEXT (1<< 1) |
%define XVID_CPU_MMXEXT (1<< 1) |
67 |
%define XVID_CPU_SSE (1<< 2) |
%define XVID_CPU_SSE (1<< 2) |
68 |
%define XVID_CPU_SSE2 (1<< 3) |
%define XVID_CPU_SSE2 (1<< 3) |
69 |
|
%define XVID_CPU_SSE3 (1<< 8) |
70 |
%define XVID_CPU_3DNOW (1<< 4) |
%define XVID_CPU_3DNOW (1<< 4) |
71 |
%define XVID_CPU_3DNOWEXT (1<< 5) |
%define XVID_CPU_3DNOWEXT (1<< 5) |
72 |
%define XVID_CPU_TSC (1<< 6) |
%define XVID_CPU_TSC (1<< 6) |
89 |
; Macros |
; Macros |
90 |
;============================================================================= |
;============================================================================= |
91 |
|
|
92 |
%macro CHECK_FEATURE 3 |
%macro CHECK_FEATURE 4 |
93 |
mov ecx, %1 |
mov eax, %1 |
94 |
and ecx, edx |
and eax, %4 |
95 |
neg ecx |
neg eax |
96 |
sbb ecx, ecx |
sbb eax, eax |
97 |
and ecx, %2 |
and eax, %2 |
98 |
or %3, ecx |
or %3, eax |
99 |
%endmacro |
%endmacro |
100 |
|
|
101 |
;============================================================================= |
;============================================================================= |
146 |
cpuid |
cpuid |
147 |
|
|
148 |
; RDTSC command ? |
; RDTSC command ? |
149 |
CHECK_FEATURE CPUID_TSC, XVID_CPU_TSC, ebp |
CHECK_FEATURE CPUID_TSC, XVID_CPU_TSC, ebp, edx |
150 |
|
|
151 |
; MMX support ? |
; MMX support ? |
152 |
CHECK_FEATURE CPUID_MMX, XVID_CPU_MMX, ebp |
CHECK_FEATURE CPUID_MMX, XVID_CPU_MMX, ebp, edx |
153 |
|
|
154 |
; SSE support ? |
; SSE support ? |
155 |
CHECK_FEATURE CPUID_SSE, (XVID_CPU_MMXEXT|XVID_CPU_SSE), ebp |
CHECK_FEATURE CPUID_SSE, (XVID_CPU_MMXEXT|XVID_CPU_SSE), ebp, edx |
156 |
|
|
157 |
; SSE2 support? |
; SSE2 support? |
158 |
CHECK_FEATURE CPUID_SSE2, XVID_CPU_SSE2, ebp |
CHECK_FEATURE CPUID_SSE2, XVID_CPU_SSE2, ebp, edx |
159 |
|
|
160 |
|
; SSE3 support? |
161 |
|
CHECK_FEATURE CPUID_SSE3, XVID_CPU_SSE3, ebp, ecx |
162 |
|
|
163 |
; extended functions? |
; extended functions? |
164 |
mov eax, 0x80000000 |
mov eax, 0x80000000 |
178 |
jnz .cpu_quit |
jnz .cpu_quit |
179 |
|
|
180 |
; 3DNow! support ? |
; 3DNow! support ? |
181 |
CHECK_FEATURE EXT_CPUID_3DNOW, XVID_CPU_3DNOW, ebp |
CHECK_FEATURE EXT_CPUID_3DNOW, XVID_CPU_3DNOW, ebp, edx |
182 |
|
|
183 |
; 3DNOW extended ? |
; 3DNOW extended ? |
184 |
CHECK_FEATURE EXT_CPUID_AMD_3DNOWEXT, XVID_CPU_3DNOWEXT, ebp |
CHECK_FEATURE EXT_CPUID_AMD_3DNOWEXT, XVID_CPU_3DNOWEXT, ebp, edx |
185 |
|
|
186 |
; extended MMX ? |
; extended MMX ? |
187 |
CHECK_FEATURE EXT_CPUID_AMD_MMXEXT, XVID_CPU_MMXEXT, ebp |
CHECK_FEATURE EXT_CPUID_AMD_MMXEXT, XVID_CPU_MMXEXT, ebp, edx |
188 |
|
|
189 |
.cpu_quit: |
.cpu_quit: |
190 |
|
|
198 |
pop ebx |
pop ebx |
199 |
|
|
200 |
ret |
ret |
201 |
|
ENDFUNC |
202 |
|
|
203 |
; sse/sse2 operating support detection routines |
; sse/sse2 operating support detection routines |
204 |
; these will trigger an invalid instruction signal if not supported. |
; these will trigger an invalid instruction signal if not supported. |
207 |
sse_os_trigger: |
sse_os_trigger: |
208 |
xorps xmm0, xmm0 |
xorps xmm0, xmm0 |
209 |
ret |
ret |
210 |
|
ENDFUNC |
211 |
|
|
212 |
|
|
213 |
ALIGN 16 |
ALIGN 16 |
215 |
sse2_os_trigger: |
sse2_os_trigger: |
216 |
xorpd xmm0, xmm0 |
xorpd xmm0, xmm0 |
217 |
ret |
ret |
218 |
|
ENDFUNC |
219 |
|
|
220 |
|
|
221 |
; enter/exit mmx state |
; enter/exit mmx state |
224 |
emms_mmx: |
emms_mmx: |
225 |
emms |
emms |
226 |
ret |
ret |
227 |
|
ENDFUNC |
228 |
|
|
229 |
; faster enter/exit mmx state |
; faster enter/exit mmx state |
230 |
ALIGN 16 |
ALIGN 16 |
232 |
emms_3dn: |
emms_3dn: |
233 |
femms |
femms |
234 |
ret |
ret |
235 |
|
ENDFUNC |
236 |
|
|
237 |
|
|
238 |
|
|
239 |
|
%ifidn __OUTPUT_FORMAT__,elf |
240 |
|
section ".note.GNU-stack" noalloc noexec nowrite progbits |
241 |
|
%endif |
242 |
|
|