b17834e66d59b8936ed2cc0f25fd1f71c3e3e879
[fw/sdcc] / src / regression / or1.c
1
2 unsigned char success=0;
3 unsigned char failures=0;
4 unsigned char dummy=0;
5
6 bit bit0 = 0;
7 bit bit1 = 0;
8 bit bit2 = 0;
9
10 unsigned int uint0 = 0;
11 unsigned int uint1 = 0;
12 unsigned char uchar0 = 0;
13 unsigned char uchar1 = 0;
14 unsigned long ulong0 = 0;
15 unsigned long ulong1 = 0;
16
17 void done()
18 {
19
20   dummy++;
21
22 }
23
24 // uchar0 = 0;
25 void or_lit2uchar(void)
26 {
27
28   if(uchar0)
29     failures++;
30
31   uchar0 |= 1;
32
33   if(uchar0 != 1)
34     failures++;
35
36   uchar0 |= 2;
37
38   if(uchar0 != 3)
39     failures++;
40
41   uchar0 |= 0x0e;
42
43   if(uchar0 != 0x0f)
44     failures++;
45
46 }
47
48
49 void or_lit2uint(void)
50 {
51
52   if(uint0)
53     failures++;
54
55   uint0 |= 1;
56   if(uint0 != 1) 
57     failures++;
58
59   uint0 |= 2;
60   if(uint0 != 3) 
61     failures++;
62
63   uint0 |= 0x100;
64   if(uint0 != 0x103) 
65     failures++;
66
67   uint0 |= 0x102;
68   if(uint0 != 0x103) 
69     failures++;
70
71   uint0 |= 0x303;
72   if(uint0 != 0x303) 
73     failures++;
74
75 }
76
77 void or_lit2ulong(void)
78 {
79
80   if(ulong0)
81     failures++;
82
83   ulong0 |= 1;
84   if(ulong0 != 1) 
85     failures++;
86
87   ulong0 |= 2;
88   if(ulong0 != 3) 
89     failures++;
90
91   ulong0 |= 0x100;
92   if(ulong0 != 0x103) 
93     failures++;
94
95   ulong0 |= 0x102;
96   if(ulong0 != 0x103) 
97     failures++;
98
99   ulong0 |= 0x303;
100   if(ulong0 != 0x303) 
101     failures++;
102
103   ulong0 |= 0x80000000;
104   if(ulong0 != 0x80000303) 
105     failures++;
106
107 }
108
109 /*-----------*/
110 void or_uchar2uchar(void)
111 {
112
113   uchar0 |= uchar1;
114
115   if(uchar0 != 1)
116     failures++;
117
118   uchar1 |= 0x0f;
119
120   uchar0 = uchar1 | 0x10;
121
122   if(uchar0 != 0x1f)
123     failures++;
124 }
125
126 void or_uint2uint(void)
127 {
128   uint0 |= uint1;
129
130   if(uint0 != 1)
131     failures++;
132
133   uint1 |= 0x0f;
134
135   uint0 = uint1 | 0x10;
136
137   if(uint0 != 0x1f)
138     failures++;
139
140 }
141
142 void or_bits1(void)
143 {
144
145   bit0 = bit0 | bit1 | bit2;
146
147 }
148
149 void or_bits2(void)
150 {
151
152   bit0 = bit1 | bit2;
153
154 }
155
156 void main(void)
157 {
158
159   or_lit2uchar();
160   or_lit2uint();
161   or_lit2ulong();
162
163   uchar0=0;
164   uchar1=1;
165   or_uchar2uchar();
166
167   uint0=0;
168   uint1=1;
169   or_uint2uint();
170
171   or_bits1();
172   if(bit0)
173     failures++;
174
175   or_bits2();
176   if(bit0)
177     failures++;
178
179   bit1=1;
180   or_bits1();
181   if(!bit0)
182     failures++;
183
184   or_bits2();
185   if(!bit0)
186     failures++;
187
188
189   success = failures;
190   done();
191 }