Mercurial > projects > ldc
annotate tests/mini/asm1_1.d @ 1647:638a823ace45
Strange workaround for returning from within 'void main()'. The new dmdfe sets the ReturnStatement->exp to null. Fixed bug #391.
author | Kelly Wilson <wilsonk cpsc.ucalgary.ca> |
---|---|
date | Wed, 10 Mar 2010 19:35:14 -0700 |
parents | 08f87d8cd101 |
children |
rev | line source |
---|---|
341
1bb99290e03a
[svn r362] Started merging the old 'test' dir as well as the newer 'tangotests' dir into 'tests/mini' and 'tests/minicomplex'.
lindquist
parents:
220
diff
changeset
|
1 module tangotests.asm1_1; |
220
ccc2e6898a78
[svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff
changeset
|
2 |
ccc2e6898a78
[svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff
changeset
|
3 extern(C) int printf(char*, ...); |
ccc2e6898a78
[svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff
changeset
|
4 |
ccc2e6898a78
[svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff
changeset
|
5 int main() |
ccc2e6898a78
[svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff
changeset
|
6 { |
ccc2e6898a78
[svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff
changeset
|
7 int i = 12; |
ccc2e6898a78
[svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff
changeset
|
8 int* ip = &i; |
ccc2e6898a78
[svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff
changeset
|
9 printf("%d\n", i); |
1034
12b423e17860
Adjust mini tests to use D_InlineAsm
Christian Kamm <kamm incasoftware de>
parents:
741
diff
changeset
|
10 version (D_InlineAsm_X86) |
220
ccc2e6898a78
[svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff
changeset
|
11 { |
1215
08f87d8cd101
Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents:
1034
diff
changeset
|
12 asm |
08f87d8cd101
Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents:
1034
diff
changeset
|
13 { |
08f87d8cd101
Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents:
1034
diff
changeset
|
14 mov ECX, ip; |
08f87d8cd101
Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents:
1034
diff
changeset
|
15 mov EAX, [ECX]; |
08f87d8cd101
Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents:
1034
diff
changeset
|
16 add EAX, 8; |
08f87d8cd101
Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents:
1034
diff
changeset
|
17 mul EAX, EAX; |
08f87d8cd101
Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents:
1034
diff
changeset
|
18 mov [ECX], EAX; |
08f87d8cd101
Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents:
1034
diff
changeset
|
19 } |
741
4ac97ec7c18e
Applied easy part from wilsonk's x86-64 patch in #107
Christian Kamm <kamm incasoftware de>
parents:
341
diff
changeset
|
20 } |
1034
12b423e17860
Adjust mini tests to use D_InlineAsm
Christian Kamm <kamm incasoftware de>
parents:
741
diff
changeset
|
21 else version (D_InlineAsm_X86_64) |
741
4ac97ec7c18e
Applied easy part from wilsonk's x86-64 patch in #107
Christian Kamm <kamm incasoftware de>
parents:
341
diff
changeset
|
22 { |
1215
08f87d8cd101
Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents:
1034
diff
changeset
|
23 asm |
08f87d8cd101
Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents:
1034
diff
changeset
|
24 { |
08f87d8cd101
Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents:
1034
diff
changeset
|
25 movq RCX, ip; |
08f87d8cd101
Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents:
1034
diff
changeset
|
26 mov EAX, [RCX]; |
08f87d8cd101
Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents:
1034
diff
changeset
|
27 add EAX, 8; |
08f87d8cd101
Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents:
1034
diff
changeset
|
28 imul EAX, EAX; |
08f87d8cd101
Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents:
1034
diff
changeset
|
29 mov [RCX], EAX; |
08f87d8cd101
Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents:
1034
diff
changeset
|
30 } |
220
ccc2e6898a78
[svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff
changeset
|
31 } |
ccc2e6898a78
[svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff
changeset
|
32 printf("%d\n", i); |
ccc2e6898a78
[svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff
changeset
|
33 assert(i == 400); |
ccc2e6898a78
[svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff
changeset
|
34 return 0; |
ccc2e6898a78
[svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff
changeset
|
35 } |