1 |
;/****************************************************************************** |
;/**************************************************************************** |
2 |
; * |
; * |
3 |
; * Copyright (C) 2001 - Michael Militzer <isibaar@xvid.org> |
; * XVID MPEG-4 VIDEO CODEC |
4 |
|
; * - CPUID check processors capabilities - |
5 |
; * |
; * |
6 |
; * This file is part of XviD, a free MPEG-4 video encoder/decoder |
; * Copyright (C) 2001 Michael Militzer <isibaar@xvid.org> |
7 |
; * |
; * |
8 |
; * XviD is free software; you can redistribute it and/or modify it |
; * This program is free software ; you can redistribute it and/or modify |
9 |
; * under the terms of the GNU General Public License as published by |
; * it under the terms of the GNU General Public License as published by |
10 |
; * the Free Software Foundation; either version 2 of the License, or |
; * the Free Software Foundation; either version 2 of the License, or |
11 |
; * (at your option) any later version. |
; * (at your option) any later version. |
12 |
; * |
; * |
19 |
; * along with this program; if not, write to the Free Software |
; * along with this program; if not, write to the Free Software |
20 |
; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
; * |
; * |
22 |
; * Under section 8 of the GNU General Public License, the copyright |
; * $Id: cpuid.asm,v 1.4.2.2 2003-10-28 22:23:03 edgomez Exp $ |
|
; * holders of XVID explicitly forbid distribution in the following |
|
|
; * countries: |
|
|
; * |
|
|
; * - Japan |
|
|
; * - United States of America |
|
|
; * |
|
|
; * Linking XviD statically or dynamically with other modules is making a |
|
|
; * combined work based on XviD. Thus, the terms and conditions of the |
|
|
; * GNU General Public License cover the whole combination. |
|
|
; * |
|
|
; * As a special exception, the copyright holders of XviD give you |
|
|
; * permission to link XviD with independent modules that communicate with |
|
|
; * XviD solely through the VFW1.1 and DShow interfaces, regardless of the |
|
|
; * license terms of these independent modules, and to copy and distribute |
|
|
; * the resulting combined work under terms of your choice, provided that |
|
|
; * every copy of the combined work is accompanied by a complete copy of |
|
|
; * the source code of XviD (the version of XviD used to produce the |
|
|
; * combined work), being distributed under the terms of the GNU General |
|
|
; * Public License plus this exception. An independent module is a module |
|
|
; * which is not derived from or based on XviD. |
|
|
; * |
|
|
; * Note that people who make modified versions of XviD are not obligated |
|
|
; * to grant this special exception for their modified versions; it is |
|
|
; * their choice whether to do so. The GNU General Public License gives |
|
|
; * permission to release a modified version without this exception; this |
|
|
; * exception also makes it possible to release a modified version which |
|
|
; * carries forward this exception. |
|
23 |
; * |
; * |
24 |
; * $Id: cpuid.asm,v 1.3 2002-11-17 00:51:11 edgomez Exp $ |
; ***************************************************************************/ |
|
; ******************************************************************************/ |
|
25 |
|
|
26 |
bits 32 |
BITS 32 |
27 |
|
|
28 |
|
%macro cglobal 1 |
29 |
|
%ifdef PREFIX |
30 |
|
global _%1 |
31 |
|
%define %1 _%1 |
32 |
|
%else |
33 |
|
global %1 |
34 |
|
%endif |
35 |
|
%endmacro |
36 |
|
|
37 |
|
;============================================================================= |
38 |
|
; Constants |
39 |
|
;============================================================================= |
40 |
|
|
41 |
%define CPUID_TSC 0x00000010 |
%define CPUID_TSC 0x00000010 |
42 |
%define CPUID_MMX 0x00800000 |
%define CPUID_MMX 0x00800000 |
47 |
%define EXT_CPUID_AMD_3DNOWEXT 0x40000000 |
%define EXT_CPUID_AMD_3DNOWEXT 0x40000000 |
48 |
%define EXT_CPUID_AMD_MMXEXT 0x00400000 |
%define EXT_CPUID_AMD_MMXEXT 0x00400000 |
49 |
|
|
50 |
%define XVID_CPU_MMX 0x00000001 |
;;; NB: Make sure these defines match the ones defined in xvid.h |
51 |
%define XVID_CPU_MMXEXT 0x00000002 |
%define XVID_CPU_MMX (1<< 0) |
52 |
%define XVID_CPU_SSE 0x00000004 |
%define XVID_CPU_MMXEXT (1<< 1) |
53 |
%define XVID_CPU_SSE2 0x00000008 |
%define XVID_CPU_SSE (1<< 2) |
54 |
%define XVID_CPU_3DNOW 0x00000010 |
%define XVID_CPU_SSE2 (1<< 3) |
55 |
%define XVID_CPU_3DNOWEXT 0x00000020 |
%define XVID_CPU_3DNOW (1<< 4) |
56 |
%define XVID_CPU_TSC 0x00000040 |
%define XVID_CPU_3DNOWEXT (1<< 5) |
57 |
|
%define XVID_CPU_TSC (1<< 6) |
58 |
|
|
59 |
%macro cglobal 1 |
;============================================================================= |
60 |
%ifdef PREFIX |
; Read only data |
61 |
global _%1 |
;============================================================================= |
|
%define %1 _%1 |
|
|
%else |
|
|
global %1 |
|
|
%endif |
|
|
%endmacro |
|
62 |
|
|
63 |
ALIGN 32 |
ALIGN 32 |
64 |
|
SECTION .rodata |
65 |
|
|
66 |
section .data |
vendorAMD: |
67 |
|
db "AuthenticAMD" |
68 |
|
|
69 |
vendorAMD db "AuthenticAMD" |
;============================================================================= |
70 |
|
; Macros |
71 |
|
;============================================================================= |
72 |
|
|
73 |
%macro CHECK_FEATURE 3 |
%macro CHECK_FEATURE 3 |
|
|
|
74 |
mov ecx, %1 |
mov ecx, %1 |
75 |
and ecx, edx |
and ecx, edx |
76 |
neg ecx |
neg ecx |
77 |
sbb ecx, ecx |
sbb ecx, ecx |
78 |
and ecx, %2 |
and ecx, %2 |
79 |
or %3, ecx |
or %3, ecx |
|
|
|
80 |
%endmacro |
%endmacro |
81 |
|
|
82 |
section .text |
;============================================================================= |
83 |
|
; Code |
84 |
|
;============================================================================= |
85 |
|
|
86 |
|
SECTION .text |
87 |
|
|
88 |
; int check_cpu_feature(void) |
; int check_cpu_feature(void) |
89 |
|
|
173 |
|
|
174 |
ret |
ret |
175 |
|
|
|
|
|
|
|
|
176 |
; sse/sse2 operating support detection routines |
; sse/sse2 operating support detection routines |
177 |
; these will trigger an invalid instruction signal if not supported. |
; these will trigger an invalid instruction signal if not supported. |
178 |
|
ALIGN 16 |
179 |
cglobal sse_os_trigger |
cglobal sse_os_trigger |
|
align 16 |
|
180 |
sse_os_trigger: |
sse_os_trigger: |
181 |
xorps xmm0, xmm0 |
xorps xmm0, xmm0 |
182 |
ret |
ret |
183 |
|
|
184 |
|
|
185 |
|
ALIGN 16 |
186 |
cglobal sse2_os_trigger |
cglobal sse2_os_trigger |
|
align 16 |
|
187 |
sse2_os_trigger: |
sse2_os_trigger: |
188 |
xorpd xmm0, xmm0 |
xorpd xmm0, xmm0 |
189 |
ret |
ret |
190 |
|
|
191 |
|
|
192 |
|
; enter/exit mmx state |
193 |
|
ALIGN 16 |
194 |
|
cglobal emms_mmx |
195 |
|
emms_mmx: |
196 |
|
emms |
197 |
|
ret |
198 |
|
|
199 |
|
; faster enter/exit mmx state |
200 |
|
ALIGN 16 |
201 |
|
cglobal emms_3dn |
202 |
|
emms_3dn: |
203 |
|
femms |
204 |
|
ret |