* Removed all Id tags.
[cacao.git] / tests / regression / jctest.java
1 /* tests/jctest.java - checks most of the JVM instructions
2
3    Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
4    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6    TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25    Contact: cacao@cacaojvm.org
26
27    Authors: Reinhard Grafl
28             Christian Thalinger
29
30 */
31
32 public class jctest implements jcinterface {
33     static {
34         p("<clinit> called");
35     }
36
37     static int linenum = 0;
38
39     static int i1 = 77;
40     static long l1 = 123456789, l2 = 987654321, l3 = -99999999999999L;
41     static int i2, i3 = -100;
42     static float f1 = 0.1F, f2 = 0.2F, f3 = 0.3F;
43     static double d1 = 0.001, d2 = 0.002, d3 = 0.003;
44     static String s1, s2 = "constant string";
45
46     int n_i1, n_i2, n_i3, n_i4;
47     long n_l1, n_l2, n_l3, n_l4;
48     float n_f1, n_f2, n_f3, n_f4;
49     double n_d1, n_d2, n_d3, n_d4;
50
51         
52     public static void main(String[] s) {
53         p ("=================== JavaVM - Tester ========================");
54
55         p ("------------------- test arguments");
56         int i;
57         for (i = 0; i < s.length; i++) p(s[i]);
58
59         testgeneral();
60         testtables();
61         testcasts();
62         testspecialnullpointers();
63         testarrays();
64                 
65         p("------------------- test consts");
66         testconst( 1,          1);
67         testconst(-1,         -1);
68         testconst(-24123,     -4918923241323L);
69         testconst(-243511,    -4423423234231423L);
70         testconst(0x7fffffff, 0x7fffffffffffffffL);
71         testconst(0x80000000, 0x8000000000000000L);
72
73         p("------------------- test div and rem consts");
74         testdivremconst(17);
75         testdivremconst(12347);
76         testdivremconst(8893427);
77         testdivremconst(1005234562);
78         testdivremconst(-17);
79         testdivremconst(-12347);
80         testdivremconst(-8893427);
81         testdivremconst(-1005234562);
82
83         testdivremconst(17L);
84         testdivremconst(12347L);
85         testdivremconst(8893427L);
86         testdivremconst(1005234562L);
87         testdivremconst(12135005234562L);
88         testdivremconst(2343552355623464626L);
89         testdivremconst(-17L);
90         testdivremconst(-12347L);
91         testdivremconst(-8893427L);
92         testdivremconst(-1005234562L);
93         testdivremconst(-12135005234562L);
94         testdivremconst(-2343552355623464626L);
95
96         p("------------------- test ints");
97         testint(1,2);
98         testint(-1,17);
99         testint(-24351,24123);
100         testint(4918923,-441423);
101         testint(0,0);
102         testint(-1,-1);
103         testint(1423487,123444444);
104         testint(0x7fffffff,1);
105         testint(0,0x7fffffff);
106         testint(0x3333,143444);
107         testint(4444441,12342);
108         testint(0x80000000,-1);
109
110         p("------------------- test longs");
111         testlong(1,2);
112         testlong(-1,17);
113         testlong(-24351,24123);
114         testlong(4918923241323L,-4423423234231423L);
115         testlong(0,0);
116         testlong(-1,-1);
117         testlong(1423487,123444442344L);
118         testlong(0x7fffffffffffffffL,1);
119         testlong(0,0x7fffffffffffffffL);
120         testlong(0x3333,143444);
121         testlong(4444441,12342);
122         testlong(0x8000000000000000L,-1);
123         testlong(0x0000000080000000L,0x0000000080000000L);
124
125         p("------------------- test floats");
126         testfloat((float) 1,(float) 2.042);
127         testfloat((float) -1.234,(float) 17.44);
128         testfloat((float) -24351,(float) 24123);
129         testfloat((float) 0.1,(float) 1243);
130         testfloat((float) 0.0,(float) -555.4132);
131         testfloat((float) 77.0,(float) -555);
132         testfloat((float) 2147483000.0,(float) -555234);
133
134         p("------------------- test doubles");
135         testdouble(1,2.042);
136         testdouble(-1.234,17.44);
137         testdouble(-24351,24123);
138         testdouble(0.1,1243);
139         testdouble(0.0,-555.4132);
140         testdouble(77.0,-555);
141         testdouble(2147483000.0,-555234);
142
143         p("=================== end of test =========================");
144     }
145
146
147     public static void testgeneral() {
148         int i;
149         // ******************** basic data types *******************************
150                 
151         p ("------------------- test int-PUSH-STORE-LOAD");
152         int j = -1;
153         p(j); p (0); p(2); p(17); p(-100); 
154         p (500); p(-32768); p(-32769); p(32767); p(32768);
155         p (90000); p(-1000000000);
156                 
157         p ("------------------- test long-PUSH-STORE-LOAD");
158         long l = 3L;
159         p ( l ); p ( 0L ); p ( 99L );
160         p (500L); p(-32768L); p(-32769L); p(32767L); p(32768L);
161         p ( 6900000000000L ); p ( 349827389478173274L );
162
163         p ("------------------- test float-PUSH-STORE-LOAD");
164         float f = 99.444F;
165         p ( f ); p (0.0F); p (1.0F); p (342323423478.2223434234232334F);
166         
167         p ("------------------- test double-PUSH-STORE-LOAD");
168         double d = 99234.42D;
169         p ( d ); p (0.0D); p (1.0D); p (342323423478.2223434234232334D);
170
171
172         // ******************** static variables *******************************
173
174         p ("------------------- test static variables");        
175         i1 = i1+i2+i3;
176         l2 = l1+l2+l3;
177         f1 = f1*f2;
178         p (i1); p(i2); p(i3); 
179         p (l1); p(l2); p(l3);
180         p (f1); p(f2); p(f3);
181         p (d1); p(d2); p(d3);
182
183         // ******************** arithmetic test ********************************
184                 
185         p ("------------------- test arithmetic");
186         i1 = 17;
187         i2 = 0x7fffffff;
188         p (i2);
189         p (i2+1);
190         p (i1-i2);
191         l1 = 0x7fffffffffffffffL;
192         p (l1);
193         p (l1+1);
194         p (l1+0x7fffffffffffffffL);
195                 
196                 
197         // ******************** test method calls ******************************
198                 
199         p ("statische methode");
200         jctest ttt = new jctest ();
201         ttt.p_manyparam (19,18,17,16, 88,77,66,55, 
202                          0.1F,0.2F,0.3F,0.4F, -2.0D,-3.0D,-4.0D,-5.0D );
203         jcinterface ttt2 = ttt;
204         ttt2.p_nonstatic ("interface method");
205     }
206
207
208
209     // ************************ test tables ************************************
210                 
211     public static void testtables() {
212         int i;
213
214         p ("------------------- test tableswitch");
215
216         for (i = -5; i < 15; i++) {
217             switch (i) {
218             case  2:  p ("->  2"); break;       
219             case  3:  p ("->  3"); break;       
220             case  5:  p ("->  5"); break;       
221             case  6:  p ("->  6"); break;
222             case  7:  p ("->  7"); break;
223             case  8:  p ("->  8"); break;
224             case 10:  p ("-> 10"); break;
225             default:  p ("default"); break;
226             }
227         }
228
229         p ("------------------- test lookupswitch");
230
231         for (i = -5; i < 15; i++) {
232             switch (i) {
233             case  2:  p ("->  2"); break;
234             case  8:  p ("->  8"); break;
235             case 14:  p ("-> 14"); break;
236             case -4:  p ("-> -4"); break;
237             default:  p ("default"); break;
238             }
239         }       
240     }
241
242
243     // ****************** test type casts and array stores *********************
244
245     public static void testcasts() {
246         Object     on  = null;
247         Object     o   = new Object();
248         Object     oi  = new Integer(0);
249         Object[]   ona = null;
250         Object[]   oa  = new Object [1];
251         Object[]   oia = new Integer[1];
252         Integer    i   = new Integer(0);
253         Integer[]  ia;
254         java.io.DataOutput dataout = null;
255         Object             od  = new java.io.DataOutputStream(
256                                                               (java.io.DataOutputStream)dataout);
257
258         p ("------------------- test casts");
259
260         p("null is instanceof Object:  ", on instanceof Object);
261         p("Integer is instanceof Object:  ", oi instanceof Object);
262         p("Integer is instanceof Integer: ", oi instanceof Integer);
263         p("Object is instanceof Integer:  ", o instanceof Integer);
264
265         p("null is instanceof Object[]:  ", on instanceof Object[]);
266         p("Integer[] is instanceof Object[]:  ", oia instanceof Object[]);
267         p("Integer[] is instanceof Integer[]: ", oia instanceof Integer[]);
268         p("Object[] is instanceof Integer[]:  ", oa instanceof Integer[]);
269
270         p("Integer is instanceof Object[]:  ", oi instanceof Object[]);
271         p("Integer[] is instanceof Object:  ", oia instanceof Object);
272         p("Integer is instanceof Integer[]: ", oi instanceof Integer[]);
273         p("Object is instanceof Integer[]:  ", o instanceof Integer[]);
274
275         try {
276             p ("type cast check: Integer = Object(Integer)");
277             i = (Integer) oi;
278             p ("type cast check: Integer = Object");
279             i = (Integer) o;
280             p ("error: class cast exception not thrown");
281         }       
282         catch (ClassCastException c) {
283             p ("exception: class cast");
284         }
285
286         p("DataOutputStream is instanceof DataOutput: ",
287           od instanceof java.io.DataOutput);
288         p("Object is instanceof DataOutput: ", o instanceof java.io.DataOutput);
289
290         try {
291             p ("type cast check: DataOutput = Object(DataOutputStream)");
292             dataout = (java.io.DataOutput) od;
293             p ("type cast check: DataOutput = Object");
294             dataout = (java.io.DataOutput) o;
295             p ("error: class cast exception not thrown");
296         }       
297         catch (ClassCastException c) {
298             p ("exception: class cast");
299         }
300
301         try {
302             p ("type cast check: Integer[] = Object(Integer)[]");
303             ia = (Integer[]) oia;
304             p ("type cast check: Integer[] = Object[]");
305             ia = (Integer[]) oa;
306             p ("error: class cast exception not thrown");
307         }       
308         catch (ClassCastException c) {
309             p ("exception: class cast");
310         }
311
312         try {
313             p ("array store check: Object(Integer)[0] = Integer");
314             oia[0] = i;
315             p ("array store check: Object(Integer)[0] = Object");
316             oia[0] = o;
317             p ("error: array store exception not thrown");
318         }       
319         catch (ArrayStoreException c) {
320             p ("exception: array store");
321         }
322     }
323
324
325     // ****************** test special null pointers ***************************
326
327     public static void testspecialnullpointers() {
328         int i = 0;
329         jctest c = null;
330         jcinterface f = null;
331
332         p ("------------------- test special null pointers");
333
334         try {
335             p ("null pointer check: put field");
336             c.n_i1 = 0;
337             p ("error: put field null pointer exception not thrown");
338         }       
339         catch (NullPointerException x) {
340             p ("exception: null pointer");
341         }
342
343         try {
344             p ("null pointer check: get field");
345             i = c.n_i1;
346             p ("error: get field null pointer exception not thrown");
347         }       
348         catch (NullPointerException x) {
349             p ("exception: null pointer");
350         }
351
352         try {
353             p ("null pointer check: invokevirtual");
354             c.p_nonstatic("invokevirtual");
355             p ("error: invokevirtual null pointer exception not thrown");
356         }       
357         catch (NullPointerException x) {
358             p ("exception: null pointer");
359         }
360
361         try {
362             p ("null pointer check: invokeinterface");
363             f.p_nonstatic("invokeinterface");
364             p ("error: invokeinterface null pointer exception not thrown");
365         }       
366         catch (NullPointerException x) {
367             p ("exception: null pointer");
368         }
369
370         try {
371             p ("null pointer check: monitorenter");
372             synchronized (c) {
373                 p ("error: monitorenter null pointer exception not thrown");
374             }
375         }       
376         catch (NullPointerException x) {
377             p ("exception: null pointer");
378         }
379     }
380
381
382     // ************************ test array bounds ******************************
383
384     public static void testarraybounds(byte[] ba, int i) {
385         p ("testarraybounds: " + (i - 10));
386         ba[i-10] = 0;
387         p ("testarraybounds: " + (i - 5));
388         ba[i-5]  = 0;
389         p ("testarraybounds: " + (i));
390         ba[i]    = 0;
391         p ("testarraybounds: " + (i + 5));
392         ba[i+5]  = 0;
393         p ("testarraybounds: " + (i + 10));
394         ba[i+10] = 0; 
395     }
396
397
398     // ************************ test arrays ************************************                
399
400     public static void testarrays() {
401         int    i;
402         long   l;
403         float  f;
404         double d;
405         String s;
406                 
407         p ("------------------- test byte arrays");
408
409         byte[] ba = null;
410
411         try {
412             p ("null pointer check: byte array store");
413             ba[1] = 0;
414             p ("error: null pointer exception not thrown");
415         }       
416         catch (NullPointerException c) {
417             p ("exception: null pointer");
418         }
419         try {
420             p ("null pointer check: byte array load");
421             i = ba[1];
422             p ("error: null pointer exception not thrown");
423         }       
424         catch (NullPointerException c) {
425             p ("exception: null pointer");
426         }
427
428         try {
429             p ("negative array size check: byte array");
430             ba = new byte [-2];
431             p ("error: negative array size exception not thrown");
432         }       
433         catch (NegativeArraySizeException c) {
434             p ("exception: negative array size");
435         }
436
437         ba = new byte [100];
438
439
440         try {
441             p ("array bound check: byte array store");
442             ba[-1] = 0;
443             p ("error: exception not thrown");
444         }       
445         catch (ArrayIndexOutOfBoundsException c) {
446             p ("exception_1: out of bounds: "+(-1));
447         }
448         try {
449             p ("array bound check: byte array load");
450             i = ba[-1];
451             p ("error: exception not thrown");
452         }       
453         catch (ArrayIndexOutOfBoundsException c) {
454             p ("exception_2: out of bounds: "+(-1));
455         }
456
457         try {
458             testarraybounds(ba, 5);
459         }       
460         catch (ArrayIndexOutOfBoundsException c) {
461             p ("exception_3: out of bounds: "+5);
462         }
463         try {
464             testarraybounds(ba, 50);
465         }       
466         catch (ArrayIndexOutOfBoundsException c) {
467             p ("exception_4: out of bounds: "+50);
468         }
469         try {
470             testarraybounds(ba, 100);
471         }       
472         catch (ArrayIndexOutOfBoundsException c) {
473             p ("exception_5: out of bounds: "+100);
474         }
475
476         try {
477             ba[-4] = 0;
478         }       
479         catch (ArrayIndexOutOfBoundsException c) {
480             p ("exception_6: out of bounds: "+(-4));
481         }
482         try {
483             ba[-3] = 0;
484         }       
485         catch (ArrayIndexOutOfBoundsException c) {
486             p ("exception_7: out of bounds: "+(-3));
487         }
488
489         for (i=-2; i<102; i++) { 
490             try {
491                 ba[i] = (byte) (i-50);
492             }   
493             catch (ArrayIndexOutOfBoundsException c) {
494                 p ("exception_8: out of bounds: "+i);
495             }
496         }
497                 
498         try {
499             ba[102] = 0;
500         }       
501         catch (ArrayIndexOutOfBoundsException c) {
502             p ("exception_9: out of bounds: "+102);
503         }
504         try {
505             ba[103] = 0;
506         }       
507         catch (ArrayIndexOutOfBoundsException c) {
508             p ("exception_10: out of bounds: "+103);
509         }
510         for (i=0; i<100; i++) p (ba[i]);                
511
512
513                 
514
515         p ("-------- test short arrays");               
516
517         short[] sa = null;
518
519         try {
520             p ("null pointer check: short array store");
521             sa[1] = 0;
522             p ("error: null pointer exception not thrown");
523         }       
524         catch (NullPointerException c) {
525             p ("exception: null pointer");
526         }
527         try {
528             p ("null pointer check: short array load");
529             i = sa[1];
530             p ("error: null pointer exception not thrown");
531         }       
532         catch (NullPointerException c) {
533             p ("exception: null pointer");
534         }
535
536         sa = new short [100];
537
538         try {
539             p ("array bound check: short array store");
540             sa[-1] = 0;
541             p ("error: exception not thrown");
542         }       
543         catch (ArrayIndexOutOfBoundsException c) {
544             p ("exception_11: out of bounds: "+(-1));
545         }
546         try {
547             p ("array bound check: short array load");
548             i = sa[-1];
549             p ("error: exception not thrown");
550         }       
551         catch (ArrayIndexOutOfBoundsException c) {
552             p ("exception_12: out of bounds: "+(-1));
553         }
554
555         for (i=0; i<100; i++) sa[i] = (short) (i-50);
556         for (i=0; i<100; i++) p (sa[i]);
557                 
558                 
559
560         p ("-------- test int arrays");         
561
562         int[] ia = null;
563
564         try {
565             p ("null pointer check: int array store");
566             ia[1] = 0;
567             p ("error: null pointer exception not thrown");
568         }       
569         catch (NullPointerException c) {
570             p ("exception: null pointer");
571         }
572         try {
573             p ("null pointer check: int array load");
574             i = ia[1];
575             p ("error: null pointer exception not thrown");
576         }       
577         catch (NullPointerException c) {
578             p ("exception: null pointer");
579         }
580
581         ia = new int [50];
582
583         try {
584             p ("array bound check: int array store");
585             ia[-1] = 0;
586             p ("error: exception not thrown");
587         }       
588         catch (ArrayIndexOutOfBoundsException c) {
589             p ("exception: out of bounds: "+(-1));
590         }
591         try {
592             p ("array bound check: int array load");
593             i = ia[-1];
594             p ("error: exception not thrown");
595         }       
596         catch (ArrayIndexOutOfBoundsException c) {
597             p ("exception: out of bounds: "+(-1));
598         }
599
600         for (i=0; i<10; i++) ia[i] = (123456 + i);
601         for (i=0; i<10; i++) p (ia[i]);
602
603                 
604
605         p ("-------- test long arrays");                
606
607         long[] la = null;
608
609         try {
610             p ("null pointer check: long array store");
611             la[1] = 0;
612             p ("error: null pointer exception not thrown");
613         }       
614         catch (NullPointerException c) {
615             p ("exception: null pointer");
616         }
617         try {
618             p ("null pointer check: long array load");
619             l = la[1];
620             p ("error: null pointer exception not thrown");
621         }       
622         catch (NullPointerException c) {
623             p ("exception: null pointer");
624         }
625
626         la = new long [10];
627
628         try {
629             p ("array bound check: long array store");
630             la[-1] = 0;
631             p ("error: exception not thrown");
632         }       
633         catch (ArrayIndexOutOfBoundsException c) {
634             p ("exception: out of bounds: "+(-1));
635         }
636         try {
637             p ("array bound check: long array load");
638             l = la[-1];
639             p ("error: exception not thrown");
640         }       
641         catch (ArrayIndexOutOfBoundsException c) {
642             p ("exception: out of bounds: "+(-1));
643         }
644
645         for (i=0; i<10; i++) la[i] = (1234567890123L + i);
646         for (i=0; i<10; i++) p (la[i]);
647
648                 
649         p ("-------- test char arrays");                
650
651         char[] ca = null;
652
653         try {
654             p ("null pointer check: char array store");
655             ca[1] = 0;
656             p ("error: null pointer exception not thrown");
657         }       
658         catch (NullPointerException c) {
659             p ("exception: null pointer");
660         }
661         try {
662             p ("null pointer check: char array load");
663             i = ca[1];
664             p ("error: null pointer exception not thrown");
665         }       
666         catch (NullPointerException c) {
667             p ("exception: null pointer");
668         }
669
670         ca = new char [50];
671
672         try {
673             p ("array bound check: char array store");
674             ca[-1] = 0;
675             p ("error: exception not thrown");
676         }       
677         catch (ArrayIndexOutOfBoundsException c) {
678             p ("exception: out of bounds: "+(-1));
679         }
680         try {
681             p ("array bound check: char array load");
682             i = ca[-1];
683             p ("error: exception not thrown");
684         }       
685         catch (ArrayIndexOutOfBoundsException c) {
686             p ("exception: out of bounds: "+(-1));
687         }
688
689         for (i=0; i<50; i++) ca[i] = (char) ('A' + i);
690         for (i=0; i<50; i++) p (ca[i]);
691
692         p ("-------- test address arrays");
693
694         String[] sta = null;
695
696         try {
697             p ("null pointer check: address array store");
698             sta[1] = null;
699             p ("error: null pointer exception not thrown");
700         }       
701         catch (NullPointerException c) {
702             p ("exception: null pointer");
703         }
704         try {
705             p ("null pointer check: address array load");
706             s = sta[1];
707             p ("error: null pointer exception not thrown");
708         }       
709         catch (NullPointerException c) {
710             p ("exception: null pointer");
711         }
712
713         try {
714             p ("negative array size check: address array");
715             sta = new String[-3];
716             p ("error: negative array size exception not thrown");
717         }       
718         catch (NegativeArraySizeException c) {
719             p ("exception: negative array size");
720         }
721
722         sta = new String[5];
723
724         try {
725             p ("array bound check: address array store");
726             sta[-1] = null;
727             p ("error: exception not thrown");
728         }       
729         catch (ArrayIndexOutOfBoundsException c) {
730             p ("exception: out of bounds: "+(-1));
731         }
732         try {
733             p ("array bound check: address array load");
734             s = sta[-1];
735             p ("error: exception not thrown");
736         }       
737         catch (ArrayIndexOutOfBoundsException c) {
738             p ("exception: out of bounds: "+(-1));
739         }
740
741         for (i=0; i<5; i++) sta[i] = Integer.toString(i) + ". Zeile";
742         for (i=0; i<5; i++) p (sta[i]);
743                 
744         p ("-------- test multi dimensional arrays");
745
746         int [][][] iaaa = null;
747
748         try {
749             p ("negative array size check: multi dimensional array");
750             iaaa = new int[2][3][-4];
751             p ("error: negative array size exception not thrown");
752         }       
753         catch (NegativeArraySizeException c) {
754             p ("exception: negative array size");
755         }
756
757         try {
758             p("savedvar size copy check: multi dimensional array");
759             Integer io = new Integer(10);
760             iaaa = new int[10][io.intValue()][10];
761             for (i = 0; i < 10; i++) {
762                 for (int j = 0; j < 10; j++) {
763                     for (int k = 0; k < 10; k++) {
764                         iaaa[i][j][k] = 1;
765                     }
766                 }
767             }
768             p("successfully created");
769         } catch (Exception e) {
770             p("error: exception thrown: " + e);
771         }
772
773         iaaa = new int[2][3][4];
774         long [][][] laaa = new long[2][3][6];
775         float [][][] faaa = new float[2][3][4];
776         double [][][] daaa = new double[3][4][7];
777         for (i=0; i<2; i++) {
778             int i2; for (i2=0; i2<3; i2++) {
779                 int i3; for (i3=0; i3<4; i3++) {
780                     iaaa[i][i2][i3] = i*i*i + i2*i2 + i3;
781                     laaa[i][i2][i3] = i*i*i + i2*i2 + i3 + 7;
782                     faaa[i][i2][i3] = i*i*i + i2*i2 + i3 + 0.4F;
783                     daaa[i][i2][i3] = i*i*i + i2*i2 + i3 - 47.0001;
784                     p (iaaa[i][i2][i3]);
785                     p (laaa[i][i2][i3]);
786                     p (faaa[i][i2][i3]);
787                     p (daaa[i][i2][i3]);
788                 }
789             }
790         }
791     }
792
793
794     static public void testconst(int i, long l) {
795         p ("TESTCONST CALLED WITH ", i);
796         p ("                  AND ", l);
797                 
798         if (!(i == (0))) p("not IFEQ:   ", (0));
799         if (!(i != (0))) p("not IFNE:   ", (0));
800         if (!(i <  (0))) p("not IFLT:   ", (0));
801         if (!(i <= (0))) p("not IFLE:   ", (0));
802         if (!(i >  (0))) p("not IFGT:   ", (0));
803         if (!(i >= (0))) p("not IFGE:   ", (0));
804
805         if (!(l == (0))) p("not IF_LEQ: ", (0));
806         if (!(l != (0))) p("not IF_LNE: ", (0));
807         if (!(l <  (0))) p("not IF_LLT: ", (0));
808         if (!(l <= (0))) p("not IF_LLE: ", (0));
809         if (!(l >  (0))) p("not IF_LGT: ", (0));
810         if (!(l >= (0))) p("not IF_LGE: ", (0));
811
812         p("IADDCONST:  ", i  +  (-1));
813         p("ISUBCONST:  ", i  -  (-1));
814         p("IMULCONST:  ", i  *  (-1));
815         p("ISHLCONST:  ", i <<  (-1));
816         p("ISHRCONST:  ", i >>  (-1));
817         p("IUSHRCONST: ", i >>> (-1));
818         p("IANDCONST:  ", i  &  (-1));
819         p("IORCONST:   ", i  |  (-1));
820         p("IXORCONST:  ", i  ^  (-1));
821
822         if (!(i == (-1))) p("not IFEQ:   ", (-1));
823         if (!(i != (-1))) p("not IFNE:   ", (-1));
824         if (!(i <  (-1))) p("not IFLT:   ", (-1));
825         if (!(i <= (-1))) p("not IFLE:   ", (-1));
826         if (!(i >  (-1))) p("not IFGT:   ", (-1));
827         if (!(i >= (-1))) p("not IFGE:   ", (-1));
828
829         p("LADDCONST:  ", l  +  (-1));
830         p("LSUBCONST:  ", l  -  (-1));
831         p("LMULCONST:  ", l  *  (-1));
832         p("LSHLCONST:  ", l <<  (-1));
833         p("LSHRCONST:  ", l >>  (-1));
834         p("LUSHRCONST: ", l >>> (-1));
835         p("LANDCONST:  ", l  &  (-1));
836         p("LORCONST:   ", l  |  (-1));
837         p("LXORCONST:  ", l  ^  (-1));
838
839         if (!(l == (-1))) p("not IF_LEQ: ", (-1));
840         if (!(l != (-1))) p("not IF_LNE: ", (-1));
841         if (!(l <  (-1))) p("not IF_LLT: ", (-1));
842         if (!(l <= (-1))) p("not IF_LLE: ", (-1));
843         if (!(l >  (-1))) p("not IF_LGT: ", (-1));
844         if (!(l >= (-1))) p("not IF_LGE: ", (-1));
845
846         p("IADDCONST:  ", i  +  (1));
847         p("ISUBCONST:  ", i  -  (1));
848         p("IMULCONST:  ", i  *  (1));
849         p("ISHLCONST:  ", i <<  (1));
850         p("ISHRCONST:  ", i >>  (1));
851         p("IUSHRCONST: ", i >>> (1));
852         p("IANDCONST:  ", i  &  (1));
853         p("IORCONST:   ", i  |  (1));
854         p("IXORCONST:  ", i  ^  (1));
855
856         if (!(i == (1))) p("not IFEQ:   ", (1));
857         if (!(i != (1))) p("not IFNE:   ", (1));
858         if (!(i <  (1))) p("not IFLT:   ", (1));
859         if (!(i <= (1))) p("not IFLE:   ", (1));
860         if (!(i >  (1))) p("not IFGT:   ", (1));
861         if (!(i >= (1))) p("not IFGE:   ", (1));
862
863         p("LADDCONST:  ", l  +  (1));
864         p("LSUBCONST:  ", l  -  (1));
865         p("LMULCONST:  ", l  *  (1));
866         p("LSHLCONST:  ", l <<  (1));
867         p("LSHRCONST:  ", l >>  (1));
868         p("LUSHRCONST: ", l >>> (1));
869         p("LANDCONST:  ", l  &  (1));
870         p("LORCONST:   ", l  |  (1));
871         p("LXORCONST:  ", l  ^  (1));
872
873         if (!(l == (1))) p("not IF_LEQ: ", (1));
874         if (!(l != (1))) p("not IF_LNE: ", (1));
875         if (!(l <  (1))) p("not IF_LLT: ", (1));
876         if (!(l <= (1))) p("not IF_LLE: ", (1));
877         if (!(l >  (1))) p("not IF_LGT: ", (1));
878         if (!(l >= (1))) p("not IF_LGE: ", (1));
879
880         p("IADDCONST:  ", i  +  (255));
881         p("ISUBCONST:  ", i  -  (255));
882         p("IMULCONST:  ", i  *  (255));
883         p("ISHLCONST:  ", i <<  (255));
884         p("ISHRCONST:  ", i >>  (255));
885         p("IUSHRCONST: ", i >>> (255));
886         p("IANDCONST:  ", i  &  (255));
887         p("IORCONST:   ", i  |  (255));
888         p("IXORCONST:  ", i  ^  (255));
889
890         if (!(i == (255))) p("not IFEQ:   ", (255));
891         if (!(i != (255))) p("not IFNE:   ", (255));
892         if (!(i <  (255))) p("not IFLT:   ", (255));
893         if (!(i <= (255))) p("not IFLE:   ", (255));
894         if (!(i >  (255))) p("not IFGT:   ", (255));
895         if (!(i >= (255))) p("not IFGE:   ", (255));
896
897         p("LADDCONST:  ", l  +  (255));
898         p("LSUBCONST:  ", l  -  (255));
899         p("LMULCONST:  ", l  *  (255));
900         p("LSHLCONST:  ", l <<  (255));
901         p("LSHRCONST:  ", l >>  (255));
902         p("LUSHRCONST: ", l >>> (255));
903         p("LANDCONST:  ", l  &  (255));
904         p("LORCONST:   ", l  |  (255));
905         p("LXORCONST:  ", l  ^  (255));
906
907         if (!(l == (255))) p("not IF_LEQ: ", (255));
908         if (!(l != (255))) p("not IF_LNE: ", (255));
909         if (!(l <  (255))) p("not IF_LLT: ", (255));
910         if (!(l <= (255))) p("not IF_LLE: ", (255));
911         if (!(l >  (255))) p("not IF_LGT: ", (255));
912         if (!(l >= (255))) p("not IF_LGE: ", (255));
913
914         p("IADDCONST:  ", i  +  (256));
915         p("ISUBCONST:  ", i  -  (256));
916         p("IMULCONST:  ", i  *  (256));
917         p("ISHLCONST:  ", i <<  (256));
918         p("ISHRCONST:  ", i >>  (256));
919         p("IUSHRCONST: ", i >>> (256));
920         p("IANDCONST:  ", i  &  (256));
921         p("IORCONST:   ", i  |  (256));
922         p("IXORCONST:  ", i  ^  (256));
923
924         if (!(i == (256))) p("not IFEQ:   ", (256));
925         if (!(i != (256))) p("not IFNE:   ", (256));
926         if (!(i <  (256))) p("not IFLT:   ", (256));
927         if (!(i <= (256))) p("not IFLE:   ", (256));
928         if (!(i >  (256))) p("not IFGT:   ", (256));
929         if (!(i >= (256))) p("not IFGE:   ", (256));
930
931         p("LADDCONST:  ", l  +  (256));
932         p("LSUBCONST:  ", l  -  (256));
933         p("LMULCONST:  ", l  *  (256));
934         p("LSHLCONST:  ", l <<  (256));
935         p("LSHRCONST:  ", l >>  (256));
936         p("LUSHRCONST: ", l >>> (256));
937         p("LANDCONST:  ", l  &  (256));
938         p("LORCONST:   ", l  |  (256));
939         p("LXORCONST:  ", l  ^  (256));
940
941         if (!(l == (256))) p("not IF_LEQ: ", (256));
942         if (!(l != (256))) p("not IF_LNE: ", (256));
943         if (!(l <  (256))) p("not IF_LLT: ", (256));
944         if (!(l <= (256))) p("not IF_LLE: ", (256));
945         if (!(l >  (256))) p("not IF_LGT: ", (256));
946         if (!(l >= (256))) p("not IF_LGE: ", (256));
947
948         p("IADDCONST:  ", i  +  (32767));
949         p("ISUBCONST:  ", i  -  (32767));
950         p("IMULCONST:  ", i  *  (32767));
951         p("ISHLCONST:  ", i <<  (32767));
952         p("ISHRCONST:  ", i >>  (32767));
953         p("IUSHRCONST: ", i >>> (32767));
954         p("IANDCONST:  ", i  &  (32767));
955         p("IORCONST:   ", i  |  (32767));
956         p("IXORCONST:  ", i  ^  (32767));
957
958         if (!(i == (32767))) p("not IFEQ:   ", (32767));
959         if (!(i != (32767))) p("not IFNE:   ", (32767));
960         if (!(i <  (32767))) p("not IFLT:   ", (32767));
961         if (!(i <= (32767))) p("not IFLE:   ", (32767));
962         if (!(i >  (32767))) p("not IFGT:   ", (32767));
963         if (!(i >= (32767))) p("not IFGE:   ", (32767));
964
965         p("LADDCONST:  ", l  +  (32767));
966         p("LSUBCONST:  ", l  -  (32767));
967         p("LMULCONST:  ", l  *  (32767));
968         p("LSHLCONST:  ", l <<  (32767));
969         p("LSHRCONST:  ", l >>  (32767));
970         p("LUSHRCONST: ", l >>> (32767));
971         p("LANDCONST:  ", l  &  (32767));
972         p("LORCONST:   ", l  |  (32767));
973         p("LXORCONST:  ", l  ^  (32767));
974
975         if (!(l == (32767))) p("not IF_LEQ: ", (32767));
976         if (!(l != (32767))) p("not IF_LNE: ", (32767));
977         if (!(l <  (32767))) p("not IF_LLT: ", (32767));
978         if (!(l <= (32767))) p("not IF_LLE: ", (32767));
979         if (!(l >  (32767))) p("not IF_LGT: ", (32767));
980         if (!(l >= (32767))) p("not IF_LGE: ", (32767));
981
982         p("IADDCONST:  ", i  +  (32768));
983         p("ISUBCONST:  ", i  -  (32768));
984         p("IMULCONST:  ", i  *  (32768));
985         p("ISHLCONST:  ", i <<  (32768));
986         p("ISHRCONST:  ", i >>  (32768));
987         p("IUSHRCONST: ", i >>> (32768));
988         p("IANDCONST:  ", i  &  (32768));
989         p("IORCONST:   ", i  |  (32768));
990         p("IXORCONST:  ", i  ^  (32768));
991
992         if (!(i == (32768))) p("not IFEQ:   ", (32768));
993         if (!(i != (32768))) p("not IFNE:   ", (32768));
994         if (!(i <  (32768))) p("not IFLT:   ", (32768));
995         if (!(i <= (32768))) p("not IFLE:   ", (32768));
996         if (!(i >  (32768))) p("not IFGT:   ", (32768));
997         if (!(i >= (32768))) p("not IFGE:   ", (32768));
998
999         p("LADDCONST:  ", l  +  (32768));
1000         p("LSUBCONST:  ", l  -  (32768));
1001         p("LMULCONST:  ", l  *  (32768));
1002         p("LSHLCONST:  ", l <<  (32768));
1003         p("LSHRCONST:  ", l >>  (32768));
1004         p("LUSHRCONST: ", l >>> (32768));
1005         p("LANDCONST:  ", l  &  (32768));
1006         p("LORCONST:   ", l  |  (32768));
1007         p("LXORCONST:  ", l  ^  (32768));
1008
1009         if (!(l == (32768))) p("not IF_LEQ: ", (32768));
1010         if (!(l != (32768))) p("not IF_LNE: ", (32768));
1011         if (!(l <  (32768))) p("not IF_LLT: ", (32768));
1012         if (!(l <= (32768))) p("not IF_LLE: ", (32768));
1013         if (!(l >  (32768))) p("not IF_LGT: ", (32768));
1014         if (!(l >= (32768))) p("not IF_LGE: ", (32768));
1015
1016         p("IADDCONST:  ", i  +  (-32768));
1017         p("ISUBCONST:  ", i  -  (-32768));
1018         p("IMULCONST:  ", i  *  (-32768));
1019         p("ISHLCONST:  ", i <<  (-32768));
1020         p("ISHRCONST:  ", i >>  (-32768));
1021         p("IUSHRCONST: ", i >>> (-32768));
1022         p("IANDCONST:  ", i  &  (-32768));
1023         p("IORCONST:   ", i  |  (-32768));
1024         p("IXORCONST:  ", i  ^  (-32768));
1025
1026         if (!(i == (-32768))) p("not IFEQ:   ", (-32768));
1027         if (!(i != (-32768))) p("not IFNE:   ", (-32768));
1028         if (!(i <  (-32768))) p("not IFLT:   ", (-32768));
1029         if (!(i <= (-32768))) p("not IFLE:   ", (-32768));
1030         if (!(i >  (-32768))) p("not IFGT:   ", (-32768));
1031         if (!(i >= (-32768))) p("not IFGE:   ", (-32768));
1032
1033         p("LADDCONST:  ", l  +  (-32768));
1034         p("LSUBCONST:  ", l  -  (-32768));
1035         p("LMULCONST:  ", l  *  (-32768));
1036         p("LSHLCONST:  ", l <<  (-32768));
1037         p("LSHRCONST:  ", l >>  (-32768));
1038         p("LUSHRCONST: ", l >>> (-32768));
1039         p("LANDCONST:  ", l  &  (-32768));
1040         p("LORCONST:   ", l  |  (-32768));
1041         p("LXORCONST:  ", l  ^  (-32768));
1042
1043         if (!(l == (-32768))) p("not IF_LEQ: ", (-32768));
1044         if (!(l != (-32768))) p("not IF_LNE: ", (-32768));
1045         if (!(l <  (-32768))) p("not IF_LLT: ", (-32768));
1046         if (!(l <= (-32768))) p("not IF_LLE: ", (-32768));
1047         if (!(l >  (-32768))) p("not IF_LGT: ", (-32768));
1048         if (!(l >= (-32768))) p("not IF_LGE: ", (-32768));
1049
1050         p("IADDCONST:  ", i  +  (-32769));
1051         p("ISUBCONST:  ", i  -  (-32769));
1052         p("IMULCONST:  ", i  *  (-32769));
1053         p("ISHLCONST:  ", i <<  (-32769));
1054         p("ISHRCONST:  ", i >>  (-32769));
1055         p("IUSHRCONST: ", i >>> (-32769));
1056         p("IANDCONST:  ", i  &  (-32769));
1057         p("IORCONST:   ", i  |  (-32769));
1058         p("IXORCONST:  ", i  ^  (-32769));
1059
1060         if (!(i == (-32769))) p("not IFEQ:   ", (-32769));
1061         if (!(i != (-32769))) p("not IFNE:   ", (-32769));
1062         if (!(i <  (-32769))) p("not IFLT:   ", (-32769));
1063         if (!(i <= (-32769))) p("not IFLE:   ", (-32769));
1064         if (!(i >  (-32769))) p("not IFGT:   ", (-32769));
1065         if (!(i >= (-32769))) p("not IFGE:   ", (-32769));
1066
1067         p("LADDCONST:  ", l  +  (-32769));
1068         p("LSUBCONST:  ", l  -  (-32769));
1069         p("LMULCONST:  ", l  *  (-32769));
1070         p("LSHLCONST:  ", l <<  (-32769));
1071         p("LSHRCONST:  ", l >>  (-32769));
1072         p("LUSHRCONST: ", l >>> (-32769));
1073         p("LANDCONST:  ", l  &  (-32769));
1074         p("LORCONST:   ", l  |  (-32769));
1075         p("LXORCONST:  ", l  ^  (-32769));
1076
1077         if (!(l == (-32769))) p("not IF_LEQ: ", (-32769));
1078         if (!(l != (-32769))) p("not IF_LNE: ", (-32769));
1079         if (!(l <  (-32769))) p("not IF_LLT: ", (-32769));
1080         if (!(l <= (-32769))) p("not IF_LLE: ", (-32769));
1081         if (!(l >  (-32769))) p("not IF_LGT: ", (-32769));
1082         if (!(l >= (-32769))) p("not IF_LGE: ", (-32769));
1083
1084         p("IADDCONST:  ", i  +  (2147483647));
1085         p("ISUBCONST:  ", i  -  (2147483647));
1086         p("IMULCONST:  ", i  *  (2147483647));
1087         p("ISHLCONST:  ", i <<  (2147483647));
1088         p("ISHRCONST:  ", i >>  (2147483647));
1089         p("IUSHRCONST: ", i >>> (2147483647));
1090         p("IANDCONST:  ", i  &  (2147483647));
1091         p("IORCONST:   ", i  |  (2147483647));
1092         p("IXORCONST:  ", i  ^  (2147483647));
1093
1094         if (!(i == (2147483647))) p("not IFEQ:   ", (2147483647));
1095         if (!(i != (2147483647))) p("not IFNE:   ", (2147483647));
1096         if (!(i <  (2147483647))) p("not IFLT:   ", (2147483647));
1097         if (!(i <= (2147483647))) p("not IFLE:   ", (2147483647));
1098         if (!(i >  (2147483647))) p("not IFGT:   ", (2147483647));
1099         if (!(i >= (2147483647))) p("not IFGE:   ", (2147483647));
1100
1101         p("LADDCONST:  ", l  +  (2147483647));
1102         p("LSUBCONST:  ", l  -  (2147483647));
1103         p("LMULCONST:  ", l  *  (2147483647));
1104         p("LSHLCONST:  ", l <<  (2147483647));
1105         p("LSHRCONST:  ", l >>  (2147483647));
1106         p("LUSHRCONST: ", l >>> (2147483647));
1107         p("LANDCONST:  ", l  &  (2147483647));
1108         p("LORCONST:   ", l  |  (2147483647));
1109         p("LXORCONST:  ", l  ^  (2147483647));
1110
1111         if (!(l == (2147483647))) p("not IF_LEQ: ", (2147483647));
1112         if (!(l != (2147483647))) p("not IF_LNE: ", (2147483647));
1113         if (!(l <  (2147483647))) p("not IF_LLT: ", (2147483647));
1114         if (!(l <= (2147483647))) p("not IF_LLE: ", (2147483647));
1115         if (!(l >  (2147483647))) p("not IF_LGT: ", (2147483647));
1116         if (!(l >= (2147483647))) p("not IF_LGE: ", (2147483647));
1117
1118         p("LADDCONST:  ", l  +  (2147483648L));
1119         p("LSUBCONST:  ", l  -  (2147483648L));
1120         p("LMULCONST:  ", l  *  (2147483648L));
1121         p("LSHLCONST:  ", l <<  (2147483648L));
1122         p("LSHRCONST:  ", l >>  (2147483648L));
1123         p("LUSHRCONST: ", l >>> (2147483648L));
1124         p("LANDCONST:  ", l  &  (2147483648L));
1125         p("LORCONST:   ", l  |  (2147483648L));
1126         p("LXORCONST:  ", l  ^  (2147483648L));
1127
1128         if (!(l == (2147483648L))) p("not IF_LEQ: ", (2147483648L));
1129         if (!(l != (2147483648L))) p("not IF_LNE: ", (2147483648L));
1130         if (!(l <  (2147483648L))) p("not IF_LLT: ", (2147483648L));
1131         if (!(l <= (2147483648L))) p("not IF_LLE: ", (2147483648L));
1132         if (!(l >  (2147483648L))) p("not IF_LGT: ", (2147483648L));
1133         if (!(l >= (2147483648L))) p("not IF_LGE: ", (2147483648L));
1134
1135         p("IADDCONST:  ", i  +  (-2147483648));
1136         p("ISUBCONST:  ", i  -  (-2147483648));
1137         p("IMULCONST:  ", i  *  (-2147483648));
1138         p("ISHLCONST:  ", i <<  (-2147483648));
1139         p("ISHRCONST:  ", i >>  (-2147483648));
1140         p("IUSHRCONST: ", i >>> (-2147483648));
1141         p("IANDCONST:  ", i  &  (-2147483648));
1142         p("IORCONST:   ", i  |  (-2147483648));
1143         p("IXORCONST:  ", i  ^  (-2147483648));
1144
1145         if (!(i == (-2147483648))) p("not IFEQ:   ", (-2147483648));
1146         if (!(i != (-2147483648))) p("not IFNE:   ", (-2147483648));
1147         if (!(i <  (-2147483648))) p("not IFLT:   ", (-2147483648));
1148         if (!(i <= (-2147483648))) p("not IFLE:   ", (-2147483648));
1149         if (!(i >  (-2147483648))) p("not IFGT:   ", (-2147483648));
1150         if (!(i >= (-2147483648))) p("not IFGE:   ", (-2147483648));
1151
1152         p("LADDCONST:  ", l  +  (-2147483648));
1153         p("LSUBCONST:  ", l  -  (-2147483648));
1154         p("LMULCONST:  ", l  *  (-2147483648));
1155         p("LSHLCONST:  ", l <<  (-2147483648));
1156         p("LSHRCONST:  ", l >>  (-2147483648));
1157         p("LUSHRCONST: ", l >>> (-2147483648));
1158         p("LANDCONST:  ", l  &  (-2147483648));
1159         p("LORCONST:   ", l  |  (-2147483648));
1160         p("LXORCONST:  ", l  ^  (-2147483648));
1161
1162         if (!(l == (-2147483648))) p("not IF_LEQ: ", (-2147483648));
1163         if (!(l != (-2147483648))) p("not IF_LNE: ", (-2147483648));
1164         if (!(l <  (-2147483648))) p("not IF_LLT: ", (-2147483648));
1165         if (!(l <= (-2147483648))) p("not IF_LLE: ", (-2147483648));
1166         if (!(l >  (-2147483648))) p("not IF_LGT: ", (-2147483648));
1167         if (!(l >= (-2147483648))) p("not IF_LGE: ", (-2147483648));
1168
1169         p("LADDCONST:  ", l  +  (-2147483649L));
1170         p("LSUBCONST:  ", l  -  (-2147483649L));
1171         p("LMULCONST:  ", l  *  (-2147483649L));
1172         p("LSHLCONST:  ", l <<  (-2147483649L));
1173         p("LSHRCONST:  ", l >>  (-2147483649L));
1174         p("LUSHRCONST: ", l >>> (-2147483649L));
1175         p("LANDCONST:  ", l  &  (-2147483649L));
1176         p("LORCONST:   ", l  |  (-2147483649L));
1177         p("LXORCONST:  ", l  ^  (-2147483649L));
1178
1179         if (!(l == (-2147483649L))) p("not IF_LEQ: ", (-2147483649L));
1180         if (!(l != (-2147483649L))) p("not IF_LNE: ", (-2147483649L));
1181         if (!(l <  (-2147483649L))) p("not IF_LLT: ", (-2147483649L));
1182         if (!(l <= (-2147483649L))) p("not IF_LLE: ", (-2147483649L));
1183         if (!(l >  (-2147483649L))) p("not IF_LGT: ", (-2147483649L));
1184         if (!(l >= (-2147483649L))) p("not IF_LGE: ", (-2147483649L));
1185     }
1186
1187     static public void testdivremconst(int a) {
1188         p("IDIVPOW2 (" + a + " / 0x00000001):  ", a / 0x00000001);
1189         p("IDIVPOW2 (" + a + " / 0x00000002):  ", a / 0x00000002);
1190         p("IDIVPOW2 (" + a + " / 0x00000004):  ", a / 0x00000004);
1191         p("IDIVPOW2 (" + a + " / 0x00000008):  ", a / 0x00000008);
1192         p("IDIVPOW2 (" + a + " / 0x00000010):  ", a / 0x00000010);
1193         p("IDIVPOW2 (" + a + " / 0x00000020):  ", a / 0x00000020);
1194         p("IDIVPOW2 (" + a + " / 0x00000040):  ", a / 0x00000040);
1195         p("IDIVPOW2 (" + a + " / 0x00000080):  ", a / 0x00000080);
1196         p("IDIVPOW2 (" + a + " / 0x00000100):  ", a / 0x00000100);
1197         p("IDIVPOW2 (" + a + " / 0x00000200):  ", a / 0x00000200);
1198         p("IDIVPOW2 (" + a + " / 0x00000400):  ", a / 0x00000400);
1199         p("IDIVPOW2 (" + a + " / 0x00000800):  ", a / 0x00000800);
1200         p("IDIVPOW2 (" + a + " / 0x00001000):  ", a / 0x00001000);
1201         p("IDIVPOW2 (" + a + " / 0x00002000):  ", a / 0x00002000);
1202         p("IDIVPOW2 (" + a + " / 0x00004000):  ", a / 0x00004000);
1203         p("IDIVPOW2 (" + a + " / 0x00008000):  ", a / 0x00008000);
1204         p("IDIVPOW2 (" + a + " / 0x00010000):  ", a / 0x00010000);
1205         p("IDIVPOW2 (" + a + " / 0x00020000):  ", a / 0x00020000);
1206         p("IDIVPOW2 (" + a + " / 0x00040000):  ", a / 0x00040000);
1207         p("IDIVPOW2 (" + a + " / 0x00080000):  ", a / 0x00080000);
1208         p("IDIVPOW2 (" + a + " / 0x00100000):  ", a / 0x00100000);
1209         p("IDIVPOW2 (" + a + " / 0x00200000):  ", a / 0x00200000);
1210         p("IDIVPOW2 (" + a + " / 0x00400000):  ", a / 0x00400000);
1211         p("IDIVPOW2 (" + a + " / 0x00800000):  ", a / 0x00800000);
1212         p("IDIVPOW2 (" + a + " / 0x01000000):  ", a / 0x01000000);
1213         p("IDIVPOW2 (" + a + " / 0x02000000):  ", a / 0x02000000);
1214         p("IDIVPOW2 (" + a + " / 0x04000000):  ", a / 0x04000000);
1215         p("IDIVPOW2 (" + a + " / 0x08000000):  ", a / 0x08000000);
1216         p("IDIVPOW2 (" + a + " / 0x10000000):  ", a / 0x10000000);
1217         p("IDIVPOW2 (" + a + " / 0x20000000):  ", a / 0x20000000);
1218         p("IDIVPOW2 (" + a + " / 0x40000000):  ", a / 0x40000000);
1219         p("IDIVPOW2 (" + a + " / 0x80000000):  ", a / 0x80000000);
1220
1221         p("IREMPOW2 (" + a + " % 0x00000001):  ", a % 0x00000001);
1222         p("IREMPOW2 (" + a + " % 0x00000002):  ", a % 0x00000002);
1223         p("IREMPOW2 (" + a + " % 0x00000004):  ", a % 0x00000004);
1224         p("IREMPOW2 (" + a + " % 0x00000008):  ", a % 0x00000008);
1225         p("IREMPOW2 (" + a + " % 0x00000010):  ", a % 0x00000010);
1226         p("IREMPOW2 (" + a + " % 0x00000020):  ", a % 0x00000020);
1227         p("IREMPOW2 (" + a + " % 0x00000040):  ", a % 0x00000040);
1228         p("IREMPOW2 (" + a + " % 0x00000080):  ", a % 0x00000080);
1229         p("IREMPOW2 (" + a + " % 0x00000100):  ", a % 0x00000100);
1230         p("IREMPOW2 (" + a + " % 0x00000200):  ", a % 0x00000200);
1231         p("IREMPOW2 (" + a + " % 0x00000400):  ", a % 0x00000400);
1232         p("IREMPOW2 (" + a + " % 0x00000800):  ", a % 0x00000800);
1233         p("IREMPOW2 (" + a + " % 0x00001000):  ", a % 0x00001000);
1234         p("IREMPOW2 (" + a + " % 0x00002000):  ", a % 0x00002000);
1235         p("IREMPOW2 (" + a + " % 0x00004000):  ", a % 0x00004000);
1236         p("IREMPOW2 (" + a + " % 0x00008000):  ", a % 0x00008000);
1237         p("IREMPOW2 (" + a + " % 0x00010000):  ", a % 0x00010000);
1238         p("IREMPOW2 (" + a + " % 0x00020000):  ", a % 0x00020000);
1239         p("IREMPOW2 (" + a + " % 0x00040000):  ", a % 0x00040000);
1240         p("IREMPOW2 (" + a + " % 0x00080000):  ", a % 0x00080000);
1241         p("IREMPOW2 (" + a + " % 0x00100000):  ", a % 0x00100000);
1242         p("IREMPOW2 (" + a + " % 0x00200000):  ", a % 0x00200000);
1243         p("IREMPOW2 (" + a + " % 0x00400000):  ", a % 0x00400000);
1244         p("IREMPOW2 (" + a + " % 0x00800000):  ", a % 0x00800000);
1245         p("IREMPOW2 (" + a + " % 0x01000000):  ", a % 0x01000000);
1246         p("IREMPOW2 (" + a + " % 0x02000000):  ", a % 0x02000000);
1247         p("IREMPOW2 (" + a + " % 0x04000000):  ", a % 0x04000000);
1248         p("IREMPOW2 (" + a + " % 0x08000000):  ", a % 0x08000000);
1249         p("IREMPOW2 (" + a + " % 0x10000000):  ", a % 0x10000000);
1250         p("IREMPOW2 (" + a + " % 0x20000000):  ", a % 0x20000000);
1251         p("IREMPOW2 (" + a + " % 0x40000000):  ", a % 0x40000000);
1252         p("IREMPOW2 (" + a + " % 0x80000000):  ", a % 0x80000000);
1253     }
1254
1255     static public void testdivremconst(long a) {
1256         p("LDIVPOW2 (" + a + " / 0x00000001):  ", a / 0x00000001);
1257         p("LDIVPOW2 (" + a + " / 0x00000002):  ", a / 0x00000002);
1258         p("LDIVPOW2 (" + a + " / 0x00000004):  ", a / 0x00000004);
1259         p("LDIVPOW2 (" + a + " / 0x00000008):  ", a / 0x00000008);
1260         p("LDIVPOW2 (" + a + " / 0x00000010):  ", a / 0x00000010);
1261         p("LDIVPOW2 (" + a + " / 0x00000020):  ", a / 0x00000020);
1262         p("LDIVPOW2 (" + a + " / 0x00000040):  ", a / 0x00000040);
1263         p("LDIVPOW2 (" + a + " / 0x00000080):  ", a / 0x00000080);
1264         p("LDIVPOW2 (" + a + " / 0x00000100):  ", a / 0x00000100);
1265         p("LDIVPOW2 (" + a + " / 0x00000200):  ", a / 0x00000200);
1266         p("LDIVPOW2 (" + a + " / 0x00000400):  ", a / 0x00000400);
1267         p("LDIVPOW2 (" + a + " / 0x00000800):  ", a / 0x00000800);
1268         p("LDIVPOW2 (" + a + " / 0x00001000):  ", a / 0x00001000);
1269         p("LDIVPOW2 (" + a + " / 0x00002000):  ", a / 0x00002000);
1270         p("LDIVPOW2 (" + a + " / 0x00004000):  ", a / 0x00004000);
1271         p("LDIVPOW2 (" + a + " / 0x00008000):  ", a / 0x00008000);
1272         p("LDIVPOW2 (" + a + " / 0x00010000):  ", a / 0x00010000);
1273         p("LDIVPOW2 (" + a + " / 0x00020000):  ", a / 0x00020000);
1274         p("LDIVPOW2 (" + a + " / 0x00040000):  ", a / 0x00040000);
1275         p("LDIVPOW2 (" + a + " / 0x00080000):  ", a / 0x00080000);
1276         p("LDIVPOW2 (" + a + " / 0x00100000):  ", a / 0x00100000);
1277         p("LDIVPOW2 (" + a + " / 0x00200000):  ", a / 0x00200000);
1278         p("LDIVPOW2 (" + a + " / 0x00400000):  ", a / 0x00400000);
1279         p("LDIVPOW2 (" + a + " / 0x00800000):  ", a / 0x00800000);
1280         p("LDIVPOW2 (" + a + " / 0x01000000):  ", a / 0x01000000);
1281         p("LDIVPOW2 (" + a + " / 0x02000000):  ", a / 0x02000000);
1282         p("LDIVPOW2 (" + a + " / 0x04000000):  ", a / 0x04000000);
1283         p("LDIVPOW2 (" + a + " / 0x08000000):  ", a / 0x08000000);
1284         p("LDIVPOW2 (" + a + " / 0x10000000):  ", a / 0x10000000);
1285         p("LDIVPOW2 (" + a + " / 0x20000000):  ", a / 0x20000000);
1286         p("LDIVPOW2 (" + a + " / 0x40000000):  ", a / 0x40000000);
1287         p("LDIVPOW2 (" + a + " / 0x80000000):  ", a / 0x80000000);
1288
1289         p("LREMPOW2 (" + a + " % 0x00000001):  ", a % 0x00000001L);
1290         p("LREMPOW2 (" + a + " % 0x00000002):  ", a % 0x00000002L);
1291         p("LREMPOW2 (" + a + " % 0x00000004):  ", a % 0x00000004L);
1292         p("LREMPOW2 (" + a + " % 0x00000008):  ", a % 0x00000008L);
1293         p("LREMPOW2 (" + a + " % 0x00000010):  ", a % 0x00000010L);
1294         p("LREMPOW2 (" + a + " % 0x00000020):  ", a % 0x00000020L);
1295         p("LREMPOW2 (" + a + " % 0x00000040):  ", a % 0x00000040L);
1296         p("LREMPOW2 (" + a + " % 0x00000080):  ", a % 0x00000080L);
1297         p("LREMPOW2 (" + a + " % 0x00000100):  ", a % 0x00000100L);
1298         p("LREMPOW2 (" + a + " % 0x00000200):  ", a % 0x00000200L);
1299         p("LREMPOW2 (" + a + " % 0x00000400):  ", a % 0x00000400L);
1300         p("LREMPOW2 (" + a + " % 0x00000800):  ", a % 0x00000800L);
1301         p("LREMPOW2 (" + a + " % 0x00001000):  ", a % 0x00001000L);
1302         p("LREMPOW2 (" + a + " % 0x00002000):  ", a % 0x00002000L);
1303         p("LREMPOW2 (" + a + " % 0x00004000):  ", a % 0x00004000L);
1304         p("LREMPOW2 (" + a + " % 0x00008000):  ", a % 0x00008000L);
1305         p("LREMPOW2 (" + a + " % 0x00010000):  ", a % 0x00010000L);
1306         p("LREMPOW2 (" + a + " % 0x00020000):  ", a % 0x00020000L);
1307         p("LREMPOW2 (" + a + " % 0x00040000):  ", a % 0x00040000L);
1308         p("LREMPOW2 (" + a + " % 0x00080000):  ", a % 0x00080000L);
1309         p("LREMPOW2 (" + a + " % 0x00100000):  ", a % 0x00100000L);
1310         p("LREMPOW2 (" + a + " % 0x00200000):  ", a % 0x00200000L);
1311         p("LREMPOW2 (" + a + " % 0x00400000):  ", a % 0x00400000L);
1312         p("LREMPOW2 (" + a + " % 0x00800000):  ", a % 0x00800000L);
1313         p("LREMPOW2 (" + a + " % 0x01000000):  ", a % 0x01000000L);
1314         p("LREMPOW2 (" + a + " % 0x02000000):  ", a % 0x02000000L);
1315         p("LREMPOW2 (" + a + " % 0x04000000):  ", a % 0x04000000L);
1316         p("LREMPOW2 (" + a + " % 0x08000000):  ", a % 0x08000000L);
1317         p("LREMPOW2 (" + a + " % 0x10000000):  ", a % 0x10000000L);
1318         p("LREMPOW2 (" + a + " % 0x20000000):  ", a % 0x20000000L);
1319         p("LREMPOW2 (" + a + " % 0x40000000):  ", a % 0x40000000L);
1320         p("LREMPOW2 (" + a + " % 0x80000000):  ", a % 0x80000000L);
1321     }
1322
1323
1324     static public void testint(int a, int b) {
1325         p("TESTINT called with ", a);
1326         p("                AND ", b);
1327                 
1328         p("IADD:  ", a+b);
1329         p("ISUB:  ", a-b);
1330         p("IMUL:  ", a*b);
1331         try { p("IDIV:  ", a/b); } 
1332         catch (ArithmeticException e) { p("divison by zero"); }
1333         try { p("IREM:  ", a%b); } 
1334         catch (ArithmeticException e) { p("divison by zero"); }
1335         p("INEG:  ", -a);
1336         p("ISHL:  ", a<<b);
1337         p("ISHR:  ", a>>b);
1338         p("IUSHR: ", a>>>b);
1339         p("IAND:  ", a & b);
1340         p("IOR:   ", a | b);
1341         p("IXOR:  ", a ^ b);
1342
1343         p("I2L:   ", (long) a);
1344         p("I2F:   ", (float) a);
1345         p("I2D:   ", (double) a);
1346         p("INT2BYTE: ", (byte) a);      
1347         p("INT2CHAR: ", (char) a);      
1348         p("INT2SHORT: ", (short) a);    
1349
1350         if (!(a == 0)) p("not IFEQ");
1351         if (!(a != 0)) p("not IFNE");
1352         if (!(a < 0))  p("not IFLT");
1353         if (!(a <= 0)) p("not IFLE");
1354         if (!(a > 0))  p("not IFGT");
1355         if (!(a >= 0)) p("not IFGE");
1356
1357         if (!(a == b)) p("not IF_ICMPEQ");
1358         if (!(a != b)) p("not IF_ICMPNE");
1359         if (!(a < b))  p("not IF_ICMPLT");
1360         if (!(a <= b)) p("not IF_ICMPLE");
1361         if (!(a > b))  p("not IF_ICMPGT");
1362         if (!(a >= b)) p("not IF_ICMPGE");
1363                 
1364         p("COND_ICMPEQ " + a + " == 0: " + ((a == 0) ? 0 : 1));
1365         p("COND_ICMPNE " + a + " != 0: " + ((a != 0) ? 0 : 1));
1366         p("COND_ICMPLT " + a + " <  0: " + ((a <  0) ? 0 : 1));
1367         p("COND_ICMPLE " + a + " <= 0: " + ((a <= 0) ? 0 : 1));
1368         p("COND_ICMPGT " + a + " >  0: " + ((a >  0) ? 0 : 1));
1369         p("COND_ICMPGE " + a + " >= 0: " + ((a >= 0) ? 0 : 1));
1370                 
1371         p("COND_ICMPEQ " + a + " == 0: " + ((a == 0) ? 1 : 0));
1372         p("COND_ICMPNE " + a + " != 0: " + ((a != 0) ? 1 : 0));
1373         p("COND_ICMPLT " + a + " <  0: " + ((a <  0) ? 1 : 0));
1374         p("COND_ICMPLE " + a + " <= 0: " + ((a <= 0) ? 1 : 0));
1375         p("COND_ICMPGT " + a + " >  0: " + ((a >  0) ? 1 : 0));
1376         p("COND_ICMPGE " + a + " >= 0: " + ((a >= 0) ? 1 : 0));
1377                 
1378         p("COND_ICMPEQ " + a + " == 0: " + ((a == 0) ? 2 : 3));
1379         p("COND_ICMPNE " + a + " != 0: " + ((a != 0) ? 2 : 3));
1380         p("COND_ICMPLT " + a + " <  0: " + ((a <  0) ? 2 : 3));
1381         p("COND_ICMPLE " + a + " <= 0: " + ((a <= 0) ? 2 : 3));
1382         p("COND_ICMPGT " + a + " >  0: " + ((a >  0) ? 2 : 3));
1383         p("COND_ICMPGE " + a + " >= 0: " + ((a >= 0) ? 2 : 3));
1384                 
1385         p("COND_ICMPEQ " + a + " == " + b + ": " + (a == b));
1386         p("COND_ICMPNE " + a + " != " + b + ": " + (a != b));
1387         p("COND_ICMPLT " + a + " <  " + b + ": " + (a <  b));
1388         p("COND_ICMPLE " + a + " <= " + b + ": " + (a <= b));
1389         p("COND_ICMPGT " + a + " >  " + b + ": " + (a >  b));
1390         p("COND_ICMPGE " + a + " >= " + b + ": " + (a >= b));
1391                 
1392     }
1393
1394     static public void testlong(long a, long b) {
1395         p("TESTLONG called with ", a);
1396         p("                 AND ", b);
1397                 
1398         p("LADD:  ", a + b);
1399         p("LSUB:  ", a - b);
1400         p("LMUL:  ", a * b);
1401         try { p("LDIV:  ", a / b); } 
1402         catch (ArithmeticException e) { p("divison by zero"); }
1403         try { p("LREM:  ", a % b); } 
1404         catch (ArithmeticException e) { p("divison by zero"); }
1405         p("LNEG:  ", -a);
1406         p("LSHL:  ", a << b);
1407         p("LSHR:  ", a >> b);
1408         p("LUSHR: ", a >>>b);
1409         p("LAND:  ", a &  b);
1410         p("LOR:   ", a |  b);
1411         p("LXOR:  ", a ^  b);
1412
1413         p("L2I:   ", (int) a);
1414         p("L2F:   ", (float) a);
1415         p("L2D:   ", (double) a);
1416
1417         p("LCMP a == b : ", a == b);
1418         p("LCMP a != b : ", a != b);
1419         p("LCMP a <  b : ", a <  b);
1420         p("LCMP a <= b : ", a <= b);
1421         p("LCMP a >  b : ", a >  b);
1422         p("LCMP a >= b : ", a >= b);
1423
1424         if (!(a == 0)) p("not IF_LEQ");
1425         if (!(a != 0)) p("not IF_LNE");
1426         if (!(a < 0))  p("not IF_LLT");
1427         if (!(a <= 0)) p("not IF_LLE");
1428         if (!(a > 0))  p("not IF_LGT");
1429         if (!(a >= 0)) p("not IF_LGE");
1430
1431         if (!(a == b)) p("not IF_LCMPEQ");
1432         if (!(a != b)) p("not IF_LCMPNE");
1433         if (!(a < b))  p("not IF_LCMPLT");
1434         if (!(a <= b)) p("not IF_LCMPLE");
1435         if (!(a > b))  p("not IF_LCMPGT");
1436         if (!(a >= b)) p("not IF_LCMPGE");
1437     }
1438
1439     static public void testfloat(float a, float b) {
1440         p("TESTFLOAT called with ", a);
1441         p("                  AND ", b);
1442                 
1443         p("FADD:  ", a + b);
1444         p("FSUB:  ", a - b);
1445         p("FMUL:  ", a * b);
1446         p("FDIV:  ", a / b); 
1447         p("FREM:  ", a % b);
1448                 
1449         p("F2I:   ", (int) a);
1450         p("F2L:   ", (long) a);
1451         p("F2D:   ", (double) a);
1452
1453         if ((a == b)) p("FCMP a == b");
1454         if ((a != b)) p("FCMP a != b");
1455         if ((a < b))  p("FCMP a < b");
1456         if ((a <= b)) p("FCMP a <= b");
1457         if ((a > b))  p("FCMP a > b");
1458         if ((a >= b)) p("FCMP a >= b");
1459     }
1460
1461     static public void testdouble(double a, double b) {
1462         p("TESTDOUBLE called with ", a);
1463         p("                   AND ", b);
1464                 
1465         p("DADD:  ", a + b);
1466         p("DSUB:  ", a - b);
1467         p("DMUL:  ", a * b);
1468         p("DDIV:  ", a / b); 
1469         p("DREM:  ", a % b);
1470                 
1471         p("D2I:   ", (int) a);
1472         p("D2L:   ", (long) a);
1473         p("D2F:   ", (float) a);
1474
1475         if ((a == b)) p("DCMP a == b");
1476         if ((a != b)) p("DCMP a != b");
1477         if ((a < b))  p("DCMP a < b");
1478         if ((a <= b)) p("DCMP a <= b");
1479         if ((a > b))  p("DCMP a > b");
1480         if ((a >= b)) p("DCMP a >= b");
1481     }
1482
1483
1484     // ********************* output methods ****************************
1485         
1486     public static void pnl() {
1487         System.out.println ();
1488         System.out.print (linenum);
1489         System.out.print (".    ");
1490         linenum++;
1491     }
1492
1493     public static void p(String a) { System.out.print(a); pnl(); }
1494
1495     public static void p(boolean a) {
1496         System.out.print(a);
1497         pnl();
1498     }
1499
1500     public static void p(byte a) {
1501         System.out.print("byte: ");
1502         System.out.print(a);
1503         System.out.print(" (0x");
1504         System.out.print(Integer.toHexString(a));
1505         System.out.print(")");
1506         pnl();
1507     }
1508
1509     public static void p(char a) {
1510         System.out.print("char: ");
1511         System.out.print((int) a);
1512         System.out.print(" (0x");
1513         System.out.print(Integer.toHexString((int) a));
1514         System.out.print(")");
1515         pnl();
1516     }
1517
1518     public static void p(short a) {
1519         System.out.print("short: ");
1520         System.out.print(a);
1521         System.out.print(" (0x");
1522         System.out.print(Integer.toHexString(a));
1523         System.out.print(")");
1524         pnl();
1525     }
1526
1527     public static void p(int a) {
1528         System.out.print ("int: ");
1529         System.out.print(a);
1530         System.out.print(" (0x");
1531         System.out.print(Integer.toHexString(a));
1532         System.out.print(")");
1533         pnl();
1534     }
1535
1536     public static void p(long a) {
1537         System.out.print ("long: ");
1538         System.out.print(a);
1539         System.out.print(" (0x");
1540         System.out.print(Long.toHexString(a));
1541         System.out.print(")");
1542         pnl();
1543     }
1544
1545     public static void p(float a) {
1546         int i = Float.floatToIntBits(a);
1547         System.out.print("float: ");
1548         System.out.print(i);
1549         System.out.print(" (0x");
1550         System.out.print(Integer.toHexString(i));
1551         System.out.print(")");
1552         pnl();
1553     }
1554
1555     public static void p(double a) {
1556         long l = Double.doubleToLongBits(a);
1557         System.out.print("double: ");
1558         System.out.print(l);
1559         System.out.print(" (0x");
1560         System.out.print(Long.toHexString(l));
1561         System.out.print(")");
1562         pnl();
1563     }
1564
1565     public static void p(String s,boolean i) { 
1566         System.out.print(s); p(i);
1567     }
1568     public static void p(String s,int i) { 
1569         System.out.print(s); p(i);
1570     }
1571     public static void p(String s,byte i) { 
1572         System.out.print(s); p(i);
1573     }
1574     public static void p(String s,char i) { 
1575         System.out.print(s); p(i);
1576     }
1577     public static void p(String s,short i) { 
1578         System.out.print(s); p(i);
1579     }
1580     public static void p(String s,long l) { 
1581         System.out.print(s); p(l);
1582     }
1583     public static void p(String s,float f) { 
1584         System.out.print(s); p(f);
1585     }
1586     public static void p(String s,double d) {
1587         System.out.print(s); p(d);
1588     }
1589
1590     // methods for testing interface and method calls
1591
1592     public void jctest() {
1593         p("<init> called");
1594     }
1595
1596     public void p_manyparam(int p_i1,int p_i2,
1597                             int p_i3, int p_i4, 
1598                             long p_l1,long p_l2,
1599                             long p_l3,long p_l4, 
1600                             float p_f1, float p_f2, 
1601                             float p_f3, float p_f4,
1602                             double p_d1, double p_d2,
1603                             double p_d3, double p_d4) {
1604         n_i1 = p_i1;
1605         n_i2 = p_i2;
1606         n_i3 = p_i3;
1607         n_i4 = p_i4;
1608         n_l1 = p_l1;
1609         n_l2 = p_l2;
1610         n_l3 = p_l3;
1611         n_l4 = p_l4;
1612         n_f1 = p_f1;
1613         n_f2 = p_f2;
1614         n_f3 = p_f3;
1615         n_f4 = p_f4;
1616         n_d1 = p_d1;
1617         n_d2 = p_d2;
1618         n_d3 = p_d3;
1619         n_d4 = p_d4;
1620     }
1621                 
1622     public void p_nonstatic (String a) { 
1623         p(a); 
1624         p(n_i1);
1625         p(n_i2);
1626         p(n_i3);
1627         p(n_i4);
1628         p(n_l1);
1629         p(n_l2);
1630         p(n_l3);
1631         p(n_l4);
1632         p(n_f1);
1633         p(n_f2);
1634         p(n_f3);
1635         p(n_f4);
1636         p(n_d1);
1637         p(n_d2);
1638         p(n_d3);
1639         p(n_d4);
1640                 
1641     }
1642 }
1643
1644 interface jcinterface { 
1645     public void p_nonstatic (String a);
1646 }