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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1382, Mon Mar 22 22:36:25 2004 UTC revision 1794, Fri Nov 14 15:43:28 2008 UTC
# Line 19  Line 19 
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  ; * $Id: cpuid.asm,v 1.5 2004-03-22 22:36:24 edgomez Exp $  ; * $Id: cpuid.asm,v 1.14 2008-11-14 15:43:28 Isibaar Exp $
23  ; *  ; *
24  ; ***************************************************************************/  ; ***************************************************************************/
25    
# Line 27  Line 27 
27    
28  %macro cglobal 1  %macro cglobal 1
29          %ifdef PREFIX          %ifdef PREFIX
30                    %ifdef MARK_FUNCS
31                            global _%1:function %1.endfunc-%1
32                            %define %1 _%1:function %1.endfunc-%1
33                            %define ENDFUNC .endfunc
34                    %else
35                  global _%1                  global _%1
36                  %define %1 _%1                  %define %1 _%1
37                            %define ENDFUNC
38                    %endif
39            %else
40                    %ifdef MARK_FUNCS
41                            global %1:function %1.endfunc-%1
42                            %define ENDFUNC .endfunc
43          %else          %else
44                  global %1                  global %1
45                            %define ENDFUNC
46                    %endif
47          %endif          %endif
48  %endmacro  %endmacro
49    
# Line 42  Line 55 
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    %define CPUID_SSE41             0x00080000
60    
61  %define EXT_CPUID_3DNOW         0x80000000  %define EXT_CPUID_3DNOW         0x80000000
62  %define EXT_CPUID_AMD_3DNOWEXT  0x40000000  %define EXT_CPUID_AMD_3DNOWEXT  0x40000000
# Line 52  Line 67 
67  %define XVID_CPU_MMXEXT   (1<< 1)  %define XVID_CPU_MMXEXT   (1<< 1)
68  %define XVID_CPU_SSE      (1<< 2)  %define XVID_CPU_SSE      (1<< 2)
69  %define XVID_CPU_SSE2     (1<< 3)  %define XVID_CPU_SSE2     (1<< 3)
70    %define XVID_CPU_SSE3     (1<< 8)
71    %define XVID_CPU_SSE41    (1<< 9)
72  %define XVID_CPU_3DNOW    (1<< 4)  %define XVID_CPU_3DNOW    (1<< 4)
73  %define XVID_CPU_3DNOWEXT (1<< 5)  %define XVID_CPU_3DNOWEXT (1<< 5)
74  %define XVID_CPU_TSC      (1<< 6)  %define XVID_CPU_TSC      (1<< 6)
# Line 62  Line 79 
79    
80  ALIGN 32  ALIGN 32
81  %ifdef FORMAT_COFF  %ifdef FORMAT_COFF
82  SECTION .rodata data  SECTION .rodata
83  %else  %else
84  SECTION .rodata data align=16  SECTION .rodata align=16
85  %endif  %endif
86    
87  vendorAMD:  vendorAMD:
# Line 74  Line 91 
91  ; Macros  ; Macros
92  ;=============================================================================  ;=============================================================================
93    
94  %macro  CHECK_FEATURE         3  %macro  CHECK_FEATURE         4
95    mov ecx, %1    mov eax, %1
96    and ecx, edx    and eax, %4
97    neg ecx    neg eax
98    sbb ecx, ecx    sbb eax, eax
99    and ecx, %2    and eax, %2
100    or %3, ecx    or %3, eax
101  %endmacro  %endmacro
102    
103  ;=============================================================================  ;=============================================================================
# Line 99  Line 116 
116    push edi    push edi
117    push ebp    push ebp
118    
119      sub esp, 12             ; Stack space for vendor name
120    
121    xor ebp, ebp    xor ebp, ebp
122    
123          ; CPUID command ?          ; CPUID command ?
# Line 118  Line 137 
137          ; get vendor string, used later          ; get vendor string, used later
138    xor eax, eax    xor eax, eax
139    cpuid    cpuid
140    mov [esp-12], ebx       ; vendor string    mov [esp], ebx       ; vendor string
141    mov [esp-12+4], edx    mov [esp+4], edx
142    mov [esp-12+8], ecx    mov [esp+8], ecx
143    test eax, eax    test eax, eax
144    
145    jz near .cpu_quit    jz near .cpu_quit
# Line 129  Line 148 
148    cpuid    cpuid
149    
150   ; RDTSC command ?   ; RDTSC command ?
151    CHECK_FEATURE CPUID_TSC, XVID_CPU_TSC, ebp    CHECK_FEATURE CPUID_TSC, XVID_CPU_TSC, ebp, edx
152    
153    ; MMX support ?    ; MMX support ?
154    CHECK_FEATURE CPUID_MMX, XVID_CPU_MMX, ebp    CHECK_FEATURE CPUID_MMX, XVID_CPU_MMX, ebp, edx
155    
156    ; SSE support ?    ; SSE support ?
157    CHECK_FEATURE CPUID_SSE, (XVID_CPU_MMXEXT|XVID_CPU_SSE), ebp    CHECK_FEATURE CPUID_SSE, (XVID_CPU_MMXEXT|XVID_CPU_SSE), ebp, edx
158    
159    ; SSE2 support?    ; SSE2 support?
160    CHECK_FEATURE CPUID_SSE2, XVID_CPU_SSE2, ebp    CHECK_FEATURE CPUID_SSE2, XVID_CPU_SSE2, ebp, edx
161    
162      ; SSE3 support?
163      CHECK_FEATURE CPUID_SSE3, XVID_CPU_SSE3, ebp, ecx
164    
165      ; SSE41 support?
166      CHECK_FEATURE CPUID_SSE41, XVID_CPU_SSE41, ebp, ecx
167    
168    ; extended functions?    ; extended functions?
169    mov eax, 0x80000000    mov eax, 0x80000000
# Line 151  Line 176 
176    
177   ; AMD cpu ?   ; AMD cpu ?
178    lea esi, [vendorAMD]    lea esi, [vendorAMD]
179    lea edi, [esp-12]    lea edi, [esp]
180    mov ecx, 12    mov ecx, 12
181    cld    cld
182    repe cmpsb    repe cmpsb
183    jnz .cpu_quit    jnz .cpu_quit
184    
185    ; 3DNow! support ?    ; 3DNow! support ?
186    CHECK_FEATURE EXT_CPUID_3DNOW, XVID_CPU_3DNOW, ebp    CHECK_FEATURE EXT_CPUID_3DNOW, XVID_CPU_3DNOW, ebp, edx
187    
188    ; 3DNOW extended ?    ; 3DNOW extended ?
189    CHECK_FEATURE EXT_CPUID_AMD_3DNOWEXT, XVID_CPU_3DNOWEXT, ebp    CHECK_FEATURE EXT_CPUID_AMD_3DNOWEXT, XVID_CPU_3DNOWEXT, ebp, edx
190    
191    ; extended MMX ?    ; extended MMX ?
192    CHECK_FEATURE EXT_CPUID_AMD_MMXEXT, XVID_CPU_MMXEXT, ebp    CHECK_FEATURE EXT_CPUID_AMD_MMXEXT, XVID_CPU_MMXEXT, ebp, edx
193    
194  .cpu_quit:  .cpu_quit:
195    
196    mov eax, ebp    mov eax, ebp
197    
198      add esp, 12
199    
200    pop ebp    pop ebp
201    pop edi    pop edi
202    pop esi    pop esi
203    pop ebx    pop ebx
204    
205    ret    ret
206    ENDFUNC
207    
208  ; sse/sse2 operating support detection routines  ; sse/sse2 operating support detection routines
209  ; these will trigger an invalid instruction signal if not supported.  ; these will trigger an invalid instruction signal if not supported.
# Line 184  Line 212 
212  sse_os_trigger:  sse_os_trigger:
213    xorps xmm0, xmm0    xorps xmm0, xmm0
214    ret    ret
215    ENDFUNC
216    
217    
218  ALIGN 16  ALIGN 16
# Line 191  Line 220 
220  sse2_os_trigger:  sse2_os_trigger:
221    xorpd xmm0, xmm0    xorpd xmm0, xmm0
222    ret    ret
223    ENDFUNC
224    
225    
226  ; enter/exit mmx state  ; enter/exit mmx state
# Line 199  Line 229 
229  emms_mmx:  emms_mmx:
230    emms    emms
231    ret    ret
232    ENDFUNC
233    
234  ; faster enter/exit mmx state  ; faster enter/exit mmx state
235  ALIGN 16  ALIGN 16
# Line 206  Line 237 
237  emms_3dn:  emms_3dn:
238    femms    femms
239    ret    ret
240    ENDFUNC
241    
242    
243    
244    %ifidn __OUTPUT_FORMAT__,elf
245    section ".note.GNU-stack" noalloc noexec nowrite progbits
246    %endif
247    

Legend:
Removed from v.1382  
changed lines
  Added in v.1794

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