85fbef7417b5e64b02bb989b697ed821a00e47d5
[openssl.git] / crypto / x86cpuid.pl
1 #!/usr/bin/env perl
2
3 push(@INC,"perlasm");
4 require "x86asm.pl";
5
6 &asm_init($ARGV[0],"x86cpuid");
7
8 &function_begin("OPENSSL_ia32_cpuid");
9         &xor    ("edx","edx");
10         &pushf  ();
11         &pop    ("eax");
12         &mov    ("ecx","eax");
13         &xor    ("eax",1<<21);
14         &push   ("eax");
15         &popf   ();
16         &pushf  ();
17         &pop    ("eax");
18         &xor    ("ecx","eax");
19         &bt     ("ecx",21);
20         &jnc    (&label("nocpuid"));
21         &mov    ("eax",1);
22         &cpuid  ();
23 &set_label("nocpuid");
24         &mov    ("eax","edx");
25         &mov    ("edx","ecx");
26 &function_end("OPENSSL_ia32_cpuid");
27
28 &external_label("OPENSSL_ia32cap");
29
30 &function_begin_B("OPENSSL_rdtsc");
31         &xor    ("eax","eax");
32         &xor    ("edx","edx");
33         &picmeup("ecx","OPENSSL_ia32cap");
34         &bt     (&DWP(0,"ecx"),4);
35         &jnc    (&label("notsc"));
36         &rdtsc  ();
37 &set_label("notsc");
38         &ret    ();
39 &function_end_B("OPENSSL_rdtsc");
40
41 &initseg("OPENSSL_cpuid_setup") if ($main'elf);
42
43 &asm_finish();