comparison tests/mini/asm6.d @ 1215:08f87d8cd101

Fix some unittests for 64-bit asm. They were operating on int variables as if they were longs. This was causing asm1_1 to fail when compiled with -O3 because it was overwriting the spilled value of callee-saved register %rbx, which the runtime was using as a pointer value at the time.
author Frits van Bommel <fvbommel wxs.nl>
date Mon, 13 Apr 2009 17:42:36 +0200
parents 4c524d80e6e1
children
comparison
equal deleted inserted replaced
1214:7e5547d8e59f 1215:08f87d8cd101
1 extern(C) int printf(char*, ...); 1 extern(C) int printf(char*, ...);
2
3 version (D_InlineAsm_X86)
4 version = InlineAsm_X86_Any;
5 version (D_InlineAsm_X86_64)
6 version = InlineAsm_X86_Any;
2 7
3 void main() 8 void main()
4 { 9 {
5 int a,b,c; 10 int a,b,c;
6 a = int.max-1; 11 a = int.max-1;
7 b = 5; 12 b = 5;
8 version (D_InlineAsm_X86) 13 version (InlineAsm_X86_Any)
9 { 14 {
10 asm 15 asm
11 { 16 {
12 mov EAX, a; 17 mov EAX, a;
13 mov ECX, b; 18 mov ECX, b;
14 add EAX, ECX; 19 add EAX, ECX;
15 jo Loverflow; 20 jo Loverflow;
16 mov c, EAX; 21 mov c, EAX;
17 } 22 }
18 }
19 else version (D_InlineAsm_X86_64)
20 {
21 asm
22 {
23 movq RDX, a;
24 movq RAX, b;
25 add RDX, RAX;
26 jo Loverflow;
27 movq c, RDX;
28 }
29 } 23 }
30 printf("a == %d\n", a); 24 printf("a == %d\n", a);
31 printf("b == %d\n", b); 25 printf("b == %d\n", b);
32 printf("c == %d\n", c); 26 printf("c == %d\n", c);
33 assert(c == c); 27 assert(c == c);