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