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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (view) (download)

1 : Isibaar 3 ;/******************************************************************************
2 :     ; * *
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 :     ; ******************************************************************************/
29 :     ;
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 :    
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 :     %macro cglobal 1
69 :     %ifdef PREFIX
70 :     global _%1
71 :     %define %1 _%1
72 :     %else
73 :     global %1
74 :     %endif
75 :     %endmacro
76 :    
77 :     ALIGN 32
78 :    
79 :     section .data
80 :    
81 :     features dd 0
82 :    
83 :     vendor dd 0,0,0
84 :     vendorAMD db "AuthenticAMD"
85 :    
86 :     %macro CHECK_FEATURE 3
87 :    
88 :     mov ecx, %1
89 :     and ecx, edx
90 :     neg ecx
91 :     sbb ecx, ecx
92 :     and ecx, %2
93 :     or [%3], ecx
94 :    
95 :     %endmacro
96 :    
97 :     section .text
98 :    
99 :     ; int check_cpu_feature(void)
100 :    
101 :     cglobal check_cpu_features
102 :     check_cpu_features:
103 :    
104 :     pushad
105 :     pushfd
106 :    
107 :     ; CPUID command ?
108 :     pop eax
109 :     mov ecx, eax
110 :     xor eax, 0x200000
111 :     push eax
112 :     popfd
113 :     pushfd
114 :     pop eax
115 :     cmp eax, ecx
116 :    
117 :     jz near .cpu_quit ; no CPUID command -> exit
118 :    
119 :    
120 :     ; get vendor string, used later
121 :     xor eax, eax
122 :     cpuid
123 :     mov [vendor], ebx ; vendor string
124 :     mov [vendor+4], edx
125 :     mov [vendor+8], ecx
126 :     test eax, eax
127 :    
128 :     jz near .cpu_quit
129 :    
130 :     mov eax, 1
131 :     cpuid
132 :    
133 :    
134 :     ; RDTSC command ?
135 :     CHECK_FEATURE CPUID_TSC, XVID_CPU_TSC, features
136 :    
137 :     ; MMX support ?
138 :     CHECK_FEATURE CPUID_MMX, XVID_CPU_MMX, features
139 :    
140 :     ; SSE support ?
141 :     CHECK_FEATURE CPUID_SSE, (XVID_CPU_MMXEXT+XVID_CPU_SSE), features
142 :    
143 :     ; SSE2 support?
144 :     CHECK_FEATURE CPUID_SSE2, XVID_CPU_SSE2, features
145 :    
146 :    
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 :     ; 3DNow! support ?
157 :     CHECK_FEATURE EXT_CPUID_3DNOW, XVID_CPU_3DNOW, features
158 :    
159 :     ; AMD cpu ?
160 :     lea esi, [vendorAMD]
161 :     lea edi, [vendor]
162 :     mov ecx, 12
163 :     cld
164 :     repe cmpsb
165 :     jnz .cpu_quit
166 :    
167 :     ; 3DNOW extended ?
168 :     CHECK_FEATURE EXT_CPUID_AMD_3DNOWEXT, XVID_CPU_3DNOWEXT, features
169 :    
170 :     ; extended MMX ?
171 :     CHECK_FEATURE EXT_CPUID_AMD_MMXEXT, XVID_CPU_MMXEXT, features
172 :    
173 :     .cpu_quit:
174 :    
175 :     popad
176 :    
177 :     mov eax, [features]
178 :    
179 :     ret

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