]> git.sesse.net Git - x264/blob - common/amd64/cpu-a.asm
api addition: x264_param_parse() to set options by name
[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 cglobal x264_cpu_cpuid_test
39 cglobal x264_cpu_cpuid
40 cglobal x264_emms
41
42 ALIGN 16
43 ;-----------------------------------------------------------------------------
44 ;   int x264_cpu_cpuid_test( void ) return 0 if unsupported
45 ;-----------------------------------------------------------------------------
46 x264_cpu_cpuid_test:
47     firstpush rbx
48     pushreg  rbx
49     push     rbp
50     pushreg  rbp
51     mov      rbp, rsp
52     setframe rbp, 0
53     endprolog
54
55     pushfq
56     pop     rax
57     mov     ebx, eax
58     xor     eax, 0x200000
59     push    rax
60     
61     popfq
62     pushfq
63     pop     rax
64     xor     eax, ebx
65     
66     lea     rsp, [rbp]
67     pop     rbp
68     pop     rbx
69     ret
70     endfunc
71
72 ALIGN 16
73 ;-----------------------------------------------------------------------------
74 ;   int x264_cpu_cpuid( int op, int *eax, int *ebx, int *ecx, int *edx )
75 ;-----------------------------------------------------------------------------
76 x264_cpu_cpuid:
77     firstpush rbx
78     pushreg   rbx
79     endprolog
80     
81     mov     r10,   parm4q
82     mov     r11,   parm3q
83     mov     r9,    parm2q
84 %ifdef WIN64
85     mov     r8,    [rsp+40+8]
86 %endif    
87     
88     mov     eax,   parm1d
89     cpuid
90
91     mov     [r9],  eax
92     mov     [r11], ebx
93     mov     [r10], ecx
94     mov     [r8],  edx
95
96     pop     rbx
97     ret
98     endfunc
99
100 ALIGN 16
101 ;-----------------------------------------------------------------------------
102 ;   void x264_emms( void )
103 ;-----------------------------------------------------------------------------
104 x264_emms:
105     emms
106     ret
107