annotate addon/cpuinfo.d @ 709:b0e6b3803e95

added cpuinfo helper for IASM tests
author thomask
date Fri, 21 Oct 2005 19:20:34 +0000
parents
children ce5513bd43f0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
709
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
1 // $HeadURL: svn://dstress.kuehne.cn/run/a/asm_sub_01_C.d $
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
2 // $Date: 2005-08-20 20:24:41 +0200 (Sat, 20 Aug 2005) $
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
3 // $Author: thomask $
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
4
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
5 // @author@ Thomas Kuehne <thomas-dloop@kuehne.cn>
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
6
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
7 module /*dstress.*/addon.cpuinfo;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
8
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
9 version(D_InlineAsm){
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
10 void haveCMOV(){
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
11 uint a = 0;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
12 asm{
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
13 mov EAX, 1;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
14 cpuid;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
15 mov a, EDX;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
16 }
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
17 assert((a >> 15) & 1);
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
18 }
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
19
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
20 void haveCX8(){
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
21 uint a = 0;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
22 asm{
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
23 mov EAX, 1;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
24 cpuid;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
25 mov a, EDX;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
26 }
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
27 assert((a >> 8) & 1);
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
28 }
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
29
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
30 void haveFPU(){
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
31 uint a = 0;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
32
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
33 asm{
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
34 mov EAX, 1;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
35 cpuid;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
36 mov a, EDX;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
37 }
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
38
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
39 assert(a & 1);
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
40 }
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
41
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
42 void haveMMX(){
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
43 uint a = 0;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
44
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
45 asm{
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
46 mov EAX, 1;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
47 cpuid;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
48 mov a, EDX;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
49 }
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
50
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
51 assert((a >> 23) & 1);
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
52 }
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
53
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
54
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
55 void haveSSE(){
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
56 uint a = 0;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
57
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
58 asm{
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
59 mov EAX, 1;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
60 cpuid;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
61 mov a, EDX;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
62 }
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
63
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
64 assert((a >> 25) & 1);
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
65 }
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
66
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
67 void haveSSE2(){
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
68 uint a = 0;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
69
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
70 asm{
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
71 mov EAX, 1;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
72 cpuid;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
73 mov a, EDX;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
74 }
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
75
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
76 assert((a >> 26) & 1);
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
77 }
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
78
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
79 void haveSSE3(){
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
80 uint a = 0;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
81
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
82 asm{
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
83 mov EAX, 1;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
84 cpuid;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
85 mov a, ECX;
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
86 }
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
87
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
88 assert(a & 1);
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
89 }
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
90 }else{
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
91 pragma(msg, "no Inline ASM support");
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
92 static assert(0);
b0e6b3803e95 added cpuinfo helper for IASM tests
thomask
parents:
diff changeset
93 }