comparison run/mini/callingconv1.d @ 1628:c6ef09dfba4d

add mini test set from ldc project
author Moritz Warning <moritzwarning@web.de>
date Mon, 10 Jan 2011 19:47:18 +0100
parents
children
comparison
equal deleted inserted replaced
1627:e1b954780837 1628:c6ef09dfba4d
1 module mini.callingconv1;
2
3 extern(C) int printf(char*, ...);
4
5 float foo(float a, float b)
6 {
7 return a + b;
8 }
9
10 void main()
11 {
12 float a = 1.5;
13 float b = 2.5;
14 float c;
15
16 version(D_InlineAsm_X86)
17 {
18 version(Windows)
19 {
20 asm
21 {
22 movss XMM0, [a];
23 movss XMM1, [b];
24 movss [ESP], XMM1;
25 movss [ESP]+4, XMM0;
26 call foo;
27 fstp [c]-4;
28 movss XMM0, [c]-4;
29 movss [c], XMM0;
30 }
31 } else
32 {
33
34 asm
35 {
36 mov EAX, [a];
37 push EAX;
38 mov EAX, [b];
39 push EAX;
40 call foo;
41 fstp c;
42 }
43 }
44 }
45 else version(D_InlineAsm_X86_64)
46 {
47 asm
48 {
49 movss XMM0, [a];
50 movss XMM1, [b];
51 call foo;
52 movss [c], XMM0;
53 }
54 }
55 printf("%f\n", c);
56
57 assert(c == 4.0);
58
59 printf("passed %f\n", c);
60 }