add 3DNOW stuff from Miroslav
[platform/upstream/flac.git] / src / libFLAC / ia32 / cpu_asm.nasm
1 ; libFLAC - Free Lossless Audio Codec library
2 ; Copyright (C) 2001  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
26         code_section
27
28 ; **********************************************************************
29 ;
30
31 have_cpuid:
32         pushfd
33         pop     eax
34         mov     edx, eax
35         xor     eax, 0x00200000
36         push    eax
37         popfd
38         pushfd
39         pop     eax
40         cmp     eax, edx
41         jz      .no_cpuid
42         mov     eax, 1
43         jmp     .end
44 .no_cpuid:
45         xor     eax, eax
46 .end:
47         ret
48
49 cident FLAC__cpu_info_asm_ia32
50         push    ebx
51         call    have_cpuid
52         test    eax, eax
53         jz      .no_cpuid
54         mov     eax, 1
55         cpuid
56         mov     eax, edx
57         jmp     .end
58 .no_cpuid:
59         xor     eax, eax
60 .end
61         pop     ebx
62         ret
63
64 cident FLAC__cpu_info_extended_amd_asm_ia32
65         push    ebx
66         call    have_cpuid
67         test    eax, eax
68         jz      .no_cpuid
69         mov     eax, 0x80000000
70         cpuid
71         cmp     eax, 0x80000001
72         jb      .no_cpuid
73         mov     eax, 0x80000001
74         cpuid
75         mov     eax, edx
76         jmp     .end
77 .no_cpuid
78         xor     eax, eax
79 .end
80         pop     ebx
81         ret
82
83 end