comparison tests/mini/asm7.d @ 741:4ac97ec7c18e

Applied easy part from wilsonk's x86-64 patch in #107
author Christian Kamm <kamm incasoftware de>
date Thu, 30 Oct 2008 11:08:34 +0100
parents 1bb99290e03a
children 12b423e17860
comparison
equal deleted inserted replaced
740:96484f5bf5af 741:4ac97ec7c18e
1 module tangotests.asm7; 1 module tangotests.asm7;
2 2
3 // test massive label collisions (runtime uses Loverflow too) 3 // test massive label collisions (runtime uses Loverflow too)
4 extern(C) int printf(char*, ...);
4 5
5 void main() 6 void main()
6 { 7 {
7 int a = add(1,2); 8 int a = add(1,2);
8 int s = sub(1,2); 9 int s = sub(1,2);
11 } 12 }
12 13
13 int add(int a, int b) 14 int add(int a, int b)
14 { 15 {
15 int res; 16 int res;
16 asm 17 version (LLVM_InlineAsm_X86)
17 { 18 {
18 mov EAX, a; 19 asm
19 add EAX, b; 20 {
20 jo Loverflow; 21 mov EAX, a;
21 mov res, EAX; 22 add EAX, b;
23 jo Loverflow;
24 mov res, EAX;
25 }
22 } 26 }
27 else version (LLVM_InlineAsm_X86_64)
28 {
29 asm
30 {
31 mov EAX, a;
32 add EAX, b;
33 jo Loverflow;
34 mov res, EAX;
35 }
36 }
37 printf("%d\n",res);
23 return res; 38 return res;
24 Loverflow: 39 Loverflow:
25 assert(0, "add overflow"); 40 assert(0, "add overflow");
26 } 41 }
27 42
28 int sub(int a, int b) 43 int sub(int a, int b)
29 { 44 {
30 int res; 45 int res;
31 asm 46 version (LLVM_InlineAsm_X86)
32 { 47 {
33 mov EAX, a; 48 asm
34 sub EAX, b; 49 {
35 jo Loverflow; 50 mov EAX, a;
36 mov res, EAX; 51 sub EAX, b;
52 jo Loverflow;
53 mov res, EAX;
54 }
37 } 55 }
56 else version (LLVM_InlineAsm_X86_64)
57 {
58 asm
59 {
60 mov EAX, a;
61 sub EAX, b;
62 jo Loverflow;
63 mov res, EAX;
64 }
65 }
66 printf("%d\n",res);
38 return res; 67 return res;
39 Loverflow: 68 Loverflow:
40 assert(0, "sub overflow"); 69 assert(0, "sub overflow");
70 int x;
41 } 71 }