root / tests / cris / check_addc.c @ 651721b2
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 | dd43edf4 | ths | extern inline int cris_addc(int a, const int b) { |
8 | dd43edf4 | ths | asm ("addc\t%1, %0\n" : "+r" (a) : "r" (b)); |
9 | dd43edf4 | ths | return a;
|
10 | dd43edf4 | ths | } |
11 | dd43edf4 | ths | |
12 | dd43edf4 | ths | #define verify_addc(a, b, res, n, z, v, c) \
|
13 | dd43edf4 | ths | { \ |
14 | dd43edf4 | ths | int r; \
|
15 | dd43edf4 | ths | r = cris_addc((a), (b)); \ |
16 | dd43edf4 | ths | cris_tst_cc((n), (z), (v), (c)); \ |
17 | dd43edf4 | ths | if (r != (res)) \
|
18 | dd43edf4 | ths | err(); \ |
19 | dd43edf4 | ths | } |
20 | dd43edf4 | ths | |
21 | dd43edf4 | ths | int main(void) |
22 | dd43edf4 | ths | { |
23 | dd43edf4 | ths | cris_tst_cc_init(); |
24 | dd43edf4 | ths | asm volatile ("clearf cz"); |
25 | dd43edf4 | ths | verify_addc(0, 0, 0, 0, 0, 0, 0); |
26 | dd43edf4 | ths | |
27 | dd43edf4 | ths | cris_tst_cc_init(); |
28 | dd43edf4 | ths | asm volatile ("setf z"); |
29 | dd43edf4 | ths | verify_addc(0, 0, 0, 0, 1, 0, 0); |
30 | dd43edf4 | ths | |
31 | dd43edf4 | ths | cris_tst_cc_init(); |
32 | dd43edf4 | ths | asm volatile ("setf cz"); |
33 | dd43edf4 | ths | verify_addc(0, 0, 1, 0, 0, 0, 0); |
34 | dd43edf4 | ths | cris_tst_cc_init(); |
35 | dd43edf4 | ths | asm volatile ("clearf c"); |
36 | dd43edf4 | ths | verify_addc(-1, 2, 1, 0, 0, 0, 1); |
37 | dd43edf4 | ths | |
38 | dd43edf4 | ths | cris_tst_cc_init(); |
39 | dd43edf4 | ths | asm volatile ("clearf nzv"); |
40 | dd43edf4 | ths | asm volatile ("setf c"); |
41 | dd43edf4 | ths | verify_addc(-1, 2, 2, 0, 0, 0, 1); |
42 | dd43edf4 | ths | |
43 | dd43edf4 | ths | cris_tst_cc_init(); |
44 | dd43edf4 | ths | asm volatile ("setf c"); |
45 | dd43edf4 | ths | verify_addc(0xffff, 0xffff, 0x1ffff, 0, 0, 0, 0); |
46 | dd43edf4 | ths | |
47 | dd43edf4 | ths | cris_tst_cc_init(); |
48 | dd43edf4 | ths | asm volatile ("clearf nzvc"); |
49 | dd43edf4 | ths | verify_addc(-1, -1, 0xfffffffe, 1, 0, 0, 1); |
50 | dd43edf4 | ths | |
51 | dd43edf4 | ths | cris_tst_cc_init(); |
52 | dd43edf4 | ths | asm volatile ("setf c"); |
53 | dd43edf4 | ths | verify_addc(0x78134452, 0x5432f789, 0xcc463bdc, 1, 0, 1, 0); |
54 | dd43edf4 | ths | |
55 | dd43edf4 | ths | pass(); |
56 | dd43edf4 | ths | return 0; |
57 | dd43edf4 | ths | } |