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