Mercurial > projects > ldc
comparison tests/mini/asm1_1.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 | 12b423e17860 |
children |
comparison
equal
deleted
inserted
replaced
1214:7e5547d8e59f | 1215:08f87d8cd101 |
---|---|
7 int i = 12; | 7 int i = 12; |
8 int* ip = &i; | 8 int* ip = &i; |
9 printf("%d\n", i); | 9 printf("%d\n", i); |
10 version (D_InlineAsm_X86) | 10 version (D_InlineAsm_X86) |
11 { | 11 { |
12 asm | 12 asm |
13 { | 13 { |
14 mov EBX, ip; | 14 mov ECX, ip; |
15 mov EAX, [EBX]; | 15 mov EAX, [ECX]; |
16 add EAX, 8; | 16 add EAX, 8; |
17 mul EAX, EAX; | 17 mul EAX, EAX; |
18 mov [EBX], EAX; | 18 mov [ECX], EAX; |
19 } | 19 } |
20 } | 20 } |
21 else version (D_InlineAsm_X86_64) | 21 else version (D_InlineAsm_X86_64) |
22 { | 22 { |
23 asm | 23 asm |
24 { | 24 { |
25 movq RCX, ip; | 25 movq RCX, ip; |
26 movq RAX, [RCX]; | 26 mov EAX, [RCX]; |
27 add RAX, 8; | 27 add EAX, 8; |
28 imul RAX, RAX; | 28 imul EAX, EAX; |
29 movq [RCX], RAX; | 29 mov [RCX], EAX; |
30 } | 30 } |
31 } | 31 } |
32 printf("%d\n", i); | 32 printf("%d\n", i); |
33 assert(i == 400); | 33 assert(i == 400); |
34 return 0; | 34 return 0; |
35 } | 35 } |