Commit | Line | Data |
---|---|---|
4a71579b PC |
1 | #include "alu.inc" |
2 | ||
3 | .code | |
4 | prolog | |
5 | ||
6 | #define SUBX(N, I0, I1, V) ALUX(N, sub, I0, I1, V) | |
7 | ||
8 | /* nothing */ | |
9 | SUBX(0, 0, 0, 0) | |
10 | #if __WORDSIZE == 32 | |
11 | /* carry */ | |
12 | SUBX(1, 0x7fffffff, 0xffffffff, 0xffffffff) | |
13 | /* overflow */ | |
14 | SUBX(2, 0x80000000, 1, 0) | |
15 | /* carry */ | |
16 | SUBX(3, 0x7fffffff, 0x80000000, 0xffffffff) | |
17 | /* overflow */ | |
18 | SUBX(4, 0x80000000, 0x7fffffff, 0) | |
19 | /* carry+overflow */ | |
20 | SUBX(5, 1, 0x80000000, 0xffffffff) | |
21 | #else | |
22 | /* carry */ | |
23 | SUBX(1, 0x7fffffff, 0xffffffff, -1) | |
24 | /* nothing */ | |
25 | SUBX(2, 0x80000000, 1, 0) | |
26 | /* carry */ | |
27 | SUBX(3, 0x7fffffff, 0x80000000, -1) | |
28 | /* nothing */ | |
29 | SUBX(4, 0x80000000, 0x7fffffff, 0) | |
30 | /* carry */ | |
31 | SUBX(5, 1, 0x80000000, -1) | |
32 | /* carry */ | |
33 | SUBX(6, 0x7fffffffffffffff, 0xffffffffffffffff, -1) | |
34 | /* overflow */ | |
35 | SUBX(7, 0x8000000000000000, 1, 0) | |
36 | /* carry */ | |
37 | SUBX(8, 0x7fffffffffffffff, 0x8000000000000000, -1) | |
38 | /* overflow */ | |
39 | SUBX(9, 0x8000000000000000, 0x7fffffffffffffff, 0) | |
40 | /* carry+overflow */ | |
41 | SUBX(10,1, 0x8000000000000000, -1) | |
42 | #endif | |
43 | ||
44 | prepare | |
45 | pushargi ok | |
46 | ellipsis | |
47 | finishi @printf | |
48 | ret | |
49 | epilog |