]> git.sesse.net Git - x264/blob - common/amd64/cpu-a.asm
amd64 asm patch, part1.
[x264] / common / amd64 / 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 %macro cglobal 1
31         %ifdef PREFIX
32                 global _%1
33                 %define %1 _%1
34         %else
35                 global %1
36         %endif
37 %endmacro
38
39 ;=============================================================================
40 ; Code
41 ;=============================================================================
42
43 SECTION .text
44
45 cglobal x264_cpu_cpuid_test
46 cglobal x264_cpu_cpuid
47 cglobal x264_emms
48
49 ALIGN 16
50 ;-----------------------------------------------------------------------------
51 ;   int __cdecl x264_cpu_cpuid_test( void ) return 0 if unsupported
52 ;-----------------------------------------------------------------------------
53 x264_cpu_cpuid_test:
54     pushfd
55     push    ebx
56     push    ebp
57     push    esi
58     push    edi
59
60     pushfd
61     pop     eax
62     mov     ebx, eax
63     xor     eax, 0x200000
64     push    eax
65     popfd
66     pushfd
67     pop     eax
68     xor     eax, ebx
69     
70     pop     edi
71     pop     esi
72     pop     ebp
73     pop     ebx
74     popfd
75     ret
76
77 ALIGN 16
78 ;-----------------------------------------------------------------------------
79 ;   int __cdecl x264_cpu_cpuid( int op, int *eax, int *ebx, int *ecx, int *edx )
80 ;-----------------------------------------------------------------------------
81 x264_cpu_cpuid:
82
83     push    ebp
84     mov     ebp,    esp
85     push    ebx
86     push    esi
87     push    edi
88     
89     mov     eax,    [ebp +  8]
90     cpuid
91
92     mov     esi,    [ebp + 12]
93     mov     [esi],  eax
94
95     mov     esi,    [ebp + 16]
96     mov     [esi],  ebx
97
98     mov     esi,    [ebp + 20]
99     mov     [esi],  ecx
100
101     mov     esi,    [ebp + 24]
102     mov     [esi],  edx
103
104     pop     edi
105     pop     esi
106     pop     ebx
107     pop     ebp
108     ret
109
110 ALIGN 16
111 ;-----------------------------------------------------------------------------
112 ;   void __cdecl x264_emms( void )
113 ;-----------------------------------------------------------------------------
114 x264_emms:
115     emms
116     ret
117