113
|
1 #include "stdio.h"
|
|
2
|
114
|
3 double sin(double);
|
113
|
4 void test1();
|
|
5 void print(int d);
|
|
6
|
|
7 int test2(int f,int i);
|
|
8
|
|
9 unsigned f = 3;
|
|
10 int d = -3;
|
|
11 unsigned f1 = 3;
|
132
|
12 unsigned f2 = 4;
|
113
|
13 int d1 = -3;
|
|
14 int d2 = -2;
|
|
15 unsigned h = 65536*100;
|
|
16
|
|
17 int
|
|
18 d2i(int d) {
|
|
19 return (int)d;
|
|
20 }
|
|
21
|
|
22 int
|
|
23 i2d(int u) {
|
|
24 return (int)u;
|
|
25 }
|
|
26
|
|
27 unsigned u;
|
|
28 unsigned
|
|
29 d2u(int d) {
|
|
30 return (unsigned)d;
|
|
31 }
|
|
32
|
|
33 int
|
|
34 u2d(unsigned u) {
|
|
35 return (int)u;
|
|
36 }
|
|
37
|
|
38 int
|
|
39 main(int ac,char *av[]) {
|
|
40 int g;
|
|
41 int i;
|
|
42 unsigned u;
|
|
43 unsigned d00 = ac?-30:ac;
|
116
|
44 unsigned d01 = 0x3ffffff;
|
|
45 unsigned d02 = 0x300;
|
113
|
46
|
427
|
47 printf("#0046:%d %f %d %f\n",1,0.1,1,0.1);
|
|
48 printf("#0047:%f %d %f %d\n",0.1,1,0.1,1);
|
114
|
49
|
427
|
50 printf("#0049:%u %u %u\n",d00,d01%d02,d01*d02);
|
113
|
51
|
|
52 g = 1;
|
|
53 g = -g;
|
427
|
54 printf("#0053:%d\ncond ",g);
|
|
55 if(f==f*1) printf("#0054:1 ");
|
|
56 if(d==f*1) printf("#0055:2 ");
|
|
57 if(f==f1) printf("#0056:3 ");
|
|
58 if(d==d1) printf("#0057:4 ");
|
|
59 if(d==d2) printf("#0058:-4 ");
|
|
60 if(d>d1) printf("#0059:5 ");
|
|
61 if(d>d2) printf("#0060:-5 ");
|
|
62 if(d>=d1) printf("#0061:6 ");
|
|
63 if(d>=d2) printf("#0062:-6 ");
|
|
64 if(d!=d1) printf("#0063:7 ");
|
|
65 if(d!=d2) printf("#0064:-7 ");
|
|
66 if(d<d1) printf("#0065:8 ");
|
|
67 if(d<d2) printf("#0066:-8 ");
|
|
68 if(d<=d1) printf("#0067:9 ");
|
|
69 if(d<=d2) printf("#0068:-9 ");
|
132
|
70
|
427
|
71 printf("#0070:unsigned ");
|
|
72 if(f>f1) printf("#0071:5 ");
|
|
73 if(f>f2) printf("#0072:-5 ");
|
|
74 if(f>=f1) printf("#0073:6 ");
|
|
75 if(f>=f2) printf("#0074:-6 ");
|
|
76 if(f!=f1) printf("#0075:7 ");
|
|
77 if(f!=f2) printf("#0076:-7 ");
|
|
78 if(f<f1) printf("#0077:8 ");
|
|
79 if(f<f2) printf("#0078:-8 ");
|
|
80 if(f<=f1) printf("#0079:9 ");
|
|
81 if(f<=f2) printf("#0080:-9 ");
|
132
|
82
|
113
|
83 d = 123; f=-234;
|
|
84 i = d;
|
|
85 d = i;
|
|
86 i = f;
|
|
87 f = i;
|
427
|
88 printf("#0087:\n%d %d %d",i,d,f);
|
113
|
89 f = g = d = d1 = d2 = f;
|
427
|
90 printf("#0089: %d %d %d %d\n",i,d,f,g);
|
113
|
91
|
|
92 d = 320967294; f=224967294;
|
|
93 u = d;
|
|
94 d = u;
|
|
95 u = f;
|
|
96 f = u;
|
427
|
97 printf("#0096:%u %d %d\n",u,d,f);
|
113
|
98
|
|
99 print(1.0);
|
|
100 print(0.1234*100);
|
|
101 print(1.234e6);
|
|
102 print(-1.234e+3);
|
|
103
|
|
104 test1();
|
427
|
105 printf("#0104:nested call: %d\n",test2(test2(test2(test2(-333,3),5),6),7));
|
116
|
106 /* test3(40,20); */
|
113
|
107 return 0;
|
|
108 }
|
|
109
|
|
110 void
|
|
111 print(int d)
|
|
112 {
|
|
113 unsigned f;
|
|
114 int *dd;
|
|
115
|
|
116 f = d;
|
|
117
|
|
118
|
|
119 dd = (int*) &f;
|
427
|
120 printf("#0119:f %d ",f);
|
|
121 printf("#0120:dx %08x \n",*(dd));
|
113
|
122 }
|
|
123
|
|
124 int
|
|
125 testd(int i,int j)
|
|
126 {
|
|
127 return j+1.1+.0e3+12.3e-12;
|
|
128 }
|
|
129
|
|
130 unsigned
|
|
131 testf(unsigned i,unsigned j)
|
|
132 {
|
|
133 return j+1;
|
|
134 }
|
|
135
|
|
136 void
|
|
137 ahoaho() {
|
|
138 }
|
|
139
|
|
140 void
|
|
141 test1()
|
|
142 {
|
|
143 unsigned f;
|
|
144 unsigned f1;
|
|
145 int g;
|
|
146 int g1;
|
|
147 unsigned *pf;
|
|
148 unsigned *pf1;
|
|
149 int *pg;
|
|
150 int *pg1;
|
|
151 int n = 1;
|
|
152
|
427
|
153 printf("#0152:simple int ");
|
113
|
154 f = 1.3;
|
|
155
|
|
156 g = 1.0;
|
|
157 g = g+g;
|
427
|
158 printf("#0157:%d:%d\t",n++,g);
|
113
|
159 g1 = g*g;
|
427
|
160 printf("#0159:%d:%d\t",n++,g1);
|
113
|
161 g = g/g1;
|
427
|
162 printf("#0161:%d:%d\t",n++,g);
|
113
|
163 g = g-g1;
|
427
|
164 printf("#0163:%d:%d\t",n++,g);
|
113
|
165 g = sin(g1);
|
427
|
166 printf("#0165:%d:%d\t",n++,g);
|
113
|
167 g = testd(g,g1);
|
427
|
168 printf("#0167:%d:%d\t",n++,g);
|
|
169 printf("#0168:\n");
|
116
|
170 g = g+g;
|
|
171
|
|
172 g = 3.0;
|
427
|
173 printf("#0172:%d:%d\t",n++,g);
|
186
|
174 g1 = g<<2;
|
427
|
175 printf("#0174:<< %d:%d\t",n++,g1);
|
186
|
176 g1 = g<<f;
|
427
|
177 printf("#0176:<< %d:%d\t",n++,g1);
|
186
|
178 g1 = g>>2;
|
427
|
179 printf("#0178:>> %d:%d\t",n++,g1);
|
186
|
180 g1 = g>>f;
|
427
|
181 printf("#0180:>> %d:%d\t",n++,g1);
|
116
|
182 g = g%g1;
|
427
|
183 printf("#0182:% %d:%d\t",n++,g);
|
116
|
184 g = g|g1;
|
427
|
185 printf("#0184:| %d:%d\t",n++,g);
|
116
|
186 g = g&g1;
|
427
|
187 printf("#0186:& %d:%d\t",n++,g);
|
116
|
188 g = g^g1;
|
427
|
189 printf("#0188:^ %d:%d\t",n++,g);
|
113
|
190
|
186
|
191 g = -120;
|
|
192 g1 = g>>2;
|
427
|
193 printf("#0192:>> %d:%d\t",n++,g1);
|
186
|
194 g1 = g>>f;
|
427
|
195 printf("#0194:>> %d:%d\t",n++,g1);
|
209
|
196
|
427
|
197 printf("#0196:\n");
|
186
|
198
|
427
|
199 printf("#0198:simple unsigned ");
|
113
|
200 f = f+f;
|
427
|
201 printf("#0200:%d:%d\t",n++,f);
|
113
|
202 f1 = f*f;
|
427
|
203 printf("#0202:%d:%d\t",n++,f1);
|
113
|
204 f = f/f1;
|
427
|
205 printf("#0204:%d:%d\t",n++,f);
|
113
|
206 f = f-f1;
|
427
|
207 printf("#0206:%d:%d\t",n++,f);
|
113
|
208 f = sin(f1);
|
427
|
209 printf("#0208:%d:%d\t",n++,f);
|
|
210 printf("#0209:\n");
|
113
|
211
|
116
|
212 f = 3.0;
|
427
|
213 printf("#0212:%d:%d\t",n++,f);
|
116
|
214 f1 = f<<f;
|
427
|
215 printf("#0214:%d:%d\t",n++,f1);
|
116
|
216 f = f%f1;
|
427
|
217 printf("#0216:%d:%d\t",n++,f);
|
116
|
218 f = f|f1;
|
427
|
219 printf("#0218:%d:%d\t",n++,f);
|
116
|
220 f = f&f1;
|
427
|
221 printf("#0220:%d:%d\t",n++,f);
|
116
|
222 f = f^f1;
|
427
|
223 printf("#0222:%d:%d\t",n++,f);
|
|
224 printf("#0223:\n");
|
116
|
225
|
|
226
|
427
|
227 printf("#0226:post/pre increment ");
|
113
|
228 g1 = g;
|
427
|
229 printf("#0228:%d:%d\t",n++,g1++ - ++g);
|
113
|
230
|
|
231 f1 = f;
|
427
|
232 printf("#0231:%d:%d\t",n++,f1++ - ++f);
|
113
|
233
|
|
234 g1 = g;
|
427
|
235 printf("#0234:%d:%d\t",n++,g1-- - --g);
|
113
|
236
|
|
237 f1 = f;
|
427
|
238 printf("#0237:%d:%d\t",n++,f1-- - --f);
|
113
|
239
|
427
|
240 printf("#0239:\n");
|
|
241 printf("#0240:simple calc ");
|
113
|
242
|
114
|
243 f=3.13; g=-7.56; f1=-5.13; g1=7.56;
|
113
|
244
|
|
245 g = f+f;
|
427
|
246 printf("#0245:%d:%d\t",n++,g);
|
113
|
247 f = g*g;
|
427
|
248 printf("#0247:%d:%d\t",n++,f);
|
113
|
249 g = g*g+f*f-g1*g1;
|
427
|
250 printf("#0249:%d:%d\t",n++,g);
|
|
251 printf("#0250:\n");
|
113
|
252
|
427
|
253 printf("#0252:unsigned argument ");
|
113
|
254 f = testf(f,f1);
|
427
|
255 printf("#0254:%d:%d\t",n++,f);
|
113
|
256
|
427
|
257 printf("#0256:\nindirect ");
|
113
|
258 n=1;
|
|
259 f = 1.3; pf=&f; pf1=&f1;
|
|
260
|
|
261 ahoaho();
|
|
262 g = 1.0; pg=&g; pg1=&g1;
|
|
263 *pg = *pg+ *pg;
|
427
|
264 printf("#0263:%d:%d\t",n++,*pg);
|
113
|
265 *pg1 = *pg**pg;
|
427
|
266 printf("#0265:%d:%d\t",n++,*pg1);
|
113
|
267 *pg = *pg/ *pg1;
|
427
|
268 printf("#0267:%d:%d\t",n++,*pg);
|
113
|
269 *pg = *pg-*pg1;
|
427
|
270 printf("#0269:%d:%d\t",n++,*pg);
|
113
|
271 *pg = sin(*pg1);
|
427
|
272 printf("#0271:%d:%d\t",n++,*pg);
|
113
|
273 *pg = testd(*pg,*pg1);
|
427
|
274 printf("#0273:%d:%d\t",n++,*pg);
|
|
275 printf("#0274:\n");
|
113
|
276
|
|
277 *pf = *pf+*pf;
|
427
|
278 printf("#0277:%d:%d\t",n++,*pf);
|
113
|
279 *pf1 = *pf**pf;
|
427
|
280 printf("#0279:%d:%d\t",n++,*pf1);
|
113
|
281 *pf = *pf/ *pf1;
|
427
|
282 printf("#0281:%d:%d\t",n++,*pf);
|
113
|
283 *pf = *pf-*pf1;
|
427
|
284 printf("#0283:%d:%d\t",n++,*pf);
|
113
|
285 *pf = sin(*pf1);
|
427
|
286 printf("#0285:%d:%d\t",n++,*pf);
|
|
287 printf("#0286:\n");
|
113
|
288
|
427
|
289 printf("#0288:indirect post/pre ");
|
113
|
290 *pg1 = *pg;
|
427
|
291 printf("#0290:%d:%d\t",n++,(*pg1)++ - ++(*pg));
|
113
|
292
|
|
293 *pf1 = *pf;
|
427
|
294 printf("#0293:%d:%d\t",n++,(*pf1)++ - ++(*pf));
|
113
|
295
|
|
296 *pg1 = *pg;
|
427
|
297 printf("#0296:%d:%d\t",n++, (*pg1)-- - --(*pg));
|
113
|
298
|
|
299 *pf1 = *pf;
|
427
|
300 printf("#0299:%d:%d\t",n++, (*pf1)-- - --(*pf));
|
|
301 printf("#0300:\n");
|
113
|
302
|
114
|
303 *pf=3.13; *pg=-7.56; *pf1=-5.13; *pg1=7.56;
|
113
|
304
|
|
305 *pg = *pf+*pf;
|
427
|
306 printf("#0305:%d:%d\t",n++,*pg);
|
113
|
307 *pf = *pg**pg;
|
427
|
308 printf("#0307:%d:%d\t",n++,*pf);
|
113
|
309 *pg = *pg**pg+*pf**pf-*pg1**pg1;
|
427
|
310 printf("#0309:%d:%d\t",n++,*pg);
|
|
311 printf("#0310:\n");
|
113
|
312
|
427
|
313 printf("#0312:unsigned argument ");
|
113
|
314
|
|
315 *pf = testf(*pf,*pf1);
|
427
|
316 printf("#0315:%d:%d\t",n++,*pf);
|
113
|
317
|
|
318
|
427
|
319 printf("#0318:\nassop ");
|
113
|
320 n=1;
|
|
321 f = 1.3;
|
|
322 g = 1.0;
|
|
323
|
|
324 g *= 2*g;
|
427
|
325 printf("#0324:%d:%d\t",n++,g);
|
113
|
326 g /= 2*g;
|
427
|
327 printf("#0326:%d:%d\t",n++,g);
|
113
|
328 g -= 2*g;
|
427
|
329 printf("#0328:%d:%d\t",n++,g);
|
113
|
330 g += 2*g;
|
427
|
331 printf("#0330:%d:%d\t",n++,g);
|
113
|
332
|
127
|
333 g = -3;
|
113
|
334 f *= 2*g;
|
427
|
335 printf("#0334:%d:%d\t",n++,f);
|
113
|
336 f /= 2*g;
|
427
|
337 printf("#0336:%d:%d\t",n++,f);
|
113
|
338 f -= 2*g;
|
427
|
339 printf("#0338:%d:%d\t",n++,f);
|
113
|
340 f += 2*g;
|
427
|
341 printf("#0340:%d:%d\t",n++,f);
|
|
342 printf("#0341:\n");
|
113
|
343
|
|
344 n=1;
|
|
345 f = 1.3;
|
|
346 g = 1.0;
|
|
347
|
427
|
348 printf("#0347:indirect assop ");
|
113
|
349 *pg *= 2**pg;
|
427
|
350 printf("#0349:%d:%d\t",n++,*pg);
|
113
|
351 *pg /= 2**pg;
|
427
|
352 printf("#0351:%d:%d\t",n++,*pg);
|
113
|
353 *pg -= 2**pg;
|
427
|
354 printf("#0353:%d:%d\t",n++,*pg);
|
113
|
355 *pg += 2**pg;
|
427
|
356 printf("#0355:%d:%d\t",n++,*pg);
|
113
|
357
|
127
|
358 *pg = -3;
|
113
|
359 *pf *= 2**pg;
|
427
|
360 printf("#0359:%d:%d\t",n++,*pf);
|
113
|
361 *pf /= 2**pg;
|
427
|
362 printf("#0361:%d:%d\t",n++,*pf);
|
113
|
363 *pf -= 2**pg;
|
427
|
364 printf("#0363:%d:%d\t",n++,*pf);
|
113
|
365 *pf += 2**pg;
|
427
|
366 printf("#0365:%d:%d\t",n++,*pf);
|
|
367 printf("#0366:\n");
|
113
|
368
|
|
369
|
|
370 return;
|
|
371 }
|
|
372
|
|
373 int
|
|
374 test2(int f,int i)
|
|
375 {
|
|
376 int g,h;
|
|
377
|
|
378 if (i<=0) return f;
|
116
|
379 #if 0
|
427
|
380 printf("#0379:rec: %d %d\n",i,f);
|
113
|
381 #endif
|
|
382 g = f*2;
|
114
|
383 h = f-3.5;
|
|
384 return h/3-(3.0-(g+3)*test2(f*1.5,i-1)/(h-1));
|
113
|
385 }
|
116
|
386
|
|
387 int
|
|
388 test3(int base,int base1)
|
|
389 {
|
|
390 int i,j;
|
|
391 for(i=0;i<10;i++) {
|
|
392 for(j=0;j<10;j++) {
|
427
|
393 printf("#0392:%d ",(base+i)%(base1+j));
|
116
|
394 }
|
427
|
395 printf("#0394:\n");
|
116
|
396 }
|
|
397 return 0;
|
|
398 }
|