]> git.sesse.net Git - x264/blob - common/amd64/cpu-a.asm
7137a4c686034e40542efc91a2f9b299da88f5cd
[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 64
25
26 ;=============================================================================
27 ; Macros and other preprocessor constants
28 ;=============================================================================
29
30 %include "amd64inc.asm"
31
32 ;=============================================================================
33 ; Code
34 ;=============================================================================
35
36 SECTION .text
37
38 ;-----------------------------------------------------------------------------
39 ;   int x264_cpu_cpuid_test( void ) return 0 if unsupported
40 ;-----------------------------------------------------------------------------
41 cglobal x264_cpu_cpuid_test
42     firstpush rbx
43     pushreg  rbx
44     push     rbp
45     pushreg  rbp
46     mov      rbp, rsp
47     setframe rbp, 0
48     endprolog
49
50     pushfq
51     pop     rax
52     mov     ebx, eax
53     xor     eax, 0x200000
54     push    rax
55     
56     popfq
57     pushfq
58     pop     rax
59     xor     eax, ebx
60     
61     lea     rsp, [rbp]
62     pop     rbp
63     pop     rbx
64     ret
65     endfunc
66
67 ;-----------------------------------------------------------------------------
68 ;   int x264_cpu_cpuid( int op, int *eax, int *ebx, int *ecx, int *edx )
69 ;-----------------------------------------------------------------------------
70 cglobal x264_cpu_cpuid
71     firstpush rbx
72     pushreg   rbx
73     endprolog
74     
75     mov     r10,   parm4q
76     mov     r11,   parm3q
77     mov     r9,    parm2q
78 %ifdef WIN64
79     mov     r8,    [rsp+40+8]
80 %endif    
81     
82     mov     eax,   parm1d
83     cpuid
84
85     mov     [r9],  eax
86     mov     [r11], ebx
87     mov     [r10], ecx
88     mov     [r8],  edx
89
90     pop     rbx
91     ret
92     endfunc
93
94 ;-----------------------------------------------------------------------------
95 ;   void x264_emms( void )
96 ;-----------------------------------------------------------------------------
97 cglobal x264_emms
98     emms
99     ret
100