root / tests / tcg / cris / check_addc.c @ c09015dd
History | View | Annotate | Download (1.3 kB)
1 | dd43edf4 | ths | #include <stdio.h> |
---|---|---|---|
2 | dd43edf4 | ths | #include <stdlib.h> |
3 | dd43edf4 | ths | #include <stdint.h> |
4 | dd43edf4 | ths | #include "sys.h" |
5 | dd43edf4 | ths | #include "crisutils.h" |
6 | dd43edf4 | ths | |
7 | 4a6648f4 | Blue Swirl | static inline int cris_addc(int a, const int b) |
8 | 4a6648f4 | Blue Swirl | { |
9 | dd43edf4 | ths | asm ("addc\t%1, %0\n" : "+r" (a) : "r" (b)); |
10 | dd43edf4 | ths | return a;
|
11 | dd43edf4 | ths | } |
12 | dd43edf4 | ths | |
13 | dd43edf4 | ths | #define verify_addc(a, b, res, n, z, v, c) \
|
14 | dd43edf4 | ths | { \ |
15 | dd43edf4 | ths | int r; \
|
16 | dd43edf4 | ths | r = cris_addc((a), (b)); \ |
17 | dd43edf4 | ths | cris_tst_cc((n), (z), (v), (c)); \ |
18 | dd43edf4 | ths | if (r != (res)) \
|
19 | dd43edf4 | ths | err(); \ |
20 | dd43edf4 | ths | } |
21 | dd43edf4 | ths | |
22 | dd43edf4 | ths | int main(void) |
23 | dd43edf4 | ths | { |
24 | dd43edf4 | ths | cris_tst_cc_init(); |
25 | dd43edf4 | ths | asm volatile ("clearf cz"); |
26 | dd43edf4 | ths | verify_addc(0, 0, 0, 0, 0, 0, 0); |
27 | dd43edf4 | ths | |
28 | dd43edf4 | ths | cris_tst_cc_init(); |
29 | dd43edf4 | ths | asm volatile ("setf z"); |
30 | dd43edf4 | ths | verify_addc(0, 0, 0, 0, 1, 0, 0); |
31 | dd43edf4 | ths | |
32 | dd43edf4 | ths | cris_tst_cc_init(); |
33 | dd43edf4 | ths | asm volatile ("setf cz"); |
34 | dd43edf4 | ths | verify_addc(0, 0, 1, 0, 0, 0, 0); |
35 | dd43edf4 | ths | cris_tst_cc_init(); |
36 | dd43edf4 | ths | asm volatile ("clearf c"); |
37 | dd43edf4 | ths | verify_addc(-1, 2, 1, 0, 0, 0, 1); |
38 | dd43edf4 | ths | |
39 | dd43edf4 | ths | cris_tst_cc_init(); |
40 | dd43edf4 | ths | asm volatile ("clearf nzv"); |
41 | dd43edf4 | ths | asm volatile ("setf c"); |
42 | dd43edf4 | ths | verify_addc(-1, 2, 2, 0, 0, 0, 1); |
43 | dd43edf4 | ths | |
44 | dd43edf4 | ths | cris_tst_cc_init(); |
45 | dd43edf4 | ths | asm volatile ("setf c"); |
46 | dd43edf4 | ths | verify_addc(0xffff, 0xffff, 0x1ffff, 0, 0, 0, 0); |
47 | dd43edf4 | ths | |
48 | dd43edf4 | ths | cris_tst_cc_init(); |
49 | dd43edf4 | ths | asm volatile ("clearf nzvc"); |
50 | dd43edf4 | ths | verify_addc(-1, -1, 0xfffffffe, 1, 0, 0, 1); |
51 | dd43edf4 | ths | |
52 | dd43edf4 | ths | cris_tst_cc_init(); |
53 | dd43edf4 | ths | asm volatile ("setf c"); |
54 | dd43edf4 | ths | verify_addc(0x78134452, 0x5432f789, 0xcc463bdc, 1, 0, 1, 0); |
55 | dd43edf4 | ths | |
56 | dd43edf4 | ths | pass(); |
57 | dd43edf4 | ths | return 0; |
58 | dd43edf4 | ths | } |