1 | ;*************************************************************************** |
---|
2 | ;* Copyright (C) 2005 by Prakash Punnoor * |
---|
3 | ;* prakash@punnoor.de * |
---|
4 | ;* * |
---|
5 | ;* This program is free software; you can redistribute it and/or modify * |
---|
6 | ;* it under the terms of the GNU Library General Public License as * |
---|
7 | ;* published by the Free Software Foundation; either version 2 of the * |
---|
8 | ;* License, or (at your option) any later version. * |
---|
9 | ;* * |
---|
10 | ;* This program is distributed in the hope that it will be useful, * |
---|
11 | ;* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
---|
12 | ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
---|
13 | ;* GNU General Public License for more details. * |
---|
14 | ;* * |
---|
15 | ;* You should have received a copy of the GNU Library General Public * |
---|
16 | ;* License along with this program; if not, write to the * |
---|
17 | ;* Free Software Foundation, Inc., * |
---|
18 | ;* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
---|
19 | ;*************************************************************************** |
---|
20 | |
---|
21 | ; int _alDetectx86CPUCaps(uint* caps1, uint* caps2, uint* caps3); |
---|
22 | ; derived from loki_cpuinfo.c, 1997-98 by H. Dietz and R. Fisher |
---|
23 | ; using infos from sandpile.org |
---|
24 | |
---|
25 | ; returns 0 if no CPUID available |
---|
26 | global __alDetectx86CPUCaps |
---|
27 | global _alDetectx86CPUCaps |
---|
28 | |
---|
29 | __alDetectx86CPUCaps: |
---|
30 | _alDetectx86CPUCaps: |
---|
31 | |
---|
32 | pushf |
---|
33 | pop eax |
---|
34 | mov ecx, eax |
---|
35 | |
---|
36 | xor eax, 0x200000 |
---|
37 | push eax |
---|
38 | popf |
---|
39 | |
---|
40 | pushf |
---|
41 | pop eax |
---|
42 | |
---|
43 | xor ecx, eax |
---|
44 | xor eax, eax |
---|
45 | test ecx, 0x200000 |
---|
46 | jz .Return |
---|
47 | |
---|
48 | ; standard CPUID |
---|
49 | push ebx |
---|
50 | mov eax, 1 |
---|
51 | cpuid |
---|
52 | mov eax, [esp + 8] ;caps1 - MMX, SSE, SSE2 |
---|
53 | mov [eax], edx |
---|
54 | mov eax, [esp + 12] ;caps2 - SSE3 |
---|
55 | mov [eax], ecx |
---|
56 | |
---|
57 | ; extended CPUID |
---|
58 | mov eax, 0x80000001 |
---|
59 | cpuid |
---|
60 | mov eax, [esp + 16] ;caps3 - 3DNOW!, 3DNOW!EXT, CYRIX-MMXEXT, AMD-MMX-SSE |
---|
61 | mov [eax], edx |
---|
62 | pop ebx |
---|
63 | |
---|
64 | ; End |
---|
65 | .Return |
---|
66 | ret |
---|
67 | |
---|
68 | ; prevent executable stack |
---|
69 | %ifidn __OUTPUT_FORMAT__,elf |
---|
70 | section .note.GNU-stack noalloc noexec nowrite progbits |
---|
71 | %endif |
---|