root / tests / cris / check_bound.c @ 1ffc346f
History | View | Annotate | Download (2.4 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_bound_b(int v, int b) { |
8 | dd43edf4 | ths | int r = v;
|
9 | dd43edf4 | ths | asm ("bound.b\t%1, %0\n" : "+r" (r) : "ri" (b)); |
10 | dd43edf4 | ths | return r;
|
11 | dd43edf4 | ths | } |
12 | dd43edf4 | ths | |
13 | dd43edf4 | ths | extern inline int cris_bound_w(int v, int b) { |
14 | dd43edf4 | ths | int r = v;
|
15 | dd43edf4 | ths | asm ("bound.w\t%1, %0\n" : "+r" (r) : "ri" (b)); |
16 | dd43edf4 | ths | return r;
|
17 | dd43edf4 | ths | } |
18 | dd43edf4 | ths | |
19 | dd43edf4 | ths | extern inline int cris_bound_d(int v, int b) { |
20 | dd43edf4 | ths | int r = v;
|
21 | dd43edf4 | ths | asm ("bound.d\t%1, %0\n" : "+r" (r) : "ri" (b)); |
22 | dd43edf4 | ths | return r;
|
23 | dd43edf4 | ths | } |
24 | dd43edf4 | ths | |
25 | dd43edf4 | ths | int main(void) |
26 | dd43edf4 | ths | { |
27 | dd43edf4 | ths | int r;
|
28 | dd43edf4 | ths | |
29 | dd43edf4 | ths | cris_tst_cc_init(); |
30 | dd43edf4 | ths | r = cris_bound_d(-1, 2); |
31 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
32 | dd43edf4 | ths | if (r != 2) |
33 | dd43edf4 | ths | err(); |
34 | dd43edf4 | ths | |
35 | dd43edf4 | ths | cris_tst_cc_init(); |
36 | dd43edf4 | ths | r = cris_bound_d(2, 0xffffffff); |
37 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
38 | dd43edf4 | ths | if (r != 2) |
39 | dd43edf4 | ths | err(); |
40 | dd43edf4 | ths | |
41 | dd43edf4 | ths | cris_tst_cc_init(); |
42 | dd43edf4 | ths | r = cris_bound_d(0xffff, 0xffff); |
43 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
44 | dd43edf4 | ths | if (r != 0xffff) |
45 | dd43edf4 | ths | err(); |
46 | dd43edf4 | ths | |
47 | dd43edf4 | ths | cris_tst_cc_init(); |
48 | dd43edf4 | ths | r = cris_bound_d(-1, 0xffffffff); |
49 | dd43edf4 | ths | cris_tst_cc(1, 0, 0, 0); |
50 | dd43edf4 | ths | if (r != 0xffffffff) |
51 | dd43edf4 | ths | err(); |
52 | dd43edf4 | ths | |
53 | dd43edf4 | ths | cris_tst_cc_init(); |
54 | dd43edf4 | ths | r = cris_bound_d(0x78134452, 0x5432f789); |
55 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
56 | dd43edf4 | ths | if (r != 0x5432f789) |
57 | dd43edf4 | ths | err(); |
58 | dd43edf4 | ths | |
59 | dd43edf4 | ths | cris_tst_cc_init(); |
60 | dd43edf4 | ths | r = cris_bound_w(-1, 2); |
61 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
62 | dd43edf4 | ths | if (r != 2) |
63 | dd43edf4 | ths | err(); |
64 | dd43edf4 | ths | |
65 | dd43edf4 | ths | cris_tst_cc_init(); |
66 | dd43edf4 | ths | r = cris_bound_w(-1, 0xffff); |
67 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
68 | dd43edf4 | ths | if (r != 0xffff) |
69 | dd43edf4 | ths | err(); |
70 | dd43edf4 | ths | |
71 | dd43edf4 | ths | cris_tst_cc_init(); |
72 | dd43edf4 | ths | r = cris_bound_w(2, 0xffff); |
73 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
74 | dd43edf4 | ths | if (r != 2) |
75 | dd43edf4 | ths | err(); |
76 | dd43edf4 | ths | |
77 | dd43edf4 | ths | cris_tst_cc_init(); |
78 | dd43edf4 | ths | r = cris_bound_w(0xfedaffff, 0xffff); |
79 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
80 | dd43edf4 | ths | if (r != 0xffff) |
81 | dd43edf4 | ths | err(); |
82 | dd43edf4 | ths | |
83 | dd43edf4 | ths | cris_tst_cc_init(); |
84 | dd43edf4 | ths | r = cris_bound_w(0x78134452, 0xf789); |
85 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
86 | dd43edf4 | ths | if (r != 0xf789) |
87 | dd43edf4 | ths | err(); |
88 | dd43edf4 | ths | |
89 | dd43edf4 | ths | cris_tst_cc_init(); |
90 | dd43edf4 | ths | r = cris_bound_b(-1, 2); |
91 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
92 | dd43edf4 | ths | if (r != 2) |
93 | dd43edf4 | ths | err(); |
94 | dd43edf4 | ths | |
95 | dd43edf4 | ths | cris_tst_cc_init(); |
96 | dd43edf4 | ths | r = cris_bound_b(2, 0xff); |
97 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
98 | dd43edf4 | ths | if (r != 2) |
99 | dd43edf4 | ths | err(); |
100 | dd43edf4 | ths | |
101 | dd43edf4 | ths | cris_tst_cc_init(); |
102 | dd43edf4 | ths | r = cris_bound_b(-1, 0xff); |
103 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
104 | dd43edf4 | ths | if (r != 0xff) |
105 | dd43edf4 | ths | err(); |
106 | dd43edf4 | ths | |
107 | dd43edf4 | ths | cris_tst_cc_init(); |
108 | dd43edf4 | ths | r = cris_bound_b(0xff, 0xff); |
109 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
110 | dd43edf4 | ths | if (r != 0xff) |
111 | dd43edf4 | ths | err(); |
112 | dd43edf4 | ths | |
113 | dd43edf4 | ths | cris_tst_cc_init(); |
114 | dd43edf4 | ths | r = cris_bound_b(0xfeda49ff, 0xff); |
115 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
116 | dd43edf4 | ths | if (r != 0xff) |
117 | dd43edf4 | ths | err(); |
118 | dd43edf4 | ths | |
119 | dd43edf4 | ths | cris_tst_cc_init(); |
120 | dd43edf4 | ths | r = cris_bound_b(0x78134452, 0x89); |
121 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
122 | dd43edf4 | ths | if (r != 0x89) |
123 | dd43edf4 | ths | err(); |
124 | dd43edf4 | ths | |
125 | dd43edf4 | ths | cris_tst_cc_init(); |
126 | dd43edf4 | ths | r = cris_bound_w(0x78134452, 0); |
127 | dd43edf4 | ths | cris_tst_cc(0, 1, 0, 0); |
128 | dd43edf4 | ths | if (r != 0) |
129 | dd43edf4 | ths | err(); |
130 | dd43edf4 | ths | |
131 | dd43edf4 | ths | cris_tst_cc_init(); |
132 | dd43edf4 | ths | r = cris_bound_b(0xffff, -1); |
133 | dd43edf4 | ths | cris_tst_cc(0, 0, 0, 0); |
134 | dd43edf4 | ths | if (r != 0xff) |
135 | dd43edf4 | ths | err(); |
136 | dd43edf4 | ths | |
137 | dd43edf4 | ths | pass(); |
138 | dd43edf4 | ths | return 0; |
139 | dd43edf4 | ths | } |