Mercurial > projects > ldc
comparison tests/mini/asm7.d @ 341:1bb99290e03a trunk
[svn r362] Started merging the old 'test' dir as well as the newer 'tangotests' dir into 'tests/mini' and 'tests/minicomplex'.
author | lindquist |
---|---|
date | Sun, 13 Jul 2008 02:51:19 +0200 |
parents | tangotests/asm7.d@2b72433d5c8c |
children | 4ac97ec7c18e |
comparison
equal
deleted
inserted
replaced
340:351c0077d0b3 | 341:1bb99290e03a |
---|---|
1 module tangotests.asm7; | |
2 | |
3 // test massive label collisions (runtime uses Loverflow too) | |
4 | |
5 void main() | |
6 { | |
7 int a = add(1,2); | |
8 int s = sub(1,2); | |
9 assert(a == 3); | |
10 assert(s == -1); | |
11 } | |
12 | |
13 int add(int a, int b) | |
14 { | |
15 int res; | |
16 asm | |
17 { | |
18 mov EAX, a; | |
19 add EAX, b; | |
20 jo Loverflow; | |
21 mov res, EAX; | |
22 } | |
23 return res; | |
24 Loverflow: | |
25 assert(0, "add overflow"); | |
26 } | |
27 | |
28 int sub(int a, int b) | |
29 { | |
30 int res; | |
31 asm | |
32 { | |
33 mov EAX, a; | |
34 sub EAX, b; | |
35 jo Loverflow; | |
36 mov res, EAX; | |
37 } | |
38 return res; | |
39 Loverflow: | |
40 assert(0, "sub overflow"); | |
41 } |