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