annotate run/a/asm_div_02_A.d @ 1630:d0efa3ae5522 default tip

run/mini/naked_asm5: New x86_64 ABI passes the arguments in reverse order.
author David Nadlinger <code@klickverbot.at>
date Sat, 23 Apr 2011 22:57:32 +0200
parents 2a1a6610f7ad
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
989
a468938b0160 inline ASM review
thomask
parents:
diff changeset
1 // $HeadURL$
a468938b0160 inline ASM review
thomask
parents:
diff changeset
2 // $Date$
a468938b0160 inline ASM review
thomask
parents:
diff changeset
3 // $Author$
a468938b0160 inline ASM review
thomask
parents:
diff changeset
4
a468938b0160 inline ASM review
thomask
parents:
diff changeset
5 module dstress.run.a.asm_div_02_A;
a468938b0160 inline ASM review
thomask
parents:
diff changeset
6
1151
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1044
diff changeset
7 // __DSTRESS_TORTURE_BLOCK__ -fPIC
2a1a6610f7ad various inline assembler fixes
thomask
parents: 1044
diff changeset
8
989
a468938b0160 inline ASM review
thomask
parents:
diff changeset
9 version(D_InlineAsm_X86){
a468938b0160 inline ASM review
thomask
parents:
diff changeset
10 version = runTest;
a468938b0160 inline ASM review
thomask
parents:
diff changeset
11 }else version(D_InlineAsm_X86_64){
a468938b0160 inline ASM review
thomask
parents:
diff changeset
12 version = runTest;
a468938b0160 inline ASM review
thomask
parents:
diff changeset
13 }
a468938b0160 inline ASM review
thomask
parents:
diff changeset
14
a468938b0160 inline ASM review
thomask
parents:
diff changeset
15 int main(){
a468938b0160 inline ASM review
thomask
parents:
diff changeset
16 version(runTest){
a468938b0160 inline ASM review
thomask
parents:
diff changeset
17 ubyte a, b;
a468938b0160 inline ASM review
thomask
parents:
diff changeset
18 ushort x = byte.max+3;
a468938b0160 inline ASM review
thomask
parents:
diff changeset
19 ubyte y = 2;
1044
03c97933de98 inline ASM review
thomask
parents: 989
diff changeset
20
989
a468938b0160 inline ASM review
thomask
parents:
diff changeset
21 asm{
a468938b0160 inline ASM review
thomask
parents:
diff changeset
22 mov AX, x;
a468938b0160 inline ASM review
thomask
parents:
diff changeset
23 mov BL, y;
a468938b0160 inline ASM review
thomask
parents:
diff changeset
24 div BL;
a468938b0160 inline ASM review
thomask
parents:
diff changeset
25 mov a, AL;
a468938b0160 inline ASM review
thomask
parents:
diff changeset
26 mov b, AH;
a468938b0160 inline ASM review
thomask
parents:
diff changeset
27 }
a468938b0160 inline ASM review
thomask
parents:
diff changeset
28
a468938b0160 inline ASM review
thomask
parents:
diff changeset
29 if(a != 65){
a468938b0160 inline ASM review
thomask
parents:
diff changeset
30 assert(0);
a468938b0160 inline ASM review
thomask
parents:
diff changeset
31 }
a468938b0160 inline ASM review
thomask
parents:
diff changeset
32 if(b != 0){
a468938b0160 inline ASM review
thomask
parents:
diff changeset
33 assert(0);
a468938b0160 inline ASM review
thomask
parents:
diff changeset
34 }
1044
03c97933de98 inline ASM review
thomask
parents: 989
diff changeset
35
989
a468938b0160 inline ASM review
thomask
parents:
diff changeset
36 x = byte.max+2;
a468938b0160 inline ASM review
thomask
parents:
diff changeset
37 y = 2;
1044
03c97933de98 inline ASM review
thomask
parents: 989
diff changeset
38
989
a468938b0160 inline ASM review
thomask
parents:
diff changeset
39 asm{
a468938b0160 inline ASM review
thomask
parents:
diff changeset
40 mov AX, x;
a468938b0160 inline ASM review
thomask
parents:
diff changeset
41 mov BL, y;
a468938b0160 inline ASM review
thomask
parents:
diff changeset
42 div BL;
a468938b0160 inline ASM review
thomask
parents:
diff changeset
43 mov a, AL;
a468938b0160 inline ASM review
thomask
parents:
diff changeset
44 mov b, AH;
a468938b0160 inline ASM review
thomask
parents:
diff changeset
45 }
1044
03c97933de98 inline ASM review
thomask
parents: 989
diff changeset
46
989
a468938b0160 inline ASM review
thomask
parents:
diff changeset
47 if(a != 64){
a468938b0160 inline ASM review
thomask
parents:
diff changeset
48 assert(0);
a468938b0160 inline ASM review
thomask
parents:
diff changeset
49 }
a468938b0160 inline ASM review
thomask
parents:
diff changeset
50 if(b != 1){
a468938b0160 inline ASM review
thomask
parents:
diff changeset
51 assert(0);
a468938b0160 inline ASM review
thomask
parents:
diff changeset
52 }
1044
03c97933de98 inline ASM review
thomask
parents: 989
diff changeset
53
989
a468938b0160 inline ASM review
thomask
parents:
diff changeset
54 return 0;
a468938b0160 inline ASM review
thomask
parents:
diff changeset
55 }else{
a468938b0160 inline ASM review
thomask
parents:
diff changeset
56 pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
a468938b0160 inline ASM review
thomask
parents:
diff changeset
57 static assert(0);
a468938b0160 inline ASM review
thomask
parents:
diff changeset
58 }
a468938b0160 inline ASM review
thomask
parents:
diff changeset
59 }