]> git.sesse.net Git - x264/blob - common/i386/cpu-a.asm
235acd4a6091ef045e49f4bbd94a5304b7113c3b
[x264] / common / i386 / cpu-a.asm
1 ;*****************************************************************************
2 ;* cpu.asm: h264 encoder library
3 ;*****************************************************************************
4 ;* Copyright (C) 2003 x264 project
5 ;* $Id: cpu.asm,v 1.1 2004/06/03 19:27:07 fenrir Exp $
6 ;*
7 ;* Authors: Laurent Aimar <fenrir@via.ecp.fr>
8 ;*
9 ;* This program is free software; you can redistribute it and/or modify
10 ;* it under the terms of the GNU General Public License as published by
11 ;* the Free Software Foundation; either version 2 of the License, or
12 ;* (at your option) any later version.
13 ;*
14 ;* This program is distributed in the hope that it will be useful,
15 ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 ;* GNU General Public License for more details.
18 ;*
19 ;* You should have received a copy of the GNU General Public License
20 ;* along with this program; if not, write to the Free Software
21 ;* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22 ;*****************************************************************************
23
24 BITS 32
25
26 ;=============================================================================
27 ; Macros and other preprocessor constants
28 ;=============================================================================
29
30 %include "i386inc.asm"
31
32 ;=============================================================================
33 ; Code
34 ;=============================================================================
35
36 SECTION .text
37
38 ;-----------------------------------------------------------------------------
39 ;   int __cdecl x264_cpu_cpuid_test( void ) return 0 if unsupported
40 ;-----------------------------------------------------------------------------
41 cglobal x264_cpu_cpuid_test
42     pushfd
43     push    ebx
44     push    ebp
45     push    esi
46     push    edi
47
48     pushfd
49     pop     eax
50     mov     ebx, eax
51     xor     eax, 0x200000
52     push    eax
53     popfd
54     pushfd
55     pop     eax
56     xor     eax, ebx
57     
58     pop     edi
59     pop     esi
60     pop     ebp
61     pop     ebx
62     popfd
63     ret
64
65 ;-----------------------------------------------------------------------------
66 ;   int __cdecl x264_cpu_cpuid( int op, int *eax, int *ebx, int *ecx, int *edx )
67 ;-----------------------------------------------------------------------------
68 cglobal x264_cpu_cpuid
69
70     push    ebp
71     mov     ebp,    esp
72     push    ebx
73     push    esi
74     push    edi
75     
76     mov     eax,    [ebp +  8]
77     cpuid
78
79     mov     esi,    [ebp + 12]
80     mov     [esi],  eax
81
82     mov     esi,    [ebp + 16]
83     mov     [esi],  ebx
84
85     mov     esi,    [ebp + 20]
86     mov     [esi],  ecx
87
88     mov     esi,    [ebp + 24]
89     mov     [esi],  edx
90
91     pop     edi
92     pop     esi
93     pop     ebx
94     pop     ebp
95     ret
96
97 ;-----------------------------------------------------------------------------
98 ;   void __cdecl x264_emms( void )
99 ;-----------------------------------------------------------------------------
100 cglobal x264_emms
101     emms
102     ret
103
104 ;-----------------------------------------------------------------------------
105 ; void x264_stack_align( void (*func)(void*), void *arg );
106 ;-----------------------------------------------------------------------------
107 cglobal x264_stack_align
108     push ebp
109     mov  ebp, esp
110     sub  esp, 4
111     and  esp, ~15
112     mov  ecx, [ebp+8]
113     mov  edx, [ebp+12]
114     mov  [esp], edx
115     call ecx
116     mov  esp, ebp
117     pop  ebp
118     ret
119