summaryrefslogtreecommitdiff
path: root/devel/perlasm/cpuid-x86.pl
blob: 8eb12ef5f780059503f573abda84b99c096bd9b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env perl
#
# ====================================================================
# Written by Nikos Mavrogiannopoulos
# Placed under the LGPL
# ====================================================================
#

$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
push(@INC,"${dir}","${dir}../../crypto/perlasm");
require "x86asm.pl";

&asm_init($ARGV[0],$0);

&function_begin_B("gnutls_cpuid");
	&push	("ebp");
	&mov    ("ebp", "esp");
	&sub    ("esp", 12);
	&mov    (&DWP(0,"esp"), "ebx");
	&mov    ("eax",&DWP(8,"ebp"));
	&mov    (&DWP(4,"esp"), "esi");
	&mov    (&DWP(8,"esp"), "edi");
	&push	("ebx");
	&cpuid	();
	&mov    ("edi", "ebx");
	&pop	("ebx");
	&mov	("esi","edx");
	&mov    ("edx",&DWP(12,"ebp"));
	&mov    (&DWP(0,"edx"), "eax");
	&mov    ("eax",&DWP(16,"ebp"));
	&mov    (&DWP(0,"eax"), "edi");
	&mov    ("eax",&DWP(20,"ebp"));
	&mov    (&DWP(0,"eax"), "ecx");
	&mov    ("eax",&DWP(24,"ebp"));
	&mov    (&DWP(0,"eax"), "esi");
	&mov    ("ebx",&DWP(0,"esp"));
	&mov    ("esi",&DWP(4,"esp"));
	&mov    ("edi",&DWP(8,"esp"));
	&mov    ("esp","ebp");
	&pop	("ebp");
	&ret    ();
&function_end_B("gnutls_cpuid");

&function_begin_B("gnutls_have_cpuid");
	&pushf	();
	&pop    ("eax");
	&or     ("eax",0x200000);
	&push   ("eax");
	&popf   ();
	&pushf  ();
	&pop    ("eax");
	&and     ("eax",0x200000);
	&ret    ();
&function_end_B("gnutls_have_cpuid");

&asciz("CPUID for x86");
&asm_finish();