Add 2003 to copyright notice
[platform/upstream/flac.git] / src / libFLAC / ia32 / cpu_asm.nasm
1 ; libFLAC - Free Lossless Audio Codec library
2 ; Copyright (C) 2001,2002,2003  Josh Coalson
3 ;
4 ; This library is free software; you can redistribute it and/or
5 ; modify it under the terms of the GNU Library General Public
6 ; License as published by the Free Software Foundation; either
7 ; version 2 of the License, or (at your option) any later version.
8 ;
9 ; This library is distributed in the hope that it will be useful,
10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 ; Library General Public License for more details.
13 ;
14 ; You should have received a copy of the GNU Library General Public
15 ; License along with this library; if not, write to the
16 ; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 ; Boston, MA  02111-1307, USA.
18
19 %include "nasm.h"
20
21         data_section
22
23 cglobal FLAC__cpu_info_asm_ia32
24 cglobal FLAC__cpu_info_extended_amd_asm_ia32
25 cglobal FLAC__cpu_info_sse_test_asm_ia32
26
27         code_section
28
29 ; **********************************************************************
30 ;
31
32 have_cpuid:
33         pushfd
34         pop     eax
35         mov     edx, eax
36         xor     eax, 0x00200000
37         push    eax
38         popfd
39         pushfd
40         pop     eax
41         cmp     eax, edx
42         jz      .no_cpuid
43         mov     eax, 1
44         jmp     .end
45 .no_cpuid:
46         xor     eax, eax
47 .end:
48         ret
49
50 cident FLAC__cpu_info_asm_ia32
51         push    ebx
52         call    have_cpuid
53         test    eax, eax
54         jz      .no_cpuid
55         mov     eax, 1
56         cpuid
57         mov     eax, edx
58         jmp     .end
59 .no_cpuid:
60         xor     eax, eax
61 .end
62         pop     ebx
63         ret
64
65 cident FLAC__cpu_info_extended_amd_asm_ia32
66         push    ebx
67         call    have_cpuid
68         test    eax, eax
69         jz      .no_cpuid
70         mov     eax, 0x80000000
71         cpuid
72         cmp     eax, 0x80000001
73         jb      .no_cpuid
74         mov     eax, 0x80000001
75         cpuid
76         mov     eax, edx
77         jmp     .end
78 .no_cpuid
79         xor     eax, eax
80 .end
81         pop     ebx
82         ret
83
84 cident FLAC__cpu_info_sse_test_asm_ia32
85         xorps   xmm0, xmm0
86         pop     ebx
87
88 end