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