Mercurial > projects > ldc
annotate tests/mini/asm8.d @ 949:b2d27ddf8f45
changes to get the naked asm stuff working for x64
author | wilsonk@ubuntu |
---|---|
date | Tue, 10 Feb 2009 08:02:25 -0700 |
parents | 03d7c4aac654 |
children | 7e669954db7d |
rev | line source |
---|---|
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
1 int foo() |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
2 { |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
3 version(X86) |
949
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
4 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
5 asm { mov EAX, 42; } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
6 } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
7 else version (X86_64) |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
8 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
9 asm { mov EAX, 42; } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
10 } |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
11 else static assert(0, "todo"); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
12 } |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
13 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
14 ulong bar() |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
15 { |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
16 version(X86) |
949
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
17 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
18 asm { mov EDX, 0xAA; mov EAX, 0xFF; } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
19 } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
20 else version (X86_64) |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
21 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
22 asm { movq RAX, 0xFF; } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
23 } |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
24 else static assert(0, "todo"); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
25 } |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
26 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
27 float onef() |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
28 { |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
29 version(X86) |
949
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
30 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
31 asm { fld1; } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
32 } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
33 else version (X86_64) |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
34 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
35 asm { fld1; } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
36 } |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
37 else static assert(0, "todo"); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
38 } |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
39 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
40 double oned() |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
41 { |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
42 version(X86) |
949
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
43 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
44 asm { fld1; } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
45 } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
46 else version (X86_64) |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
47 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
48 asm { fld1; } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
49 } |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
50 else static assert(0, "todo"); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
51 } |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
52 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
53 real oner() |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
54 { |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
55 version(X86) |
949
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
56 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
57 asm { fld1; } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
58 } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
59 else version (X86_64) |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
60 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
61 asm { fld1; } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
62 } |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
63 else static assert(0, "todo"); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
64 } |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
65 |
949
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
66 |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
67 real two = 2.0; |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
68 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
69 creal cr() |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
70 { |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
71 version(X86) |
949
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
72 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
73 asm { fld1; fld two; } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
74 } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
75 else version (X86_64) |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
76 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
77 asm { fld1; fld two; } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
78 } |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
79 else static assert(0, "todo"); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
80 } |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
81 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
82 creal cr2() |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
83 { |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
84 version(X86) |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
85 { |
949
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
86 asm |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
87 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
88 naked; |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
89 fld1; |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
90 fld two; |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
91 ret; |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
92 } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
93 } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
94 else version (X86_64) |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
95 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
96 asm |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
97 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
98 naked; |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
99 fld1; |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
100 fld two; |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
101 ret; |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
102 } |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
103 } |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
104 else static assert(0, "todo"); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
105 } |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
106 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
107 void* vp() |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
108 { |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
109 version(X86) |
949
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
110 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
111 asm { mov EAX, 0x80; } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
112 } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
113 else version (X86_64) |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
114 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
115 asm { movq RAX, 0x80; } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
116 } |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
117 else static assert(0, "todo"); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
118 } |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
119 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
120 int[int] gaa; |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
121 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
122 int[int] aa() |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
123 { |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
124 version(X86) |
949
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
125 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
126 asm { mov EAX, gaa; } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
127 } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
128 else version (X86_64) |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
129 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
130 asm { movq RAX, gaa; } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
131 } |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
132 else static assert(0, "todo"); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
133 } |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
134 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
135 Object gobj; |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
136 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
137 Object ob() |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
138 { |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
139 version(X86) |
949
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
140 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
141 asm { mov EAX, gobj; } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
142 } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
143 else version (X86_64) |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
144 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
145 asm { movq RAX, gobj; } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
146 } |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
147 else static assert(0, "todo"); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
148 } |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
149 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
150 char[] ghello = "hello world"; |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
151 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
152 char[] str() |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
153 { |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
154 version(X86) |
949
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
155 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
156 asm { lea ECX, ghello; mov EAX, [ECX]; mov EDX, [ECX+4]; } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
157 } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
158 else version (X86_64) |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
159 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
160 asm { movq RAX, [ghello]; movq RDX, [ghello]+8; } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
161 } |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
162 else static assert(0, "todo"); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
163 } |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
164 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
165 char[] delegate() dg() |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
166 { |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
167 version(X86) |
949
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
168 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
169 asm { mov EAX, gobj; lea EDX, Object.toString; } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
170 } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
171 else version (X86_64) |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
172 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
173 asm { movq RAX, [gobj]; leaq RDX, Object.toString; } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
174 } |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
175 else static assert(0, "todo"); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
176 } |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
177 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
178 void main() |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
179 { |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
180 gaa[4] = 5; |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
181 gobj = new Object; |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
182 auto adg = &gobj.toString; |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
183 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
184 assert(foo() == 42); |
949
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
185 version(X86) |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
186 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
187 assert(bar() == 0x000000AA000000FF); |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
188 } |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
189 else version (X86_64) |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
190 { |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
191 assert(bar() == 0x00000000000000FF); |
b2d27ddf8f45
changes to get the naked asm stuff working for x64
wilsonk@ubuntu
parents:
945
diff
changeset
|
192 } |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
193 assert(onef() == 1); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
194 assert(oned() == 1); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
195 assert(oner() == 1); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
196 assert(cr() == 1+2i); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
197 assert(cr2() == 1+2i); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
198 assert(vp() == cast(void*)0x80); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
199 assert(aa() is gaa); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
200 assert(ob() is gobj); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
201 assert(str() == "hello world"); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
202 assert(dg()() == "object.Object"); |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
203 } |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
204 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
diff
changeset
|
205 extern(C) int printf(char*, ...); |