FEFunction.java
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18: package xeij;
19:
20: import java.lang.*;
21:
22: public class FEFunction {
23:
24: public static final boolean FPK_DEBUG_TRACE = false;
25:
26: public static final int FPK_CLOCK = 80;
27:
28: public static final boolean FPK_FPCP_NAN = true;
29:
30: public static boolean fpkOn;
31:
32:
33:
34:
35:
36: public static boolean fpkRejectFloatOn;
37:
38: public static void fpkInit () {
39: fpkOn = Settings.sgsGetOnOff ("fefunc");
40: fpkRejectFloatOn = Settings.sgsGetOnOff ("rejectfloat");
41: }
42:
43:
44:
45: public static final int[] fpkRndTable = new int[55];
46: public static int fpkRndPointer = -1;
47:
48:
49:
50: public static void fpkRndInit (int t) {
51: for (int i = 0; i < 55; i++) {
52: t = (char) t * 15625 + 1;
53: fpkRndTable[i] = t << 16 | (char) t;
54: }
55: fpkRndPointer = 54;
56: fpkRndShuffle ();
57: fpkRndShuffle ();
58: fpkRndShuffle ();
59: }
60:
61:
62:
63: public static void fpkRndShuffle () {
64: for (int i = 0; i < 24; i++) {
65: fpkRndTable[i] -= fpkRndTable[i + 31];
66: }
67: for (int i = 24; i < 55; i++) {
68: fpkRndTable[i] -= fpkRndTable[i - 24];
69: }
70: }
71:
72:
73:
74: public static int fpkRndLong () {
75: int i = fpkRndPointer;
76: if (i < 0) {
77: fpkRndInit (111);
78: i = fpkRndPointer;
79: }
80: if (i == 54) {
81: fpkRndShuffle ();
82: i = 0;
83: } else {
84: i++;
85: }
86: fpkRndPointer = i;
87: return fpkRndTable[i];
88: }
89:
90:
91:
92: public static final short[] fpkRandTable = new short[55];
93: public static int fpkRandPointer = -1;
94:
95:
96:
97: public static void fpkRandInit (int t) {
98: for (int i = 0; i < 55; i++) {
99: t = (char) t * 15625 + 1;
100: fpkRandTable[i] = (short) t;
101: }
102: fpkRandPointer = 54;
103: fpkRandShuffle ();
104: }
105:
106:
107:
108: public static void fpkRandShuffle () {
109: for (int i = 0; i < 24; i++) {
110: fpkRandTable[i] -= fpkRandTable[i + 31];
111: }
112: for (int i = 24; i < 55; i++) {
113: fpkRandTable[i] -= fpkRandTable[i - 24];
114: }
115: }
116:
117:
118:
119: public static short fpkRandShort () {
120: int i = fpkRandPointer;
121: if (i < 0) {
122: fpkRandInit (51);
123: i = fpkRandPointer;
124: }
125: if (i == 54) {
126: fpkRandShuffle ();
127: i = 0;
128: } else {
129: i++;
130: }
131: fpkRandPointer = i;
132: return fpkRandTable[i];
133: }
134:
135:
136:
137:
138:
139:
140:
141: public static final double[] FPK_TEN_P16QR = {
142:
143: 1.0e+0,
144: 1.0e+1,
145: 1.0e+2,
146: 1.0e+3,
147: 1.0e+4,
148: 1.0e+5,
149: 1.0e+6,
150: 1.0e+7,
151: 1.0e+8,
152: 1.0e+9,
153: 1.0e+10,
154: 1.0e+11,
155: 1.0e+12,
156: 1.0e+13,
157: 1.0e+14,
158: 1.0e+15,
159: 1.0e+0,
160: 1.0e+16,
161: 1.0e+32,
162: 1.0e+48,
163: 1.0e+64,
164: 1.0e+80,
165: 1.0e+96,
166: 1.0e+112,
167: 1.0e+128,
168: 1.0e+144,
169: 1.0e+160,
170: 1.0e+176,
171: 1.0e+192,
172: 1.0e+208,
173: 1.0e+224,
174: 1.0e+240,
175: 1.0e+0,
176: 1.0e+256,
177: };
178: public static final double[] FPK_TEN_M16QR = {
179:
180: 1.0e-0,
181: 1.0e-1,
182: 1.0e-2,
183: 1.0e-3,
184: 1.0e-4,
185: 1.0e-5,
186: 1.0e-6,
187: 1.0e-7,
188: 1.0e-8,
189: 1.0e-9,
190: 1.0e-10,
191: 1.0e-11,
192: 1.0e-12,
193: 1.0e-13,
194: 1.0e-14,
195: 1.0e-15,
196: 1.0e-0,
197: 1.0e-16,
198: 1.0e-32,
199: 1.0e-48,
200: 1.0e-64,
201: 1.0e-80,
202: 1.0e-96,
203: 1.0e-112,
204: 1.0e-128,
205: 1.0e-144,
206: 1.0e-160,
207: 1.0e-176,
208: 1.0e-192,
209: 1.0e-208,
210: 1.0e-224,
211: 1.0e-240,
212: 1.0e-0,
213: 1.0e-256,
214: };
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230: public static void fpkLMUL () {
231: long xl = (long) XEiJ.regRn[0];
232: long yl = (long) XEiJ.regRn[1];
233: long zl = xl * yl;
234: int zi = (int) zl;
235: if ((long) zi != zl) {
236: XEiJ.regRn[0] = zi;
237: XEiJ.regCCR = XEiJ.REG_CCR_V | XEiJ.REG_CCR_C;
238: } else {
239: XEiJ.regRn[0] = zi;
240: XEiJ.regCCR = 0;
241: }
242: }
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262: public static void fpkLDIV () {
263: long xl = (long) XEiJ.regRn[0];
264: long yl = (long) XEiJ.regRn[1];
265: if (yl == 0L) {
266:
267: XEiJ.regCCR = XEiJ.REG_CCR_Z | XEiJ.REG_CCR_C;
268: } else {
269: long zl = xl / yl;
270: int zi = (int) zl;
271: if ((long) zi != zl) {
272: XEiJ.regRn[0] = 0x7fffffff;
273: XEiJ.regCCR = XEiJ.REG_CCR_V | XEiJ.REG_CCR_C;
274: } else {
275: XEiJ.regRn[0] = zi;
276: XEiJ.regCCR = 0;
277: }
278: }
279: }
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298: public static void fpkLMOD () {
299: long xl = (long) XEiJ.regRn[0];
300: long yl = (long) XEiJ.regRn[1];
301: if (yl == 0L) {
302:
303: XEiJ.regCCR = XEiJ.REG_CCR_Z | XEiJ.REG_CCR_C;
304: } else {
305: long zl = xl % yl;
306: int zi = (int) zl;
307: XEiJ.regRn[0] = zi;
308: XEiJ.regCCR = 0;
309: }
310: }
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323: public static void fpkUMUL () {
324: long xl = 0xffffffffL & (long) XEiJ.regRn[0];
325: long yl = 0xffffffffL & (long) XEiJ.regRn[1];
326: long zl = xl * yl;
327: int zi = (int) zl;
328: if ((0xffffffffL & (long) zi) != zl) {
329: XEiJ.regRn[0] = zi;
330: XEiJ.regCCR = XEiJ.REG_CCR_V | XEiJ.REG_CCR_C;
331: } else {
332: XEiJ.regRn[0] = zi;
333: XEiJ.regCCR = 0;
334: }
335: }
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350: public static void fpkUDIV () {
351: long xl = 0xffffffffL & (long) XEiJ.regRn[0];
352: long yl = 0xffffffffL & (long) XEiJ.regRn[1];
353: if (yl == 0L) {
354:
355: XEiJ.regCCR = XEiJ.REG_CCR_Z | XEiJ.REG_CCR_C;
356: } else {
357: long zl = xl / yl;
358: int zi = (int) zl;
359: XEiJ.regRn[0] = zi;
360: XEiJ.regCCR = 0;
361: }
362: }
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377: public static void fpkUMOD () {
378: long xl = 0xffffffffL & (long) XEiJ.regRn[0];
379: long yl = 0xffffffffL & (long) XEiJ.regRn[1];
380: if (yl == 0L) {
381:
382: XEiJ.regCCR = XEiJ.REG_CCR_Z | XEiJ.REG_CCR_C;
383: } else {
384: long zl = xl % yl;
385: int zi = (int) zl;
386: XEiJ.regRn[0] = zi;
387: XEiJ.regCCR = 0;
388: }
389: }
390:
391:
392:
393:
394:
395:
396:
397: public static void fpkIMUL () {
398: long xl = 0xffffffffL & (long) XEiJ.regRn[0];
399: long yl = 0xffffffffL & (long) XEiJ.regRn[1];
400: long zl = xl * yl;
401: XEiJ.regRn[0] = (int) (zl >>> 32);
402: XEiJ.regRn[1] = (int) zl;
403: }
404:
405:
406:
407:
408:
409:
410:
411:
412:
413: public static void fpkIDIV () {
414: long xl = 0xffffffffL & (long) XEiJ.regRn[0];
415: long yl = 0xffffffffL & (long) XEiJ.regRn[1];
416: if (yl == 0L) {
417:
418: XEiJ.regCCR = XEiJ.REG_CCR_C;
419: } else {
420: long zl = xl / yl;
421: XEiJ.regRn[0] = (int) zl;
422: XEiJ.regRn[1] = (int) (xl - yl * zl);
423: XEiJ.regCCR = 0;
424: }
425: }
426:
427:
428:
429:
430:
431:
432: public static void fpkRANDOMIZE () {
433: fpkRndInit (XEiJ.regRn[0]);
434: XEiJ.regRn[0] = 0;
435: }
436:
437:
438:
439:
440:
441:
442: public static void fpkSRAND () {
443: fpkRandInit (XEiJ.regRn[0]);
444: XEiJ.regRn[0] = 0;
445: }
446:
447:
448:
449:
450:
451: public static void fpkRAND () {
452: XEiJ.regRn[0] = fpkRandShort () & 0x7fff;
453: }
454:
455:
456:
457:
458:
459:
460: public static void fpkLTOD () {
461:
462: long l = Double.doubleToLongBits ((double) XEiJ.regRn[0]);
463: XEiJ.regRn[0] = (int) (l >>> 32);
464: XEiJ.regRn[1] = (int) l;
465: }
466:
467:
468:
469:
470:
471:
472:
473: public static void fpkDTOL () {
474:
475: double d = Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
476: XEiJ.regRn[0] = (int) d;
477: XEiJ.regCCR = (double) Integer.MIN_VALUE - 1.0 < d && d < (double) Integer.MAX_VALUE + 1.0 ? 0 : XEiJ.REG_CCR_C;
478: }
479:
480:
481:
482:
483:
484:
485: public static void fpkLTOF () {
486:
487: XEiJ.regRn[0] = Float.floatToIntBits ((float) XEiJ.regRn[0]);
488: }
489:
490:
491:
492:
493:
494:
495:
496: public static void fpkFTOL () {
497:
498: float f = Float.intBitsToFloat (XEiJ.regRn[0]);
499: XEiJ.regRn[0] = (int) f;
500: XEiJ.regCCR = (float) Integer.MIN_VALUE - 1.0F < f && f < (float) Integer.MAX_VALUE + 1.0F ? 0 : XEiJ.REG_CCR_C;
501: }
502:
503:
504:
505:
506:
507:
508:
509:
510:
511:
512: public static void fpkFTOD () {
513:
514: long l = Double.doubleToLongBits ((double) Float.intBitsToFloat (XEiJ.regRn[0]));
515: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
516: l = 0x7fffffffffffffffL;
517: }
518: XEiJ.regRn[0] = (int) (l >>> 32);
519: XEiJ.regRn[1] = (int) l;
520: }
521:
522:
523:
524:
525:
526:
527:
528:
529:
530:
531:
532:
533: public static void fpkDTOF () {
534:
535: double d = Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
536: int h = Float.floatToIntBits ((float) d);
537: if (FPK_FPCP_NAN && h == 0x7fc00000) {
538: h = 0x7fffffff;
539: }
540: XEiJ.regRn[0] = h;
541: XEiJ.regCCR = (Double.isNaN (d) || Double.isInfinite (d) ||
542: Math.abs (d) < (double) Float.MAX_VALUE + 0.5 * (double) Math.ulp (Float.MAX_VALUE) ? 0 : XEiJ.REG_CCR_C);
543: }
544:
545:
546:
547:
548:
549:
550:
551:
552:
553:
554: public static void fpkDTST () {
555: if (true) {
556: long l = (long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1];
557: XEiJ.regCCR = l << 1 == 0L ? XEiJ.REG_CCR_Z : 0L <= l ? 0 : XEiJ.REG_CCR_N;
558: } else {
559:
560: double d = Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
561: XEiJ.regCCR = d < 0.0 ? XEiJ.REG_CCR_N : d == 0.0 ? XEiJ.REG_CCR_Z : 0;
562: }
563: }
564:
565:
566:
567:
568:
569:
570:
571:
572:
573:
574:
575:
576:
577: public static void fpkDCMP () {
578:
579: double xd = Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
580: double yd = Double.longBitsToDouble ((long) XEiJ.regRn[2] << 32 | 0xffffffffL & XEiJ.regRn[3]);
581: XEiJ.regCCR = xd < yd ? XEiJ.REG_CCR_N | XEiJ.REG_CCR_C : xd == yd ? XEiJ.REG_CCR_Z : 0;
582: }
583:
584:
585:
586:
587:
588:
589:
590:
591:
592:
593:
594:
595:
596: public static void fpkDNEG () {
597:
598: long l = Double.doubleToLongBits (-Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]));
599: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
600: l = 0x7fffffffffffffffL;
601: }
602: XEiJ.regRn[0] = (int) (l >>> 32);
603: XEiJ.regRn[1] = (int) l;
604: }
605:
606:
607:
608:
609:
610:
611:
612:
613:
614:
615:
616:
617:
618: public static void fpkDADD () {
619:
620: double xd = Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
621: double yd = Double.longBitsToDouble ((long) XEiJ.regRn[2] << 32 | 0xffffffffL & XEiJ.regRn[3]);
622: double zd = xd + yd;
623: long l = Double.doubleToLongBits (zd);
624: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
625: l = 0x7fffffffffffffffL;
626: }
627: XEiJ.regRn[0] = (int) (l >>> 32);
628: XEiJ.regRn[1] = (int) l;
629: XEiJ.regCCR = (Double.isNaN (xd) || Double.isNaN (yd) ? 0 :
630: Double.isNaN (zd) ? XEiJ.REG_CCR_C :
631: Double.isInfinite (xd) || Double.isInfinite (yd) ? 0 :
632: Double.isInfinite (zd) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C :
633: 0);
634: }
635:
636:
637:
638:
639:
640:
641:
642:
643:
644:
645: public static void fpkDSUB () {
646:
647: double xd = Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
648: double yd = Double.longBitsToDouble ((long) XEiJ.regRn[2] << 32 | 0xffffffffL & XEiJ.regRn[3]);
649: double zd = xd - yd;
650: long l = Double.doubleToLongBits (zd);
651: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
652: l = 0x7fffffffffffffffL;
653: }
654: XEiJ.regRn[0] = (int) (l >>> 32);
655: XEiJ.regRn[1] = (int) l;
656: XEiJ.regCCR = (Double.isNaN (xd) || Double.isNaN (yd) ? 0 :
657: Double.isNaN (zd) ? XEiJ.REG_CCR_C :
658: Double.isInfinite (xd) || Double.isInfinite (yd) ? 0 :
659: Double.isInfinite (zd) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C :
660: 0);
661: }
662:
663:
664:
665:
666:
667:
668:
669:
670:
671:
672:
673:
674: public static void fpkDMUL () {
675:
676: double xd = Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
677: double yd = Double.longBitsToDouble ((long) XEiJ.regRn[2] << 32 | 0xffffffffL & XEiJ.regRn[3]);
678: double zd = xd * yd;
679: long l = Double.doubleToLongBits (zd);
680: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
681: l = 0x7fffffffffffffffL;
682: }
683: XEiJ.regRn[0] = (int) (l >>> 32);
684: XEiJ.regRn[1] = (int) l;
685: XEiJ.regCCR = (Double.isNaN (xd) || Double.isNaN (yd) ? 0 :
686: Double.isNaN (zd) ? XEiJ.REG_CCR_C :
687: Double.isInfinite (xd) || Double.isInfinite (yd) ? 0 :
688: Double.isInfinite (zd) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C :
689: 0);
690: }
691:
692:
693:
694:
695:
696:
697:
698:
699: public static void fpkDDIV () {
700:
701: double xd = Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
702: double yd = Double.longBitsToDouble ((long) XEiJ.regRn[2] << 32 | 0xffffffffL & XEiJ.regRn[3]);
703: double zd = xd / yd;
704: long l = Double.doubleToLongBits (zd);
705: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
706: l = 0x7fffffffffffffffL;
707: }
708: XEiJ.regRn[0] = (int) (l >>> 32);
709: XEiJ.regRn[1] = (int) l;
710: XEiJ.regCCR = (Double.isNaN (xd) || Double.isNaN (yd) ? 0 :
711: Double.isNaN (zd) ? XEiJ.REG_CCR_C :
712: Double.isInfinite (xd) || Double.isInfinite (yd) ? 0 :
713: yd == 0.0 ? XEiJ.REG_CCR_Z | XEiJ.REG_CCR_C :
714: Double.isInfinite (zd) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C :
715: 0);
716: }
717:
718:
719:
720:
721:
722:
723:
724:
725:
726:
727: public static void fpkDMOD () {
728:
729: double xd = Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
730: double yd = Double.longBitsToDouble ((long) XEiJ.regRn[2] << 32 | 0xffffffffL & XEiJ.regRn[3]);
731: double zd = xd % yd;
732: long l = Double.doubleToLongBits (zd);
733: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
734: l = 0x7fffffffffffffffL;
735: }
736: XEiJ.regRn[0] = (int) (l >>> 32);
737: XEiJ.regRn[1] = (int) l;
738: XEiJ.regCCR = (Double.isNaN (xd) || Double.isNaN (yd) ? 0 :
739: yd == 0.0 ? XEiJ.REG_CCR_Z | XEiJ.REG_CCR_C :
740: Double.isNaN (zd) ? XEiJ.REG_CCR_C :
741: Double.isInfinite (xd) || Double.isInfinite (yd) ? 0 :
742: Double.isInfinite (zd) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C :
743: 0);
744: }
745:
746:
747:
748:
749:
750:
751: public static void fpkDABS () {
752:
753: long l = Double.doubleToLongBits (Math.abs (Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1])));
754: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
755: l = 0x7fffffffffffffffL;
756: }
757: XEiJ.regRn[0] = (int) (l >>> 32);
758: XEiJ.regRn[1] = (int) l;
759: }
760:
761:
762:
763:
764:
765:
766:
767:
768: public static void fpkDCEIL () {
769:
770: long l = Double.doubleToLongBits (Math.ceil (Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1])));
771: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
772: l = 0x7fffffffffffffffL;
773: }
774: XEiJ.regRn[0] = (int) (l >>> 32);
775: XEiJ.regRn[1] = (int) l;
776: }
777:
778:
779:
780:
781:
782:
783:
784:
785: public static void fpkDFIX () {
786:
787: double d = Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
788: long l = Double.doubleToLongBits (0.0 <= d ? Math.floor (d) : Math.ceil (d));
789: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
790: l = 0x7fffffffffffffffL;
791: }
792: XEiJ.regRn[0] = (int) (l >>> 32);
793: XEiJ.regRn[1] = (int) l;
794: }
795:
796:
797:
798:
799:
800:
801:
802:
803: public static void fpkDFLOOR () {
804:
805: long l = Double.doubleToLongBits (Math.floor (Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1])));
806: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
807: l = 0x7fffffffffffffffL;
808: }
809: XEiJ.regRn[0] = (int) (l >>> 32);
810: XEiJ.regRn[1] = (int) l;
811: }
812:
813:
814:
815:
816:
817:
818:
819:
820:
821:
822:
823:
824:
825: public static void fpkDFRAC () {
826:
827: long l = (long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1];
828: double d = Double.longBitsToDouble (l);
829: l = (Double.isNaN (d) ? Double.doubleToLongBits (Double.NaN) :
830: Double.isInfinite (d) ? l & 0x8000000000000000L :
831: Double.doubleToLongBits (0L <= l ? d - Math.floor (d) : -(-d - Math.floor (-d))));
832: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
833: l = 0x7fffffffffffffffL;
834: }
835: XEiJ.regRn[0] = (int) (l >>> 32);
836: XEiJ.regRn[1] = (int) l;
837: }
838:
839:
840:
841:
842:
843:
844:
845:
846:
847:
848: public static void fpkDSGN () {
849:
850: long l = Double.doubleToLongBits (Math.signum (Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1])));
851: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
852: l = 0x7fffffffffffffffL;
853: }
854: XEiJ.regRn[0] = (int) (l >>> 32);
855: XEiJ.regRn[1] = (int) l;
856: }
857:
858:
859:
860:
861:
862:
863:
864:
865:
866: public static void fpkSIN () {
867:
868: double xd = Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
869: double zd = Math.sin (xd);
870: long l = Double.doubleToLongBits (zd);
871: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
872: l = 0x7fffffffffffffffL;
873: }
874: XEiJ.regRn[0] = (int) (l >>> 32);
875: XEiJ.regRn[1] = (int) l;
876: XEiJ.regCCR = !Double.isNaN (xd) && Double.isNaN (zd) ? XEiJ.REG_CCR_C : 0;
877: }
878:
879:
880:
881:
882:
883:
884:
885:
886:
887: public static void fpkCOS () {
888:
889: double xd = Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
890: double zd = Math.cos (xd);
891: long l = Double.doubleToLongBits (zd);
892: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
893: l = 0x7fffffffffffffffL;
894: }
895: XEiJ.regRn[0] = (int) (l >>> 32);
896: XEiJ.regRn[1] = (int) l;
897: XEiJ.regCCR = !Double.isNaN (xd) && Double.isNaN (zd) ? XEiJ.REG_CCR_C : 0;
898: }
899:
900:
901:
902:
903:
904:
905:
906:
907:
908: public static void fpkTAN () {
909:
910: double xd = Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
911: double zd = Math.tan (xd);
912: long l = Double.doubleToLongBits (zd);
913: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
914: l = 0x7fffffffffffffffL;
915: }
916: XEiJ.regRn[0] = (int) (l >>> 32);
917: XEiJ.regRn[1] = (int) l;
918: XEiJ.regCCR = !Double.isNaN (xd) && Double.isNaN (zd) ? XEiJ.REG_CCR_C : 0;
919: }
920:
921:
922:
923:
924:
925:
926:
927:
928: public static void fpkATAN () {
929:
930: long l = Double.doubleToLongBits (Math.atan (Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1])));
931: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
932: l = 0x7fffffffffffffffL;
933: }
934: XEiJ.regRn[0] = (int) (l >>> 32);
935: XEiJ.regRn[1] = (int) l;
936: }
937:
938:
939:
940:
941:
942:
943:
944:
945:
946:
947: public static void fpkLOG () {
948:
949: double xd = Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
950: double zd = Math.log (xd);
951: long l = Double.doubleToLongBits (zd);
952: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
953: l = 0x7fffffffffffffffL;
954: }
955: XEiJ.regRn[0] = (int) (l >>> 32);
956: XEiJ.regRn[1] = (int) l;
957: XEiJ.regCCR = (Double.isNaN (xd) ? 0 :
958: Double.isNaN (zd) ? XEiJ.REG_CCR_C :
959: Double.isInfinite (xd) ? 0 :
960: Double.isInfinite (zd) ? XEiJ.REG_CCR_Z | XEiJ.REG_CCR_C :
961: 0);
962: }
963:
964:
965:
966:
967:
968:
969:
970: public static void fpkEXP () {
971:
972: int xh = XEiJ.regRn[0];
973: long l = Double.doubleToLongBits (Math.exp (Double.longBitsToDouble ((long) xh << 32 | 0xffffffffL & XEiJ.regRn[1])));
974: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
975: l = 0x7fffffffffffffffL;
976: }
977: int zh = (int) (l >>> 32);
978: XEiJ.regRn[0] = zh;
979: XEiJ.regRn[1] = (int) l;
980: XEiJ.regCCR = (zh & 0x7ff00000) == 0x7ff00000 && (xh & 0x7ff00000) != 0x7ff00000 ? XEiJ.REG_CCR_C : 0;
981: }
982:
983:
984:
985:
986:
987:
988:
989:
990:
991:
992:
993:
994: public static void fpkSQR () {
995:
996: double xd = Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
997: long l = Double.doubleToLongBits (Math.sqrt (xd));
998: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
999: l = 0x7fffffffffffffffL;
1000: }
1001: XEiJ.regRn[0] = (int) (l >>> 32);
1002: XEiJ.regRn[1] = (int) l;
1003: XEiJ.regCCR = xd < 0.0 ? XEiJ.REG_CCR_C : 0;
1004: }
1005:
1006:
1007:
1008:
1009:
1010: public static void fpkPI () {
1011: if (true) {
1012: XEiJ.regRn[0] = 0x400921fb;
1013: XEiJ.regRn[1] = 0x54442d18;
1014: } else {
1015:
1016: long l = Double.doubleToLongBits (Math.PI);
1017: XEiJ.regRn[0] = (int) (l >>> 32);
1018: XEiJ.regRn[1] = (int) l;
1019: }
1020: }
1021:
1022:
1023:
1024:
1025:
1026:
1027:
1028:
1029:
1030:
1031:
1032:
1033:
1034: public static void fpkNPI () {
1035:
1036: int xh = XEiJ.regRn[0];
1037:
1038:
1039: long l = Double.doubleToLongBits (new QFP (Double.longBitsToDouble ((long) xh << 32 | 0xffffffffL & XEiJ.regRn[1])).mul (QFP.QFP_PI).getd ());
1040: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
1041: l = 0x7fffffffffffffffL;
1042: }
1043: int zh = (int) (l >>> 32);
1044: XEiJ.regRn[0] = zh;
1045: XEiJ.regRn[1] = (int) l;
1046: XEiJ.regCCR = (zh & 0x7ff00000) == 0x7ff00000 && (xh & 0x7ff00000) != 0x7ff00000 ? XEiJ.REG_CCR_C : 0;
1047: }
1048:
1049:
1050:
1051:
1052:
1053:
1054:
1055:
1056:
1057:
1058:
1059:
1060: public static void fpkPOWER () {
1061:
1062: double xd = Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
1063: double yd = Double.longBitsToDouble ((long) XEiJ.regRn[2] << 32 | 0xffffffffL & XEiJ.regRn[3]);
1064: double zd = Math.pow (xd, yd);
1065: long l = Double.doubleToLongBits (zd);
1066: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
1067: l = 0x7fffffffffffffffL;
1068: }
1069: XEiJ.regRn[0] = (int) (l >>> 32);
1070: XEiJ.regRn[1] = (int) l;
1071: XEiJ.regCCR = (Double.isNaN (xd) || Double.isNaN (yd) ? 0 :
1072: Double.isNaN (zd) ? XEiJ.REG_CCR_C :
1073: Double.isInfinite (xd) || Double.isInfinite (yd) ? 0 :
1074: Double.isInfinite (zd) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C :
1075: 0);
1076: }
1077:
1078:
1079:
1080:
1081:
1082: public static void fpkRND () {
1083: long l = 0xffffffffL & fpkRndLong ();
1084: l |= (0x001fffffL & fpkRndLong ()) << 32;
1085:
1086:
1087:
1088: int o = Long.numberOfLeadingZeros (l) - 11;
1089: l = (long) (0x3fe - o) << 52 | 0x000fffffffffffffL & l << o;
1090: XEiJ.regRn[0] = (int) (l >>> 32);
1091: XEiJ.regRn[1] = (int) l;
1092: }
1093:
1094:
1095:
1096:
1097:
1098:
1099:
1100:
1101:
1102:
1103:
1104:
1105:
1106:
1107:
1108:
1109:
1110:
1111: public static void fpkSINH () {
1112:
1113: double xd = Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
1114: double zd = Math.sinh (xd);
1115: long l = Double.doubleToLongBits (zd);
1116: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
1117: l = 0x7fffffffffffffffL;
1118: }
1119: XEiJ.regRn[0] = (int) (l >>> 32);
1120: XEiJ.regRn[1] = (int) l;
1121: XEiJ.regCCR = (Double.isNaN (xd) ? 0 :
1122: Double.isNaN (zd) ? XEiJ.REG_CCR_C :
1123: Double.isInfinite (xd) ? 0 :
1124: Double.isInfinite (zd) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C :
1125: 0);
1126: }
1127:
1128:
1129:
1130:
1131:
1132:
1133:
1134:
1135:
1136: public static void fpkCOSH () {
1137:
1138: double xd = Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
1139: double zd = Math.cosh (xd);
1140: long l = Double.doubleToLongBits (zd);
1141: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
1142: l = 0x7fffffffffffffffL;
1143: }
1144: XEiJ.regRn[0] = (int) (l >>> 32);
1145: XEiJ.regRn[1] = (int) l;
1146: XEiJ.regCCR = (Double.isNaN (xd) ? 0 :
1147: Double.isNaN (zd) ? XEiJ.REG_CCR_C :
1148: Double.isInfinite (xd) ? 0 :
1149: Double.isInfinite (zd) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C :
1150: 0);
1151: }
1152:
1153:
1154:
1155:
1156:
1157:
1158: public static void fpkTANH () {
1159:
1160: long l = Double.doubleToLongBits (Math.tanh (Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1])));
1161: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
1162: l = 0x7fffffffffffffffL;
1163: }
1164: XEiJ.regRn[0] = (int) (l >>> 32);
1165: XEiJ.regRn[1] = (int) l;
1166: }
1167:
1168:
1169:
1170:
1171:
1172:
1173:
1174: public static void fpkATANH () {
1175:
1176: double d = Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
1177: if (true) {
1178: QFP.fpsr = 0;
1179: d = new QFP (d).atanh ().getd ();
1180: XEiJ.regCCR = (QFP.fpsr & (QFP.QFP_OE | QFP.QFP_DZ)) != 0 ? XEiJ.REG_CCR_C : 0;
1181: } else {
1182: double s = Math.signum (d);
1183: double a = Math.abs (d);
1184: if (a < 1.0) {
1185: d = s * (Math.log1p (a) - Math.log1p (-a)) * 0.5;
1186: XEiJ.regCCR = 0;
1187: } else if (a == 1.0) {
1188: d = s * Double.POSITIVE_INFINITY;
1189: XEiJ.regCCR = XEiJ.REG_CCR_C;
1190: } else {
1191: d = Double.NaN;
1192: XEiJ.regCCR = XEiJ.REG_CCR_C;
1193: }
1194: }
1195: long l = Double.doubleToLongBits (d);
1196: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
1197: l = 0x7fffffffffffffffL;
1198: }
1199: XEiJ.regRn[0] = (int) (l >>> 32);
1200: XEiJ.regRn[1] = (int) l;
1201: }
1202:
1203:
1204:
1205:
1206:
1207:
1208:
1209: public static void fpkASIN () {
1210:
1211: double d = Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
1212: if (d < -1.0 || 1.0 < d) {
1213: d = Double.NaN;
1214: XEiJ.regCCR = XEiJ.REG_CCR_C;
1215: } else {
1216: d = Math.asin (d);
1217: XEiJ.regCCR = 0;
1218: }
1219: long l = Double.doubleToLongBits (d);
1220: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
1221: l = 0x7fffffffffffffffL;
1222: }
1223: XEiJ.regRn[0] = (int) (l >>> 32);
1224: XEiJ.regRn[1] = (int) l;
1225: }
1226:
1227:
1228:
1229:
1230:
1231:
1232:
1233: public static void fpkACOS () {
1234:
1235: double d = Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
1236: if (d < -1.0 || 1.0 < d) {
1237: d = Double.NaN;
1238: XEiJ.regCCR = XEiJ.REG_CCR_C;
1239: } else {
1240: d = Math.acos (d);
1241: XEiJ.regCCR = 0;
1242: }
1243: long l = Double.doubleToLongBits (d);
1244: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
1245: l = 0x7fffffffffffffffL;
1246: }
1247: XEiJ.regRn[0] = (int) (l >>> 32);
1248: XEiJ.regRn[1] = (int) l;
1249: }
1250:
1251:
1252:
1253:
1254:
1255:
1256:
1257: public static void fpkLOG10 () {
1258:
1259: double xd = Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
1260: double zd = Math.log10 (xd);
1261: long l = Double.doubleToLongBits (zd);
1262: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
1263: l = 0x7fffffffffffffffL;
1264: }
1265: XEiJ.regRn[0] = (int) (l >>> 32);
1266: XEiJ.regRn[1] = (int) l;
1267: XEiJ.regCCR = (Double.isNaN (xd) ? 0 :
1268: Double.isNaN (zd) ? XEiJ.REG_CCR_C :
1269: Double.isInfinite (xd) ? 0 :
1270: Double.isInfinite (zd) ? XEiJ.REG_CCR_Z | XEiJ.REG_CCR_C :
1271: 0);
1272: }
1273:
1274:
1275:
1276:
1277:
1278:
1279:
1280: public static void fpkLOG2 () {
1281:
1282: double xd = Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
1283: double zd = Math.log (xd) / 0.69314718055994530941723212146;
1284: long l = Double.doubleToLongBits (zd);
1285: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
1286: l = 0x7fffffffffffffffL;
1287: }
1288: XEiJ.regRn[0] = (int) (l >>> 32);
1289: XEiJ.regRn[1] = (int) l;
1290: XEiJ.regCCR = (Double.isNaN (xd) ? 0 :
1291: Double.isNaN (zd) ? XEiJ.REG_CCR_C :
1292: Double.isInfinite (xd) ? 0 :
1293: Double.isInfinite (zd) ? XEiJ.REG_CCR_Z | XEiJ.REG_CCR_C :
1294: 0);
1295: }
1296:
1297:
1298:
1299:
1300:
1301:
1302:
1303: public static void fpkDFREXP () {
1304: int h = XEiJ.regRn[0];
1305: if (h << 1 == 0 && XEiJ.regRn[1] == 0) {
1306: XEiJ.regRn[0] = 0;
1307: XEiJ.regRn[2] = 0;
1308: } else {
1309: XEiJ.regRn[0] = (h & 0x800fffff) | 0x3ff00000;
1310: XEiJ.regRn[2] = (h >>> 20 & 0x7ff) - 0x3ff;
1311: }
1312: }
1313:
1314:
1315:
1316:
1317:
1318:
1319:
1320:
1321: public static void fpkDLDEXP () {
1322: int h = XEiJ.regRn[0];
1323: if (h << 1 == 0 && XEiJ.regRn[1] == 0) {
1324: XEiJ.regRn[0] = 0;
1325: XEiJ.regCCR = 0;
1326: } else {
1327: int t = (h >>> 20 & 0x7ff) + XEiJ.regRn[2];
1328: if ((t & ~0x7ff) != 0) {
1329: XEiJ.regCCR = XEiJ.REG_CCR_C;
1330: } else {
1331: XEiJ.regRn[0] = (h & 0x800fffff) | t << 20;
1332: XEiJ.regCCR = 0;
1333: }
1334: }
1335: }
1336:
1337:
1338:
1339:
1340:
1341:
1342: public static void fpkDADDONE () {
1343:
1344: double xd = Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
1345: double zd = xd + 1.0;
1346: long l = Double.doubleToLongBits (zd);
1347: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
1348: l = 0x7fffffffffffffffL;
1349: }
1350: XEiJ.regRn[0] = (int) (l >>> 32);
1351: XEiJ.regRn[1] = (int) l;
1352: XEiJ.regCCR = Double.isInfinite (zd) && !Double.isInfinite (xd) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C : 0;
1353: }
1354:
1355:
1356:
1357:
1358:
1359:
1360: public static void fpkDSUBONE () {
1361:
1362: double xd = Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
1363: double zd = xd - 1.0;
1364: long l = Double.doubleToLongBits (zd);
1365: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
1366: l = 0x7fffffffffffffffL;
1367: }
1368: XEiJ.regRn[0] = (int) (l >>> 32);
1369: XEiJ.regRn[1] = (int) l;
1370: XEiJ.regCCR = Double.isInfinite (zd) && !Double.isInfinite (xd) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C : 0;
1371: }
1372:
1373:
1374:
1375:
1376:
1377:
1378:
1379:
1380:
1381:
1382:
1383:
1384:
1385:
1386:
1387:
1388:
1389:
1390:
1391:
1392:
1393:
1394: public static void fpkDDIVTWO () {
1395:
1396: double xd = Double.longBitsToDouble ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
1397: double zd = xd * 0.5;
1398: long l = Double.doubleToLongBits (zd);
1399: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
1400: l = 0x7fffffffffffffffL;
1401: }
1402: XEiJ.regRn[0] = (int) (l >>> 32);
1403: XEiJ.regRn[1] = (int) l;
1404: XEiJ.regCCR = zd == 0.0 && xd != 0.0 ? XEiJ.REG_CCR_C : 0;
1405: }
1406:
1407:
1408:
1409:
1410:
1411:
1412: public static void fpkDIEECNV () {
1413: }
1414:
1415:
1416:
1417:
1418:
1419:
1420: public static void fpkIEEDCNV () {
1421: }
1422:
1423:
1424:
1425:
1426:
1427:
1428:
1429: public static void fpkFTST () {
1430: if (true) {
1431: int h = XEiJ.regRn[0];
1432: XEiJ.regCCR = h << 1 == 0 ? XEiJ.REG_CCR_Z : 0 <= h ? 0 : XEiJ.REG_CCR_N;
1433: } else {
1434:
1435: float f = Float.intBitsToFloat (XEiJ.regRn[0]);
1436: XEiJ.regCCR = f < 0.0F ? XEiJ.REG_CCR_N : f == 0.0F ? XEiJ.REG_CCR_Z : 0;
1437: }
1438: }
1439:
1440:
1441:
1442:
1443:
1444:
1445:
1446:
1447: public static void fpkFCMP () {
1448:
1449: float xf = Float.intBitsToFloat (XEiJ.regRn[0]);
1450: float yf = Float.intBitsToFloat (XEiJ.regRn[1]);
1451: XEiJ.regCCR = xf < yf ? XEiJ.REG_CCR_N | XEiJ.REG_CCR_C : xf == yf ? XEiJ.REG_CCR_Z : 0;
1452: }
1453:
1454:
1455:
1456:
1457:
1458:
1459: public static void fpkFNEG () {
1460:
1461: int h = Float.floatToIntBits (-Float.intBitsToFloat (XEiJ.regRn[0]));
1462: if (FPK_FPCP_NAN && h == 0x7fc00000) {
1463: h = 0x7fffffff;
1464: }
1465: XEiJ.regRn[0] = h;
1466: }
1467:
1468:
1469:
1470:
1471:
1472:
1473:
1474:
1475: public static void fpkFADD () {
1476:
1477: float xf = Float.intBitsToFloat (XEiJ.regRn[0]);
1478: float yf = Float.intBitsToFloat (XEiJ.regRn[1]);
1479: float zf = xf + yf;
1480: int h = Float.floatToIntBits (zf);
1481: if (FPK_FPCP_NAN && h == 0x7fc00000) {
1482: h = 0x7fffffff;
1483: }
1484: XEiJ.regRn[0] = h;
1485: XEiJ.regCCR = (Float.isNaN (xf) || Float.isNaN (yf) ? 0 :
1486: Float.isNaN (zf) ? XEiJ.REG_CCR_C :
1487: Float.isInfinite (xf) || Float.isInfinite (yf) ? 0 :
1488: Float.isInfinite (zf) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C :
1489: 0);
1490: }
1491:
1492:
1493:
1494:
1495:
1496:
1497:
1498:
1499: public static void fpkFSUB () {
1500:
1501: float xf = Float.intBitsToFloat (XEiJ.regRn[0]);
1502: float yf = Float.intBitsToFloat (XEiJ.regRn[1]);
1503: float zf = xf - yf;
1504: int h = Float.floatToIntBits (zf);
1505: if (FPK_FPCP_NAN && h == 0x7fc00000) {
1506: h = 0x7fffffff;
1507: }
1508: XEiJ.regRn[0] = h;
1509: XEiJ.regCCR = (Float.isNaN (xf) || Float.isNaN (yf) ? 0 :
1510: Float.isNaN (zf) ? XEiJ.REG_CCR_C :
1511: Float.isInfinite (xf) || Float.isInfinite (yf) ? 0 :
1512: Float.isInfinite (zf) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C :
1513: 0);
1514: }
1515:
1516:
1517:
1518:
1519:
1520:
1521:
1522:
1523: public static void fpkFMUL () {
1524:
1525: float xf = Float.intBitsToFloat (XEiJ.regRn[0]);
1526: float yf = Float.intBitsToFloat (XEiJ.regRn[1]);
1527: float zf = xf * yf;
1528: int h = Float.floatToIntBits (zf);
1529: if (FPK_FPCP_NAN && h == 0x7fc00000) {
1530: h = 0x7fffffff;
1531: }
1532: XEiJ.regRn[0] = h;
1533: XEiJ.regCCR = (Float.isNaN (xf) || Float.isNaN (yf) ? 0 :
1534: Float.isNaN (zf) ? XEiJ.REG_CCR_C :
1535: Float.isInfinite (xf) || Float.isInfinite (yf) ? 0 :
1536: Float.isInfinite (zf) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C :
1537: 0);
1538: }
1539:
1540:
1541:
1542:
1543:
1544:
1545:
1546:
1547: public static void fpkFDIV () {
1548:
1549: float xf = Float.intBitsToFloat (XEiJ.regRn[0]);
1550: float yf = Float.intBitsToFloat (XEiJ.regRn[1]);
1551: float zf = xf / yf;
1552: int h = Float.floatToIntBits (zf);
1553: if (FPK_FPCP_NAN && h == 0x7fc00000) {
1554: h = 0x7fffffff;
1555: }
1556: XEiJ.regRn[0] = h;
1557: XEiJ.regCCR = (Float.isNaN (xf) || Float.isNaN (yf) ? 0 :
1558: Float.isNaN (zf) ? XEiJ.REG_CCR_C :
1559: Float.isInfinite (xf) || Float.isInfinite (yf) ? 0 :
1560: yf == 0.0F ? XEiJ.REG_CCR_Z | XEiJ.REG_CCR_C :
1561: Float.isInfinite (zf) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C :
1562: 0);
1563: }
1564:
1565:
1566:
1567:
1568:
1569:
1570:
1571:
1572: public static void fpkFMOD () {
1573:
1574: float xf = Float.intBitsToFloat (XEiJ.regRn[0]);
1575: float yf = Float.intBitsToFloat (XEiJ.regRn[1]);
1576: float zf = xf % yf;
1577: int h = Float.floatToIntBits (zf);
1578: if (FPK_FPCP_NAN && h == 0x7fc00000) {
1579: h = 0x7fffffff;
1580: }
1581: XEiJ.regRn[0] = h;
1582: XEiJ.regCCR = (Float.isNaN (xf) || Float.isNaN (yf) ? 0 :
1583: yf == 0.0F ? XEiJ.REG_CCR_Z | XEiJ.REG_CCR_C :
1584: Float.isNaN (zf) ? XEiJ.REG_CCR_C :
1585: Float.isInfinite (xf) || Float.isInfinite (yf) ? 0 :
1586: Float.isInfinite (zf) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C :
1587: 0);
1588: }
1589:
1590:
1591:
1592:
1593:
1594:
1595: public static void fpkFABS () {
1596:
1597: int h = Float.floatToIntBits (Math.abs (Float.intBitsToFloat (XEiJ.regRn[0])));
1598: if (FPK_FPCP_NAN && h == 0x7fc00000) {
1599: h = 0x7fffffff;
1600: }
1601: XEiJ.regRn[0] = h;
1602: }
1603:
1604:
1605:
1606:
1607:
1608:
1609: public static void fpkFCEIL () {
1610:
1611: int h = Float.floatToIntBits ((float) Math.ceil ((double) Float.intBitsToFloat (XEiJ.regRn[0])));
1612: if (FPK_FPCP_NAN && h == 0x7fc00000) {
1613: h = 0x7fffffff;
1614: }
1615: XEiJ.regRn[0] = h;
1616: }
1617:
1618:
1619:
1620:
1621:
1622:
1623: public static void fpkFFIX () {
1624:
1625: float f = Float.intBitsToFloat (XEiJ.regRn[0]);
1626: int h = Float.floatToIntBits (0.0 <= f ? (float) Math.floor ((double) f) : (float) Math.ceil ((double) f));
1627: if (FPK_FPCP_NAN && h == 0x7fc00000) {
1628: h = 0x7fffffff;
1629: }
1630: XEiJ.regRn[0] = h;
1631: }
1632:
1633:
1634:
1635:
1636:
1637:
1638: public static void fpkFFLOOR () {
1639:
1640: int h = Float.floatToIntBits ((float) Math.floor ((double) Float.intBitsToFloat (XEiJ.regRn[0])));
1641: if (FPK_FPCP_NAN && h == 0x7fc00000) {
1642: h = 0x7fffffff;
1643: }
1644: XEiJ.regRn[0] = h;
1645: }
1646:
1647:
1648:
1649:
1650:
1651:
1652: public static void fpkFFRAC () {
1653:
1654: int h = XEiJ.regRn[0];
1655: float f = Float.intBitsToFloat (h);
1656: h = (Float.isNaN (f) ? Float.floatToIntBits (Float.NaN) :
1657: Float.isInfinite (f) ? h & 0x80000000 :
1658: Float.floatToIntBits (0 <= h ? f - (float) Math.floor ((double) f) : -(-f - (float) Math.floor ((double) -f))));
1659: if (FPK_FPCP_NAN && h == 0x7fc00000) {
1660: h = 0x7fffffff;
1661: }
1662: XEiJ.regRn[0] = h;
1663: }
1664:
1665:
1666:
1667:
1668:
1669:
1670: public static void fpkFSGN () {
1671:
1672: int h = Float.floatToIntBits (Math.signum (Float.intBitsToFloat (XEiJ.regRn[0])));
1673: if (FPK_FPCP_NAN && h == 0x7fc00000) {
1674: h = 0x7fffffff;
1675: }
1676: XEiJ.regRn[0] = h;
1677: }
1678:
1679:
1680:
1681:
1682:
1683:
1684:
1685: public static void fpkFSIN () {
1686:
1687: float xf = Float.intBitsToFloat (XEiJ.regRn[0]);
1688: float zf = (float) Math.sin ((double) xf);
1689: int h = Float.floatToIntBits (zf);
1690: if (FPK_FPCP_NAN && h == 0x7fc00000) {
1691: h = 0x7fffffff;
1692: }
1693: XEiJ.regRn[0] = h;
1694: XEiJ.regCCR = !Float.isNaN (xf) && Float.isNaN (zf) ? XEiJ.REG_CCR_C : 0;
1695: }
1696:
1697:
1698:
1699:
1700:
1701:
1702:
1703: public static void fpkFCOS () {
1704:
1705: float xf = Float.intBitsToFloat (XEiJ.regRn[0]);
1706: float zf = (float) Math.cos ((double) xf);
1707: int h = Float.floatToIntBits (zf);
1708: if (FPK_FPCP_NAN && h == 0x7fc00000) {
1709: h = 0x7fffffff;
1710: }
1711: XEiJ.regRn[0] = h;
1712: XEiJ.regCCR = !Float.isNaN (xf) && Float.isNaN (zf) ? XEiJ.REG_CCR_C : 0;
1713: }
1714:
1715:
1716:
1717:
1718:
1719:
1720:
1721: public static void fpkFTAN () {
1722:
1723: float xf = Float.intBitsToFloat (XEiJ.regRn[0]);
1724: float zf = (float) Math.tan ((double) xf);
1725: int h = Float.floatToIntBits (zf);
1726: if (FPK_FPCP_NAN && h == 0x7fc00000) {
1727: h = 0x7fffffff;
1728: }
1729: XEiJ.regRn[0] = h;
1730: XEiJ.regCCR = !Float.isNaN (xf) && Float.isNaN (zf) ? XEiJ.REG_CCR_C : 0;
1731: }
1732:
1733:
1734:
1735:
1736:
1737:
1738: public static void fpkFATAN () {
1739:
1740: int h = Float.floatToIntBits ((float) Math.atan ((double) Float.intBitsToFloat (XEiJ.regRn[0])));
1741: if (FPK_FPCP_NAN && h == 0x7fc00000) {
1742: h = 0x7fffffff;
1743: }
1744: XEiJ.regRn[0] = h;
1745: }
1746:
1747:
1748:
1749:
1750:
1751:
1752:
1753: public static void fpkFLOG () {
1754:
1755: float xf = Float.intBitsToFloat (XEiJ.regRn[0]);
1756: float zf = (float) Math.log ((double) xf);
1757: int h = Float.floatToIntBits (zf);
1758: if (FPK_FPCP_NAN && h == 0x7fc00000) {
1759: h = 0x7fffffff;
1760: }
1761: XEiJ.regRn[0] = h;
1762: XEiJ.regCCR = (Float.isNaN (xf) ? 0 :
1763: Float.isNaN (zf) ? XEiJ.REG_CCR_C :
1764: Float.isInfinite (xf) ? 0 :
1765: Float.isNaN (zf) ? XEiJ.REG_CCR_Z | XEiJ.REG_CCR_C :
1766: 0);
1767: }
1768:
1769:
1770:
1771:
1772:
1773:
1774:
1775: public static void fpkFEXP () {
1776:
1777: int xh = XEiJ.regRn[0];
1778: int zh = Float.floatToIntBits ((float) Math.exp ((double) Float.intBitsToFloat (xh)));
1779: if (FPK_FPCP_NAN && zh == 0x7fc00000) {
1780: zh = 0x7fffffff;
1781: }
1782: XEiJ.regRn[0] = zh;
1783: XEiJ.regCCR = (zh & 0x7fc00000) == 0x7fc00000 && (xh & 0x7fc00000) != 0x7fc00000 ? XEiJ.REG_CCR_C : 0;
1784: }
1785:
1786:
1787:
1788:
1789:
1790:
1791:
1792: public static void fpkFSQR () {
1793:
1794: float xf = Float.intBitsToFloat (XEiJ.regRn[0]);
1795: int h = Float.floatToIntBits ((float) Math.sqrt ((double) xf));
1796: if (FPK_FPCP_NAN && h == 0x7fc00000) {
1797: h = 0x7fffffff;
1798: }
1799: XEiJ.regRn[0] = h;
1800: XEiJ.regCCR = xf < 0.0F ? XEiJ.REG_CCR_C : 0;
1801: }
1802:
1803:
1804:
1805:
1806:
1807: public static void fpkFPI () {
1808:
1809: if (true) {
1810: XEiJ.regRn[0] = 0x40490fdb;
1811: } else {
1812: XEiJ.regRn[0] = Float.floatToIntBits ((float) Math.PI);
1813: }
1814: }
1815:
1816:
1817:
1818:
1819:
1820:
1821:
1822: public static void fpkFNPI () {
1823:
1824: int xh = XEiJ.regRn[0];
1825:
1826: int zh = Float.floatToIntBits ((float) ((double) Float.intBitsToFloat (xh) * Math.PI));
1827: if (FPK_FPCP_NAN && zh == 0x7fc00000) {
1828: zh = 0x7fffffff;
1829: }
1830: XEiJ.regRn[0] = zh;
1831: XEiJ.regCCR = (zh & 0x7fc00000) == 0x7fc00000 && (xh & 0x7fc00000) != 0x7fc00000 ? XEiJ.REG_CCR_C : 0;
1832: }
1833:
1834:
1835:
1836:
1837:
1838:
1839:
1840:
1841: public static void fpkFPOWER () {
1842:
1843: float xf = Float.intBitsToFloat (XEiJ.regRn[0]);
1844: float yf = Float.intBitsToFloat (XEiJ.regRn[1]);
1845: float zf = (float) Math.pow ((double) xf, (double) yf);
1846: int zh = Float.floatToIntBits (zf);
1847: if (FPK_FPCP_NAN && zh == 0x7fc00000) {
1848: zh = 0x7fffffff;
1849: }
1850: XEiJ.regRn[0] = zh;
1851: XEiJ.regCCR = (Float.isNaN (xf) || Float.isNaN (yf) ? 0 :
1852: Float.isNaN (zf) ? XEiJ.REG_CCR_C :
1853: Float.isInfinite (xf) || Float.isInfinite (yf) ? 0 :
1854: Float.isNaN (zf) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C :
1855: 0);
1856: }
1857:
1858:
1859:
1860:
1861:
1862: public static void fpkFRND () {
1863:
1864: long l = 0xffffffffL & fpkRndLong ();
1865: l |= (0x001fffffL & fpkRndLong ()) << 32;
1866:
1867:
1868:
1869: int o = Long.numberOfLeadingZeros (l) - 11;
1870: l = ((long) (1022 - 1 - o) << 52) + (l << o);
1871: XEiJ.regRn[0] = Float.floatToIntBits ((float) Double.longBitsToDouble (l));
1872: }
1873:
1874:
1875:
1876:
1877:
1878:
1879:
1880: public static void fpkFSINH () {
1881:
1882: float xf = Float.intBitsToFloat (XEiJ.regRn[0]);
1883: float zf = (float) Math.sinh ((double) xf);
1884: int zh = Float.floatToIntBits (zf);
1885: if (FPK_FPCP_NAN && zh == 0x7fc00000) {
1886: zh = 0x7fffffff;
1887: }
1888: XEiJ.regRn[0] = zh;
1889: XEiJ.regCCR = (Float.isNaN (xf) ? 0 :
1890: Float.isNaN (zf) ? XEiJ.REG_CCR_C :
1891: Float.isInfinite (xf) ? 0 :
1892: Float.isNaN (zf) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C :
1893: 0);
1894: }
1895:
1896:
1897:
1898:
1899:
1900:
1901:
1902: public static void fpkFCOSH () {
1903:
1904: float xf = Float.intBitsToFloat (XEiJ.regRn[0]);
1905: float zf = (float) Math.cosh ((double) xf);
1906: int zh = Float.floatToIntBits (zf);
1907: if (FPK_FPCP_NAN && zh == 0x7fc00000) {
1908: zh = 0x7fffffff;
1909: }
1910: XEiJ.regRn[0] = zh;
1911: XEiJ.regCCR = (Float.isNaN (xf) ? 0 :
1912: Float.isNaN (zf) ? XEiJ.REG_CCR_C :
1913: Float.isInfinite (xf) ? 0 :
1914: Float.isNaN (zf) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C :
1915: 0);
1916: }
1917:
1918:
1919:
1920:
1921:
1922:
1923: public static void fpkFTANH () {
1924:
1925: int h = Float.floatToIntBits ((float) Math.tanh ((double) Float.intBitsToFloat (XEiJ.regRn[0])));
1926: if (FPK_FPCP_NAN && h == 0x7fc00000) {
1927: h = 0x7fffffff;
1928: }
1929: XEiJ.regRn[0] = h;
1930: }
1931:
1932:
1933:
1934:
1935:
1936:
1937:
1938: public static void fpkFATANH () {
1939:
1940: double d = (double) Float.intBitsToFloat (XEiJ.regRn[0]);
1941: double s = Math.signum (d);
1942: double a = Math.abs (d);
1943: if (a < 1.0) {
1944: d = s * (Math.log1p (a) - Math.log1p (-a)) * 0.5;
1945: XEiJ.regCCR = 0;
1946: } else if (a == 1.0) {
1947: d = s * Double.POSITIVE_INFINITY;
1948: XEiJ.regCCR = XEiJ.REG_CCR_C;
1949: } else {
1950: d = Double.NaN;
1951: XEiJ.regCCR = XEiJ.REG_CCR_C;
1952: }
1953: int h = Float.floatToIntBits ((float) d);
1954: if (FPK_FPCP_NAN && h == 0x7fc00000) {
1955: h = 0x7fffffff;
1956: }
1957: XEiJ.regRn[0] = h;
1958: }
1959:
1960:
1961:
1962:
1963:
1964:
1965:
1966: public static void fpkFASIN () {
1967:
1968: double d = (double) Float.intBitsToFloat (XEiJ.regRn[0]);
1969: if (d < -1.0 || 1.0 < d) {
1970: d = Double.NaN;
1971: XEiJ.regCCR = XEiJ.REG_CCR_C;
1972: } else {
1973: d = Math.asin (d);
1974: XEiJ.regCCR = 0;
1975: }
1976: int h = Float.floatToIntBits ((float) d);
1977: if (FPK_FPCP_NAN && h == 0x7fc00000) {
1978: h = 0x7fffffff;
1979: }
1980: XEiJ.regRn[0] = h;
1981: }
1982:
1983:
1984:
1985:
1986:
1987:
1988:
1989: public static void fpkFACOS () {
1990:
1991: double d = (double) Float.intBitsToFloat (XEiJ.regRn[0]);
1992: if (d < -1.0 || 1.0 < d) {
1993: d = Double.NaN;
1994: XEiJ.regCCR = XEiJ.REG_CCR_C;
1995: } else {
1996: d = Math.acos (d);
1997: XEiJ.regCCR = 0;
1998: }
1999: int h = Float.floatToIntBits ((float) d);
2000: if (FPK_FPCP_NAN && h == 0x7fc00000) {
2001: h = 0x7fffffff;
2002: }
2003: XEiJ.regRn[0] = h;
2004: }
2005:
2006:
2007:
2008:
2009:
2010:
2011:
2012: public static void fpkFLOG10 () {
2013:
2014: double xd = (double) Float.intBitsToFloat (XEiJ.regRn[0]);
2015: double zd = Math.log10 (xd);
2016: int h = Float.floatToIntBits ((float) zd);
2017: if (FPK_FPCP_NAN && h == 0x7fc00000) {
2018: h = 0x7fffffff;
2019: }
2020: XEiJ.regRn[0] = h;
2021: XEiJ.regCCR = (Double.isNaN (xd) ? 0 :
2022: Double.isNaN (zd) ? XEiJ.REG_CCR_C :
2023: Double.isInfinite (xd) ? 0 :
2024: Double.isInfinite (zd) ? XEiJ.REG_CCR_Z | XEiJ.REG_CCR_C :
2025: 0);
2026: }
2027:
2028:
2029:
2030:
2031:
2032:
2033:
2034: public static void fpkFLOG2 () {
2035:
2036: double xd = (double) Float.intBitsToFloat (XEiJ.regRn[0]);
2037: double zd = Math.log (xd) / 0.69314718055994530941723212146;
2038: int h = Float.floatToIntBits ((float) zd);
2039: if (FPK_FPCP_NAN && h == 0x7fc00000) {
2040: h = 0x7fffffff;
2041: }
2042: XEiJ.regRn[0] = h;
2043: XEiJ.regCCR = (Double.isNaN (xd) ? 0 :
2044: Double.isNaN (zd) ? XEiJ.REG_CCR_C :
2045: Double.isInfinite (xd) ? 0 :
2046: Double.isInfinite (zd) ? XEiJ.REG_CCR_Z | XEiJ.REG_CCR_C :
2047: 0);
2048: }
2049:
2050:
2051:
2052:
2053:
2054:
2055:
2056: public static void fpkFFREXP () {
2057: int h = XEiJ.regRn[0];
2058: if (h << 1 == 0) {
2059: XEiJ.regRn[0] = 0;
2060: XEiJ.regRn[1] = 0;
2061: } else {
2062: XEiJ.regRn[0] = (h & 0x807fffff) | 0x3f800000;
2063: XEiJ.regRn[1] = (h >>> 23 & 255) - 0x7f;
2064: }
2065: }
2066:
2067:
2068:
2069:
2070:
2071:
2072:
2073:
2074: public static void fpkFLDEXP () {
2075: int h = XEiJ.regRn[0];
2076: if (h << 1 == 0) {
2077: XEiJ.regRn[0] = 0;
2078: XEiJ.regCCR = 0;
2079: } else {
2080: int t = (h >>> 23 & 255) + XEiJ.regRn[2];
2081: if ((t & ~0xff) != 0) {
2082: XEiJ.regCCR = XEiJ.REG_CCR_C;
2083: } else {
2084: XEiJ.regRn[0] = (h & 0x807fffff) | t << 23;
2085: XEiJ.regCCR = 0;
2086: }
2087: }
2088: }
2089:
2090:
2091:
2092:
2093:
2094:
2095: public static void fpkFADDONE () {
2096:
2097: float xf = Float.intBitsToFloat (XEiJ.regRn[0]);
2098: float zf = xf + 1.0F;
2099: int h = Float.floatToIntBits (zf);
2100: if (FPK_FPCP_NAN && h == 0x7fc00000) {
2101: h = 0x7fffffff;
2102: }
2103: XEiJ.regRn[0] = h;
2104: XEiJ.regCCR = Double.isInfinite (zf) && !Float.isInfinite (xf) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C : 0;
2105: }
2106:
2107:
2108:
2109:
2110:
2111:
2112: public static void fpkFSUBONE () {
2113:
2114: float xf = Float.intBitsToFloat (XEiJ.regRn[0]);
2115: float zf = xf - 1.0F;
2116: int h = Float.floatToIntBits (zf);
2117: if (FPK_FPCP_NAN && h == 0x7fc00000) {
2118: h = 0x7fffffff;
2119: }
2120: XEiJ.regRn[0] = h;
2121: XEiJ.regCCR = Double.isInfinite (zf) && !Float.isInfinite (xf) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C : 0;
2122: }
2123:
2124:
2125:
2126:
2127:
2128:
2129:
2130: public static void fpkFDIVTWO () {
2131:
2132: float xf = Float.intBitsToFloat (XEiJ.regRn[0]);
2133: float zf = xf * 0.5F;
2134: int h = Float.floatToIntBits (zf);
2135: if (FPK_FPCP_NAN && h == 0x7fc00000) {
2136: h = 0x7fffffff;
2137: }
2138: XEiJ.regRn[0] = h;
2139: XEiJ.regCCR = zf == 0.0F && xf != 0.0F ? XEiJ.REG_CCR_C : 0;
2140: }
2141:
2142:
2143:
2144:
2145:
2146:
2147: public static void fpkFIEECNV () {
2148: }
2149:
2150:
2151:
2152:
2153:
2154:
2155: public static void fpkIEEFCNV () {
2156: }
2157:
2158:
2159:
2160:
2161:
2162:
2163: public static void fpkFEVARG () {
2164: XEiJ.regRn[0] = 'I' << 24 | 'E' << 16 | 'E' << 8 | 'E';
2165: XEiJ.regRn[1] = 'X' << 24 | 'E' << 16 | 'i' << 8 | 'J';
2166: }
2167:
2168:
2169:
2170:
2171:
2172:
2173:
2174:
2175:
2176:
2177: public static void fpkFEVECS () {
2178: XEiJ.regRn[0] = -1;
2179: }
2180:
2181:
2182:
2183:
2184:
2185:
2186:
2187:
2188:
2189:
2190:
2191:
2192: public static void fpkSTOL () throws M68kException {
2193: int a = XEiJ.regRn[8];
2194: int c = XEiJ.busRbz (a);
2195: while (c == ' ' || c == '\t') {
2196: c = XEiJ.busRbz (++a);
2197: }
2198: int n = '7';
2199: if (c == '-') {
2200: n = '8';
2201: c = XEiJ.busRbz (++a);
2202: } else if (c == '+') {
2203: c = XEiJ.busRbz (++a);
2204: }
2205: if (!('0' <= c && c <= '9')) {
2206: XEiJ.regRn[8] = a;
2207: XEiJ.regCCR = XEiJ.REG_CCR_N | XEiJ.REG_CCR_C;
2208: return;
2209: }
2210: int x = c - '0';
2211: for (c = XEiJ.busRbz (++a); '0' <= c && c <= '9'; c = XEiJ.busRbz (++a)) {
2212: if (214748364 < x || x == 214748364 && n < c) {
2213: XEiJ.regRn[8] = a;
2214: XEiJ.regCCR = XEiJ.REG_CCR_V | XEiJ.REG_CCR_C;
2215: return;
2216: }
2217: x = x * 10 + (c - '0');
2218: }
2219: if (n != '7') {
2220: x = -x;
2221: }
2222: XEiJ.regRn[0] = x;
2223: XEiJ.regRn[8] = a;
2224: XEiJ.regCCR = 0;
2225: }
2226:
2227:
2228:
2229:
2230:
2231:
2232:
2233:
2234: public static void fpkLTOS () throws M68kException {
2235: int x = XEiJ.regRn[0];
2236: int a = XEiJ.regRn[8];
2237: if (x < 0) {
2238: XEiJ.busWb (a++, '-');
2239: x = -x;
2240: }
2241: long t = XEiJ.fmtBcd12 (0xffffffffL & x);
2242: XEiJ.regRn[8] = a += Math.max (1, 67 - Long.numberOfLeadingZeros (t) >> 2);
2243: XEiJ.busWb (a, 0);
2244: do {
2245: XEiJ.busWb (--a, '0' | (int) t & 15);
2246: } while ((t >>>= 4) != 0L);
2247: }
2248:
2249:
2250:
2251:
2252:
2253:
2254:
2255:
2256:
2257: public static void fpkSTOH () throws M68kException {
2258: int a = XEiJ.regRn[8];
2259: int c = XEiJ.busRbz (a);
2260: if (!('0' <= c && c <= '9' || 'A' <= c && c <= 'F' || 'a' <= c && c <= 'f')) {
2261: XEiJ.regRn[8] = a;
2262: XEiJ.regCCR = XEiJ.REG_CCR_N | XEiJ.REG_CCR_C;
2263: return;
2264: }
2265: int x = c <= '9' ? c - '0' : c <= 'F' ? c - ('A' - 10) : c - ('a' - 10);
2266: for (c = XEiJ.busRbz (++a); '0' <= c && c <= '9' || 'A' <= c && c <= 'F' || 'a' <= c && c <= 'f'; c = XEiJ.busRbz (++a)) {
2267: if (0x0fffffff < x) {
2268: XEiJ.regRn[8] = a;
2269: XEiJ.regCCR = XEiJ.REG_CCR_V | XEiJ.REG_CCR_C;
2270: return;
2271: }
2272: x = x << 4 | (c <= '9' ? c - '0' : c <= 'F' ? c - ('A' - 10) : c - ('a' - 10));
2273: }
2274: XEiJ.regRn[0] = x;
2275: XEiJ.regRn[8] = a;
2276: XEiJ.regCCR = 0;
2277: }
2278:
2279:
2280:
2281:
2282:
2283:
2284:
2285:
2286: public static void fpkHTOS () throws M68kException {
2287: int x = XEiJ.regRn[0];
2288: int a = XEiJ.regRn[8] += Math.max (1, 35 - Integer.numberOfLeadingZeros (x) >> 2);
2289: XEiJ.busWb (a, 0);
2290: do {
2291: int t = x & 15;
2292:
2293:
2294:
2295:
2296:
2297:
2298:
2299: XEiJ.busWb (--a, (9 - t >> 4 & 7 | 48) + t);
2300: } while ((x >>>= 4) != 0);
2301: }
2302:
2303:
2304:
2305:
2306:
2307:
2308:
2309:
2310:
2311: public static void fpkSTOO () throws M68kException {
2312: int a = XEiJ.regRn[8];
2313: int c = XEiJ.busRbz (a);
2314: if (!('0' <= c && c <= '7')) {
2315: XEiJ.regRn[8] = a;
2316: XEiJ.regCCR = XEiJ.REG_CCR_N | XEiJ.REG_CCR_C;
2317: return;
2318: }
2319: int x = c - '0';
2320: for (c = XEiJ.busRbz (++a); '0' <= c && c <= '7'; c = XEiJ.busRbz (++a)) {
2321: if (0x1fffffff < x) {
2322: XEiJ.regRn[8] = a;
2323: XEiJ.regCCR = XEiJ.REG_CCR_V | XEiJ.REG_CCR_C;
2324: return;
2325: }
2326: x = x << 3 | c & 7;
2327: }
2328: XEiJ.regRn[0] = x;
2329: XEiJ.regRn[8] = a;
2330: XEiJ.regCCR = 0;
2331: }
2332:
2333:
2334:
2335:
2336:
2337:
2338:
2339:
2340: public static void fpkOTOS () throws M68kException {
2341: int x = XEiJ.regRn[0];
2342:
2343:
2344: int a = XEiJ.regRn[8] += Math.max (1, (34 - Integer.numberOfLeadingZeros (x)) * 43 >>> 7);
2345: XEiJ.busWb (a, 0);
2346: do {
2347: XEiJ.busWb (--a, '0' | x & 7);
2348: } while ((x >>>= 3) != 0);
2349: }
2350:
2351:
2352:
2353:
2354:
2355:
2356:
2357:
2358:
2359: public static void fpkSTOB () throws M68kException {
2360: int a = XEiJ.regRn[8];
2361: int c = XEiJ.busRbz (a);
2362: if (!('0' <= c && c <= '1')) {
2363: XEiJ.regRn[8] = a;
2364: XEiJ.regCCR = XEiJ.REG_CCR_N | XEiJ.REG_CCR_C;
2365: return;
2366: }
2367: int x = c - '0';
2368: for (c = XEiJ.busRbz (++a); '0' <= c && c <= '1'; c = XEiJ.busRbz (++a)) {
2369: if (x < 0) {
2370: XEiJ.regRn[8] = a;
2371: XEiJ.regCCR = XEiJ.REG_CCR_V | XEiJ.REG_CCR_C;
2372: return;
2373: }
2374: x = x << 1 | c & 1;
2375: }
2376: XEiJ.regRn[0] = x;
2377: XEiJ.regRn[8] = a;
2378: XEiJ.regCCR = 0;
2379: }
2380:
2381:
2382:
2383:
2384:
2385:
2386:
2387:
2388: public static void fpkBTOS () throws M68kException {
2389: int x = XEiJ.regRn[0];
2390: int a = XEiJ.regRn[8] += Math.max (1, 32 - Integer.numberOfLeadingZeros (x));
2391: XEiJ.busWb (a, 0);
2392: do {
2393: XEiJ.busWb (--a, '0' | x & 1);
2394: } while ((x >>>= 1) != 0);
2395: }
2396:
2397:
2398:
2399:
2400:
2401:
2402:
2403:
2404:
2405: public static void fpkIUSING () throws M68kException {
2406: int x = XEiJ.regRn[0];
2407: int n = 0;
2408: if (x < 0) {
2409: n = 1;
2410: x = -x;
2411: }
2412: long t = XEiJ.fmtBcd12 (0xffffffffL & x);
2413: int l = n + Math.max (1, 67 - Long.numberOfLeadingZeros (t) >> 2);
2414: int a = XEiJ.regRn[8];
2415: for (int i = (XEiJ.regRn[1] & 255) - l; i > 0; i--) {
2416: XEiJ.busWb (a++, ' ');
2417: }
2418: XEiJ.regRn[8] = a += l;
2419: XEiJ.busWb (a, 0);
2420: do {
2421: XEiJ.busWb (--a, '0' | (int) t & 15);
2422: } while ((t >>>= 4) != 0L);
2423: if (n != 0) {
2424: XEiJ.busWb (--a, '-');
2425: }
2426: }
2427:
2428:
2429:
2430:
2431:
2432:
2433:
2434:
2435:
2436:
2437:
2438:
2439:
2440:
2441:
2442: public static void fpkVAL () throws M68kException {
2443: int a = XEiJ.regRn[8];
2444:
2445: int c = XEiJ.busRbs (a++);
2446: while (c == ' ' || c == '\t') {
2447: c = XEiJ.busRbs (a++);
2448: }
2449: if (c == '&') {
2450: c = XEiJ.busRbs (a++) & 0xdf;
2451: XEiJ.regRn[8] = a;
2452: if (c == 'B') {
2453: fpkSTOB ();
2454: fpkLTOD ();
2455: } else if (c == 'O') {
2456: fpkSTOO ();
2457: fpkLTOD ();
2458: } else if (c == 'H') {
2459: fpkSTOH ();
2460: fpkLTOD ();
2461: } else {
2462: XEiJ.regCCR = XEiJ.REG_CCR_N | XEiJ.REG_CCR_C;
2463: }
2464: } else {
2465: fpkSTOD ();
2466: }
2467: }
2468:
2469:
2470:
2471:
2472:
2473:
2474:
2475:
2476:
2477:
2478:
2479:
2480:
2481:
2482:
2483:
2484:
2485:
2486:
2487:
2488:
2489:
2490:
2491:
2492:
2493:
2494:
2495:
2496:
2497:
2498:
2499:
2500:
2501:
2502:
2503:
2504:
2505:
2506:
2507:
2508:
2509:
2510:
2511:
2512:
2513:
2514:
2515:
2516:
2517:
2518:
2519:
2520:
2521:
2522:
2523:
2524:
2525:
2526:
2527:
2528:
2529:
2530:
2531:
2532:
2533: public static void fpkUSING () throws M68kException {
2534: fpkUSINGSub ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
2535: }
2536: public static void fpkUSINGSub (long l) throws M68kException {
2537: int len1 = Math.max (0, XEiJ.regRn[2]);
2538: int len2 = Math.max (0, XEiJ.regRn[3]);
2539: int attr = XEiJ.regRn[4];
2540: int a = XEiJ.regRn[8];
2541: boolean exp = (attr & 8) != 0;
2542: int spc = (attr & 1) != 0 ? '*' : ' ';
2543: int yen = (attr & 2) != 0 ? '\\' : 0;
2544: int cmm = !exp && (attr & 4) != 0 ? ',' : 0;
2545:
2546: int sgn1 = 0;
2547: int sgn2 = 0;
2548: if (l < 0L) {
2549: if ((attr & 32 + 64) == 0) {
2550: sgn1 = '-';
2551: } else {
2552: sgn2 = '-';
2553: }
2554: l &= 0x7fffffffffffffffL;
2555: } else {
2556: if ((attr & 16) != 0) {
2557: sgn1 = '+';
2558: } else if ((attr & 16 + 32) == 32) {
2559: sgn2 = '+';
2560: } else if ((attr & 16 + 32 + 64) == 64) {
2561: sgn2 = ' ';
2562: }
2563: }
2564: double x = Double.longBitsToDouble (l);
2565: int e = (int) (l >>> 52) - 1023;
2566: l &= 0x000fffffffffffffL;
2567:
2568: if (e == -1023) {
2569: if (l == 0L) {
2570: for (int i = len1 - ((sgn1 != 0 ? 1 : 0) +
2571: (yen != 0 ? 1 : 0) +
2572: 1
2573: ); 0 < i; i--) {
2574: XEiJ.busWb (a++, spc);
2575: }
2576: if (sgn1 != 0) {
2577: XEiJ.busWb (a++, sgn1);
2578: }
2579: if (yen != 0) {
2580: XEiJ.busWb (a++, yen);
2581: }
2582: if (0 < len1) {
2583: XEiJ.busWb (a++, '0');
2584: }
2585: XEiJ.busWb (a++, '.');
2586: for (; 0 < len2; len2--) {
2587: XEiJ.busWb (a++, '0');
2588: }
2589: XEiJ.busWb (a, '\0');
2590: return;
2591: }
2592: e -= Long.numberOfLeadingZeros (l) - 12;
2593: } else if (e == 1024) {
2594: for (int i = len1 + 1 + len2 + (exp ? 5 : 0) -
2595: ((sgn1 != 0 ? 1 : 0) +
2596: (yen != 0 ? 1 : 0) +
2597: 4
2598: ); 0 < i; i--) {
2599: XEiJ.busWb (a++, spc);
2600: }
2601: if (sgn1 != 0) {
2602: XEiJ.busWb (a++, sgn1);
2603: }
2604: if (yen != 0) {
2605: XEiJ.busWb (a++, yen);
2606: }
2607: XEiJ.busWb (a++, '#');
2608: if (l == 0L) {
2609: XEiJ.busWb (a++, 'I');
2610: XEiJ.busWb (a++, 'N');
2611: XEiJ.busWb (a++, 'F');
2612: } else {
2613: XEiJ.busWb (a++, 'N');
2614: XEiJ.busWb (a++, 'A');
2615: XEiJ.busWb (a++, 'N');
2616: }
2617: XEiJ.busWb (a, '\0');
2618: return;
2619: }
2620:
2621:
2622: e = (int) Math.floor ((double) e * 0.30102999566398119521373889472);
2623:
2624:
2625:
2626:
2627: if (0 < e) {
2628: x *= FPK_TEN_M16QR[e & 15];
2629: if (16 <= e) {
2630: x *= FPK_TEN_M16QR[16 + (e >> 4 & 15)];
2631: if (256 <= e) {
2632: x *= FPK_TEN_M16QR[33];
2633: }
2634: }
2635: } else if (e < 0) {
2636: x *= FPK_TEN_P16QR[-e & 15];
2637: if (e <= -16) {
2638: x *= FPK_TEN_P16QR[16 + (-e >> 4 & 15)];
2639: if (e <= -256) {
2640: x *= FPK_TEN_P16QR[33];
2641: }
2642: }
2643: }
2644:
2645:
2646: int[] w = new int[18];
2647: {
2648: int d = (int) x;
2649: int t = XEiJ.FMT_BCD4[d];
2650: w[0] = t >> 4;
2651: w[1] = t & 15;
2652: for (int i = 2; i < 18; i += 4) {
2653:
2654:
2655:
2656: double xh = x * 0x8000001p0;
2657: xh += x - xh;
2658: x = (xh - (double) d) * 10000.0 + (x - xh) * 10000.0;
2659: d = (int) x;
2660: t = XEiJ.FMT_BCD4[d];
2661: w[i ] = t >> 12;
2662: w[i + 1] = t >> 8 & 15;
2663: w[i + 2] = t >> 4 & 15;
2664: w[i + 3] = t & 15;
2665: }
2666: }
2667:
2668:
2669: int h = w[0] != 0 ? 0 : w[1] != 0 ? 1 : 2;
2670:
2671: int o = h + 14;
2672: if (5 <= w[o]) {
2673: int i = o;
2674: while (10 <= ++w[--i]) {
2675: w[i] = 0;
2676: }
2677: if (i < h) {
2678: h--;
2679: o--;
2680: }
2681: }
2682:
2683:
2684: e -= h - 1;
2685:
2686: int ee = !exp ? e : Math.max (0, sgn1 != 0 || sgn2 != 0 ? len1 : len1 - 1) - 1;
2687:
2688:
2689:
2690: int s = h + ee + 1 + len2;
2691: if (s < o) {
2692: o = s;
2693: if (0 <= o && 5 <= w[o]) {
2694: int i = o;
2695: while (10 <= ++w[--i]) {
2696: w[i] = 0;
2697: }
2698: if (i < h) {
2699: h--;
2700: if (!exp) {
2701: ee++;
2702: } else {
2703: e++;
2704: o--;
2705: }
2706: }
2707: }
2708: }
2709:
2710: if (0 <= ee) {
2711: for (int i = len1 - ((sgn1 != 0 ? 1 : 0) +
2712: (yen != 0 ? 1 : 0) +
2713: (cmm != 0 ? ee / 3 : 0) +
2714: ee + 1
2715: ); 0 < i; i--) {
2716: XEiJ.busWb (a++, spc);
2717: }
2718: if (sgn1 != 0) {
2719: XEiJ.busWb (a++, sgn1);
2720: }
2721: if (yen != 0) {
2722: XEiJ.busWb (a++, yen);
2723: }
2724: for (int i = ee; 0 <= i; i--) {
2725: XEiJ.busWb (a++, h < o ? '0' + w[h] : '0');
2726: h++;
2727: if (cmm != 0 && 0 < i && i % 3 == 0) {
2728: XEiJ.busWb (a++, cmm);
2729: }
2730: }
2731: XEiJ.busWb (a++, '.');
2732: for (; 0 < len2; len2--) {
2733: XEiJ.busWb (a++, h < o ? '0' + w[h] : '0');
2734: h++;
2735: }
2736: } else {
2737: for (int i = len1 - ((sgn1 != 0 ? 1 : 0) +
2738: (yen != 0 ? 1 : 0) +
2739: 1
2740: ); 0 < i; i--) {
2741: XEiJ.busWb (a++, spc);
2742: }
2743: if (sgn1 != 0) {
2744: XEiJ.busWb (a++, sgn1);
2745: }
2746: if (yen != 0) {
2747: XEiJ.busWb (a++, yen);
2748: }
2749: if (0 < len1) {
2750: XEiJ.busWb (a++, '0');
2751: }
2752: XEiJ.busWb (a++, '.');
2753: for (int i = -1 - ee; 0 < len2 && 0 < i; len2--, i--) {
2754: XEiJ.busWb (a++, '0');
2755: }
2756: for (; 0 < len2; len2--) {
2757: XEiJ.busWb (a++, h < o ? '0' + w[h] : '0');
2758: h++;
2759: }
2760: }
2761: if (exp) {
2762: e -= ee;
2763: XEiJ.busWb (a++, 'E');
2764: if (0 <= e) {
2765: XEiJ.busWb (a++, '+');
2766: } else {
2767: XEiJ.busWb (a++, '-');
2768: e = -e;
2769: }
2770: e = XEiJ.FMT_BCD4[e];
2771: XEiJ.busWb (a++, '0' + (e >> 8 ));
2772: XEiJ.busWb (a++, '0' + (e >> 4 & 15));
2773: XEiJ.busWb (a++, '0' + (e & 15));
2774: }
2775: if (sgn2 != 0) {
2776: XEiJ.busWb (a++, sgn2);
2777: }
2778: XEiJ.busWb (a, '\0');
2779: }
2780:
2781:
2782:
2783:
2784:
2785:
2786:
2787:
2788:
2789:
2790:
2791:
2792:
2793:
2794:
2795:
2796:
2797:
2798:
2799:
2800:
2801:
2802:
2803:
2804:
2805: public static void fpkSTOD () throws M68kException {
2806: long l = Double.doubleToLongBits (fpkSTODSub ());
2807: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
2808: l = 0x7fffffffffffffffL;
2809: }
2810: XEiJ.regRn[0] = (int) (l >> 32);
2811: XEiJ.regRn[1] = (int) l;
2812: }
2813: public static double fpkSTODSub () throws M68kException {
2814: int a = XEiJ.regRn[8];
2815:
2816: int c = XEiJ.busRbs (a);
2817: while (c == ' ' || c == '\t') {
2818: c = XEiJ.busRbs (++a);
2819: }
2820:
2821: double s = 1.0;
2822: if (c == '+') {
2823: c = XEiJ.busRbs (++a);
2824: } else if (c == '-') {
2825: s = -s;
2826: c = XEiJ.busRbs (++a);
2827: }
2828:
2829: if (c == '#') {
2830: c = XEiJ.busRbs (a + 1);
2831: if (c == 'N' || c == 'I') {
2832: c = c << 8 | XEiJ.busRbz (a + 2);
2833: if (c == ('N' << 8 | 'A') || c == ('I' << 8 | 'N')) {
2834: c = c << 8 | XEiJ.busRbz (a + 3);
2835: if (c == ('N' << 16 | 'A' << 8 | 'N') || c == ('I' << 16 | 'N' << 8 | 'F')) {
2836: XEiJ.regRn[2] = 0;
2837: XEiJ.regRn[3] = 0;
2838: XEiJ.regRn[8] = a + 4;
2839: XEiJ.regCCR = 0;
2840: return c == ('N' << 16 | 'A' << 8 | 'N') ? Double.NaN : s * Double.POSITIVE_INFINITY;
2841: }
2842: }
2843: }
2844: XEiJ.regRn[8] = a;
2845: XEiJ.regCCR = XEiJ.REG_CCR_N | XEiJ.REG_CCR_C;
2846: return 0.0;
2847: }
2848:
2849:
2850:
2851: long u = 0L;
2852: int n = 0;
2853: int e = 1;
2854: if (c == '.') {
2855: e = 0;
2856: c = XEiJ.busRbs (++a);
2857: }
2858: if (c < '0' || '9' < c) {
2859: XEiJ.regRn[8] = a;
2860: XEiJ.regCCR = XEiJ.REG_CCR_N | XEiJ.REG_CCR_C;
2861: return 0.0;
2862: }
2863: double x = 0.0;
2864: do {
2865: if (0 < n || '0' < c) {
2866: n++;
2867: }
2868: if (e <= 0 && n <= 18) {
2869: e--;
2870: }
2871: if (0 < n && n <= 18) {
2872: u = u * 10L + (long) (c - '0');
2873: }
2874: c = XEiJ.busRbs (++a);
2875: if (0 < e && c == '.') {
2876: e = 0;
2877: c = XEiJ.busRbs (++a);
2878: }
2879: } while ('0' <= c && c <= '9');
2880: if (0 < e) {
2881: e = 18 < n ? n - 18 : 0;
2882: }
2883:
2884:
2885:
2886:
2887:
2888:
2889: if (c == 'E' || c == 'e') {
2890: c = XEiJ.busRbs (++a);
2891: int t = 1;
2892: if (c == '+') {
2893: c = XEiJ.busRbs (++a);
2894: } else if (c == '-') {
2895: t = -t;
2896: c = XEiJ.busRbs (++a);
2897: }
2898: if (c < '0' || '9' < c) {
2899: XEiJ.regRn[8] = a;
2900: XEiJ.regCCR = XEiJ.REG_CCR_N | XEiJ.REG_CCR_C;
2901: return 0.0;
2902: }
2903: while (c == '0') {
2904: c = XEiJ.busRbs (++a);
2905: }
2906: int p = 0;
2907: for (int j = 0; '0' <= c && c <= '9' && j < 9; j++) {
2908: p = p * 10 + (c - '0');
2909: c = XEiJ.busRbs (++a);
2910: }
2911: e += t * p;
2912: }
2913:
2914:
2915:
2916: if (e < -350) {
2917: XEiJ.regRn[2] = 65535;
2918: XEiJ.regRn[3] = 0;
2919: XEiJ.regRn[8] = a;
2920: XEiJ.regCCR = 0;
2921: return s < 0.0 ? -0.0 : 0.0;
2922: }
2923: if (350 < e) {
2924: XEiJ.regRn[2] = 0;
2925: XEiJ.regRn[3] = 0;
2926: XEiJ.regRn[8] = a;
2927: XEiJ.regCCR = XEiJ.REG_CCR_V | XEiJ.REG_CCR_C;
2928: return s * Double.POSITIVE_INFINITY;
2929: }
2930: if (true) {
2931: QFP xx = new QFP (s < 0.0 ? -u : u);
2932: if (0 < e) {
2933: xx.mul (QFP.QFP_TEN_P16QR[e & 15]);
2934: if (16 <= e) {
2935: xx.mul (QFP.QFP_TEN_P16QR[16 + (e >> 4 & 15)]);
2936: if (256 <= e) {
2937: xx.mul (QFP.QFP_TEN_P16QR[33]);
2938: }
2939: }
2940: } else if (e < 0) {
2941: xx.mul (QFP.QFP_TEN_M16QR[-e & 15]);
2942: if (e <= -16) {
2943: xx.mul (QFP.QFP_TEN_M16QR[16 + (-e >> 4 & 15)]);
2944: if (e <= -256) {
2945: xx.mul (QFP.QFP_TEN_M16QR[33]);
2946: }
2947: }
2948: }
2949: x = xx.getd ();
2950: } else {
2951: x = s * (double) u;
2952: if (0 < e) {
2953: x *= FPK_TEN_P16QR[e & 15];
2954: if (16 <= e) {
2955: x *= FPK_TEN_P16QR[16 + (e >> 4 & 15)];
2956: if (256 <= e) {
2957: x *= FPK_TEN_P16QR[33];
2958: }
2959: }
2960: } else if (e < 0) {
2961: x /= FPK_TEN_P16QR[-e & 15];
2962: if (e <= -16) {
2963: x /= FPK_TEN_P16QR[16 + (-e >> 4 & 15)];
2964: if (e <= -256) {
2965: x /= FPK_TEN_P16QR[33];
2966: }
2967: }
2968: }
2969: }
2970: if (Double.isInfinite (x)) {
2971: XEiJ.regRn[8] = a;
2972: XEiJ.regCCR = XEiJ.REG_CCR_V | XEiJ.REG_CCR_C;
2973: return x;
2974: }
2975:
2976: if (x == (double) ((int) x)) {
2977: XEiJ.regRn[2] = 65535;
2978: XEiJ.regRn[3] = (int) x;
2979: } else {
2980: XEiJ.regRn[2] = 0;
2981: XEiJ.regRn[3] = 0;
2982: }
2983: XEiJ.regRn[8] = a;
2984: XEiJ.regCCR = 0;
2985: return x;
2986: }
2987:
2988:
2989:
2990:
2991:
2992:
2993:
2994:
2995:
2996:
2997:
2998:
2999:
3000:
3001:
3002: public static void fpkDTOS () throws M68kException {
3003: fpkDTOSSub ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
3004: }
3005: public static void fpkDTOSSub (long l) throws M68kException {
3006: final int len3 = 14;
3007: int a = XEiJ.regRn[8];
3008:
3009:
3010: if (l < 0L) {
3011: XEiJ.busWb (a++, '-');
3012: l &= 0x7fffffffffffffffL;
3013: }
3014: double x = Double.longBitsToDouble (l);
3015: int e = (int) (l >>> 52) - 1023;
3016: l &= 0x000fffffffffffffL;
3017: if (e == -1023) {
3018: if (l == 0L) {
3019: XEiJ.busWb (a++, '0');
3020: XEiJ.busWb (a, '\0');
3021: XEiJ.regRn[8] = a;
3022: return;
3023: }
3024: e -= Long.numberOfLeadingZeros (l) - 12;
3025: } else if (e == 1024) {
3026: XEiJ.busWb (a++, '#');
3027: if (l == 0L) {
3028: XEiJ.busWb (a++, 'I');
3029: XEiJ.busWb (a++, 'N');
3030: XEiJ.busWb (a++, 'F');
3031: } else {
3032: XEiJ.busWb (a++, 'N');
3033: XEiJ.busWb (a++, 'A');
3034: XEiJ.busWb (a++, 'N');
3035: }
3036: XEiJ.busWb (a, '\0');
3037: XEiJ.regRn[8] = a;
3038: return;
3039: }
3040:
3041:
3042: e = (int) Math.floor ((double) e * 0.30102999566398119521373889472);
3043:
3044:
3045:
3046:
3047: if (0 < e) {
3048: x *= FPK_TEN_M16QR[e & 15];
3049: if (16 <= e) {
3050: x *= FPK_TEN_M16QR[16 + (e >> 4 & 15)];
3051: if (256 <= e) {
3052: x *= FPK_TEN_M16QR[33];
3053: }
3054: }
3055: } else if (e < 0) {
3056: x *= FPK_TEN_P16QR[-e & 15];
3057: if (e <= -16) {
3058: x *= FPK_TEN_P16QR[16 + (-e >> 4 & 15)];
3059: if (e <= -256) {
3060: x *= FPK_TEN_P16QR[33];
3061: }
3062: }
3063: }
3064:
3065:
3066: int[] w = new int[18];
3067: {
3068: int d = (int) x;
3069: int t = XEiJ.FMT_BCD4[d];
3070: w[0] = t >> 4;
3071: w[1] = t & 15;
3072: for (int i = 2; i < 18; i += 4) {
3073:
3074:
3075:
3076: double xh = x * 0x8000001p0;
3077: xh += x - xh;
3078: x = (xh - (double) d) * 10000.0 + (x - xh) * 10000.0;
3079: d = (int) x;
3080: t = XEiJ.FMT_BCD4[d];
3081: w[i ] = t >> 12;
3082: w[i + 1] = t >> 8 & 15;
3083: w[i + 2] = t >> 4 & 15;
3084: w[i + 3] = t & 15;
3085: }
3086: }
3087:
3088:
3089: int h = w[0] != 0 ? 0 : w[1] != 0 ? 1 : 2;
3090:
3091: int o = h + 14;
3092: if (5 <= w[o]) {
3093: int i = o;
3094: while (10 <= ++w[--i]) {
3095: w[i] = 0;
3096: }
3097: if (i < h) {
3098: h--;
3099: o--;
3100: }
3101: }
3102:
3103:
3104: e -= h - 1;
3105:
3106:
3107: while (w[o - 1] == 0) {
3108: o--;
3109: }
3110:
3111: if (0 <= e && e < len3) {
3112: for (; 0 <= e && h < o; e--) {
3113: XEiJ.busWb (a++, '0' + w[h++]);
3114: }
3115: for (; 0 <= e; e--) {
3116: XEiJ.busWb (a++, '0');
3117: }
3118: if (h < o) {
3119: XEiJ.busWb (a++, '.');
3120: do {
3121: XEiJ.busWb (a++, '0' + w[h++]);
3122: } while (h < o);
3123: }
3124: } else if (-4 <= e && e < 0) {
3125: XEiJ.busWb (a++, '0');
3126: XEiJ.busWb (a++, '.');
3127: while (++e < 0) {
3128: XEiJ.busWb (a++, '0');
3129: }
3130: do {
3131: XEiJ.busWb (a++, '0' + w[h++]);
3132: } while (h < o);
3133: } else {
3134: XEiJ.busWb (a++, '0' + w[h++]);
3135: if (h < o) {
3136: XEiJ.busWb (a++, '.');
3137: do {
3138: XEiJ.busWb (a++, '0' + w[h++]);
3139: } while (h < o);
3140: }
3141: XEiJ.busWb (a++, 'E');
3142: if (0 <= e) {
3143: XEiJ.busWb (a++, '+');
3144: } else {
3145: XEiJ.busWb (a++, '-');
3146: e = -e;
3147: }
3148: e = XEiJ.FMT_BCD4[e];
3149: XEiJ.busWb (a++, '0' + (e >> 8 ));
3150: XEiJ.busWb (a++, '0' + (e >> 4 & 15));
3151: XEiJ.busWb (a++, '0' + (e & 15));
3152: }
3153: XEiJ.busWb (a, '\0');
3154: XEiJ.regRn[8] = a;
3155: }
3156:
3157:
3158:
3159:
3160:
3161:
3162:
3163:
3164:
3165:
3166:
3167:
3168:
3169:
3170:
3171:
3172:
3173:
3174:
3175:
3176:
3177:
3178:
3179:
3180:
3181:
3182:
3183:
3184:
3185:
3186:
3187:
3188:
3189: public static void fpkECVT () throws M68kException {
3190: fpkECVTSub ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
3191: }
3192: public static void fpkECVTSub (long l) throws M68kException {
3193: int len3 = XEiJ.regRn[2];
3194: int a = XEiJ.regRn[8];
3195: if (len3 <= 0) {
3196: XEiJ.busWb (a, '\0');
3197: return;
3198: }
3199: int b = a + len3;
3200:
3201:
3202: if (0L <= l) {
3203: XEiJ.regRn[1] = 0;
3204: } else {
3205: XEiJ.regRn[1] = 1;
3206: l &= 0x7fffffffffffffffL;
3207: }
3208: double x = Double.longBitsToDouble (l);
3209: int e = (int) (l >>> 52) - 1023;
3210: l &= 0x000fffffffffffffL;
3211: if (e == -1023) {
3212: if (l == 0L) {
3213:
3214: while (a < b) {
3215: XEiJ.busWb (a++, '0');
3216: }
3217: XEiJ.busWb (a, '\0');
3218: XEiJ.regRn[0] = 1;
3219: return;
3220: }
3221: e -= Long.numberOfLeadingZeros (l) - 12;
3222: } else if (e == 1024) {
3223: for (int s = l != 0L ? '#' | 'N' << 8 | 'A' << 16 | 'N' << 24 : '#' | 'I' << 8 | 'N' << 16 | 'F' << 24; a < b && s != 0; s >>>= 8) {
3224: XEiJ.busWb (a++, s);
3225: }
3226: while (a < b) {
3227: XEiJ.busWb (a++, '\0');
3228: }
3229: XEiJ.busWb (a, '\0');
3230: XEiJ.regRn[0] = 4;
3231: return;
3232: }
3233:
3234:
3235: e = (int) Math.floor ((double) e * 0.30102999566398119521373889472);
3236:
3237:
3238:
3239:
3240: if (0 < e) {
3241: x *= FPK_TEN_M16QR[e & 15];
3242: if (16 <= e) {
3243: x *= FPK_TEN_M16QR[16 + (e >> 4 & 15)];
3244: if (256 <= e) {
3245: x *= FPK_TEN_M16QR[33];
3246: }
3247: }
3248: } else if (e < 0) {
3249: x *= FPK_TEN_P16QR[-e & 15];
3250: if (e <= -16) {
3251: x *= FPK_TEN_P16QR[16 + (-e >> 4 & 15)];
3252: if (e <= -256) {
3253: x *= FPK_TEN_P16QR[33];
3254: }
3255: }
3256: }
3257:
3258:
3259: int[] w = new int[18];
3260: {
3261: int d = (int) x;
3262: int t = XEiJ.FMT_BCD4[d];
3263: w[0] = t >> 4;
3264: w[1] = t & 15;
3265: for (int i = 2; i < 18; i += 4) {
3266:
3267:
3268:
3269: double xh = x * 0x8000001p0;
3270: xh += x - xh;
3271: x = (xh - (double) d) * 10000.0 + (x - xh) * 10000.0;
3272: d = (int) x;
3273: t = XEiJ.FMT_BCD4[d];
3274: w[i ] = t >> 12;
3275: w[i + 1] = t >> 8 & 15;
3276: w[i + 2] = t >> 4 & 15;
3277: w[i + 3] = t & 15;
3278: }
3279: }
3280:
3281:
3282: int h = w[0] != 0 ? 0 : w[1] != 0 ? 1 : 2;
3283:
3284: int o = h + 14;
3285: if (5 <= w[o]) {
3286: int i = o;
3287: while (10 <= ++w[--i]) {
3288: w[i] = 0;
3289: }
3290: if (i < h) {
3291: h--;
3292: o--;
3293: }
3294: }
3295:
3296:
3297: e -= h - 1;
3298:
3299:
3300:
3301: int s = h + len3;
3302: if (s < o) {
3303: o = s;
3304: if (0 <= o && 5 <= w[o]) {
3305: int i = o;
3306: while (10 <= ++w[--i]) {
3307: w[i] = 0;
3308: }
3309: if (i < h) {
3310: h--;
3311: o--;
3312: e++;
3313: }
3314: }
3315: }
3316:
3317: while (a < b && h < o) {
3318: XEiJ.busWb (a++, '0' + w[h++]);
3319: }
3320: while (a < b) {
3321: XEiJ.busWb (a++, '0');
3322: }
3323: XEiJ.busWb (a, '\0');
3324: XEiJ.regRn[0] = e + 1;
3325: }
3326:
3327:
3328:
3329:
3330:
3331:
3332:
3333:
3334:
3335:
3336:
3337:
3338:
3339:
3340:
3341:
3342:
3343:
3344:
3345:
3346:
3347:
3348:
3349:
3350:
3351:
3352:
3353:
3354:
3355:
3356:
3357:
3358:
3359:
3360:
3361:
3362:
3363:
3364:
3365:
3366:
3367: public static void fpkFCVT () throws M68kException {
3368: fpkFCVTSub ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
3369: }
3370: public static void fpkFCVTSub (long l) throws M68kException {
3371: int len2 = Math.max (0, XEiJ.regRn[2]);
3372: int a = XEiJ.regRn[8];
3373:
3374:
3375: if (0L <= l) {
3376: XEiJ.regRn[1] = 0;
3377: } else {
3378: XEiJ.regRn[1] = 1;
3379: l &= 0x7fffffffffffffffL;
3380: }
3381: double x = Double.longBitsToDouble (l);
3382: int e = (int) (l >>> 52) - 1023;
3383: l &= 0x000fffffffffffffL;
3384: if (e == -1023) {
3385: if (l == 0L) {
3386:
3387: while (len2-- > 0) {
3388: XEiJ.busWb (a++, '0');
3389: }
3390: XEiJ.busWb (a, '\0');
3391: XEiJ.regRn[0] = 0;
3392: return;
3393: }
3394: e -= Long.numberOfLeadingZeros (l) - 12;
3395: } else if (e == 1024) {
3396: XEiJ.busWb (a++, '#');
3397: if (l == 0L) {
3398: XEiJ.busWb (a++, 'I');
3399: XEiJ.busWb (a++, 'N');
3400: XEiJ.busWb (a++, 'F');
3401: } else {
3402: XEiJ.busWb (a++, 'N');
3403: XEiJ.busWb (a++, 'A');
3404: XEiJ.busWb (a++, 'N');
3405: }
3406: XEiJ.busWb (a, '\0');
3407: XEiJ.regRn[0] = 4;
3408: return;
3409: }
3410:
3411:
3412: e = (int) Math.floor ((double) e * 0.30102999566398119521373889472);
3413:
3414:
3415:
3416:
3417: if (0 < e) {
3418: x *= FPK_TEN_M16QR[e & 15];
3419: if (16 <= e) {
3420: x *= FPK_TEN_M16QR[16 + (e >> 4 & 15)];
3421: if (256 <= e) {
3422: x *= FPK_TEN_M16QR[33];
3423: }
3424: }
3425: } else if (e < 0) {
3426: x *= FPK_TEN_P16QR[-e & 15];
3427: if (e <= -16) {
3428: x *= FPK_TEN_P16QR[16 + (-e >> 4 & 15)];
3429: if (e <= -256) {
3430: x *= FPK_TEN_P16QR[33];
3431: }
3432: }
3433: }
3434:
3435:
3436: int[] w = new int[18];
3437: {
3438: int d = (int) x;
3439: int t = XEiJ.FMT_BCD4[d];
3440: w[0] = t >> 4;
3441: w[1] = t & 15;
3442: for (int i = 2; i < 18; i += 4) {
3443:
3444:
3445:
3446: double xh = x * 0x8000001p0;
3447: xh += x - xh;
3448: x = (xh - (double) d) * 10000.0 + (x - xh) * 10000.0;
3449: d = (int) x;
3450: t = XEiJ.FMT_BCD4[d];
3451: w[i ] = t >> 12;
3452: w[i + 1] = t >> 8 & 15;
3453: w[i + 2] = t >> 4 & 15;
3454: w[i + 3] = t & 15;
3455: }
3456: }
3457:
3458:
3459: int h = w[0] != 0 ? 0 : w[1] != 0 ? 1 : 2;
3460:
3461: int o = h + 14;
3462: if (5 <= w[o]) {
3463: int i = o;
3464: while (10 <= ++w[--i]) {
3465: w[i] = 0;
3466: }
3467: if (i < h) {
3468: h--;
3469: o--;
3470: }
3471: }
3472:
3473:
3474: e -= h - 1;
3475:
3476:
3477:
3478: int s = h + e + 1 + len2;
3479: if (s < o) {
3480: o = s;
3481: if (0 <= o && 5 <= w[o]) {
3482: int i = o;
3483: while (10 <= ++w[--i]) {
3484: w[i] = 0;
3485: }
3486: if (i < h) {
3487: h--;
3488: o--;
3489: e++;
3490: }
3491: }
3492: }
3493:
3494: while (h < o) {
3495: XEiJ.busWb (a++, '0' + w[h++]);
3496: }
3497: while (h++ < s) {
3498: XEiJ.busWb (a++, '0');
3499: }
3500: XEiJ.busWb (a, '\0');
3501: XEiJ.regRn[0] = e + 1;
3502: }
3503:
3504:
3505:
3506:
3507:
3508:
3509:
3510:
3511:
3512:
3513:
3514:
3515:
3516:
3517:
3518:
3519:
3520:
3521:
3522:
3523:
3524:
3525:
3526:
3527:
3528:
3529:
3530:
3531:
3532:
3533:
3534:
3535:
3536:
3537:
3538:
3539:
3540:
3541:
3542:
3543:
3544:
3545:
3546:
3547:
3548:
3549:
3550:
3551: public static void fpkGCVT () throws M68kException {
3552: fpkGCVTSub ((long) XEiJ.regRn[0] << 32 | 0xffffffffL & XEiJ.regRn[1]);
3553: }
3554: public static void fpkGCVTSub (long l) throws M68kException {
3555: int len3 = XEiJ.regRn[2];
3556: int a = XEiJ.regRn[8];
3557: if (len3 <= 0) {
3558: XEiJ.busWb (a, '\0');
3559: return;
3560: }
3561:
3562:
3563: if (l < 0L) {
3564: XEiJ.busWb (a++, '-');
3565: l &= 0x7fffffffffffffffL;
3566: }
3567: double x = Double.longBitsToDouble (l);
3568: int e = (int) (l >>> 52) - 1023;
3569: l &= 0x000fffffffffffffL;
3570: if (e == -1023) {
3571: if (l == 0L) {
3572: XEiJ.busWb (a++, '0');
3573: XEiJ.busWb (a++, '.');
3574: XEiJ.busWb (a, '\0');
3575: XEiJ.regRn[8] = a;
3576: return;
3577: }
3578: e -= Long.numberOfLeadingZeros (l) - 12;
3579: } else if (e == 1024) {
3580: XEiJ.busWb (a++, '#');
3581: if (l == 0L) {
3582: XEiJ.busWb (a++, 'I');
3583: XEiJ.busWb (a++, 'N');
3584: XEiJ.busWb (a++, 'F');
3585: } else {
3586: XEiJ.busWb (a++, 'N');
3587: XEiJ.busWb (a++, 'A');
3588: XEiJ.busWb (a++, 'N');
3589: }
3590: XEiJ.busWb (a, '\0');
3591: XEiJ.regRn[8] = a;
3592: return;
3593: }
3594:
3595:
3596: e = (int) Math.floor ((double) e * 0.30102999566398119521373889472);
3597:
3598:
3599:
3600:
3601: if (0 < e) {
3602: x *= FPK_TEN_M16QR[e & 15];
3603: if (16 <= e) {
3604: x *= FPK_TEN_M16QR[16 + (e >> 4 & 15)];
3605: if (256 <= e) {
3606: x *= FPK_TEN_M16QR[33];
3607: }
3608: }
3609: } else if (e < 0) {
3610: x *= FPK_TEN_P16QR[-e & 15];
3611: if (e <= -16) {
3612: x *= FPK_TEN_P16QR[16 + (-e >> 4 & 15)];
3613: if (e <= -256) {
3614: x *= FPK_TEN_P16QR[33];
3615: }
3616: }
3617: }
3618:
3619:
3620: int[] w = new int[18];
3621: {
3622: int d = (int) x;
3623: int t = XEiJ.FMT_BCD4[d];
3624: w[0] = t >> 4;
3625: w[1] = t & 15;
3626: for (int i = 2; i < 18; i += 4) {
3627:
3628:
3629:
3630: double xh = x * 0x8000001p0;
3631: xh += x - xh;
3632: x = (xh - (double) d) * 10000.0 + (x - xh) * 10000.0;
3633: d = (int) x;
3634: t = XEiJ.FMT_BCD4[d];
3635: w[i ] = t >> 12;
3636: w[i + 1] = t >> 8 & 15;
3637: w[i + 2] = t >> 4 & 15;
3638: w[i + 3] = t & 15;
3639: }
3640: }
3641:
3642:
3643: int h = w[0] != 0 ? 0 : w[1] != 0 ? 1 : 2;
3644:
3645: int o = h + 14;
3646: if (5 <= w[o]) {
3647: int i = o;
3648: while (10 <= ++w[--i]) {
3649: w[i] = 0;
3650: }
3651: if (i < h) {
3652: h--;
3653: o--;
3654: }
3655: }
3656:
3657:
3658: e -= h - 1;
3659:
3660:
3661:
3662: int s = h + len3;
3663: if (s < o) {
3664: o = s;
3665: if (0 <= o && 5 <= w[o]) {
3666: int i = o;
3667: while (10 <= ++w[--i]) {
3668: w[i] = 0;
3669: }
3670: if (i < h) {
3671: h--;
3672: o--;
3673: e++;
3674: }
3675: }
3676: }
3677:
3678:
3679: while (w[o - 1] == 0) {
3680: o--;
3681: }
3682:
3683: if (0 <= e && e < len3) {
3684: for (; 0 <= e && h < o; e--) {
3685: XEiJ.busWb (a++, '0' + w[h++]);
3686: }
3687: for (; 0 <= e; e--) {
3688: XEiJ.busWb (a++, '0');
3689: }
3690: XEiJ.busWb (a++, '.');
3691: while (h < o) {
3692: XEiJ.busWb (a++, '0' + w[h++]);
3693: }
3694: } else if (-4 <= e && e < 0) {
3695: XEiJ.busWb (a++, '0');
3696: XEiJ.busWb (a++, '.');
3697: while (++e < 0) {
3698: XEiJ.busWb (a++, '0');
3699: }
3700: while (h < o) {
3701: XEiJ.busWb (a++, '0' + w[h++]);
3702: }
3703: } else {
3704: XEiJ.busWb (a++, '0' + w[h++]);
3705: XEiJ.busWb (a++, '.');
3706: while (h < o) {
3707: XEiJ.busWb (a++, '0' + w[h++]);
3708: }
3709: XEiJ.busWb (a++, 'E');
3710: if (0 <= e) {
3711: XEiJ.busWb (a++, '+');
3712: } else {
3713: XEiJ.busWb (a++, '-');
3714: e = -e;
3715: }
3716: e = XEiJ.FMT_BCD4[e];
3717: XEiJ.busWb (a++, '0' + (e >> 8 ));
3718: XEiJ.busWb (a++, '0' + (e >> 4 & 15));
3719: XEiJ.busWb (a++, '0' + (e & 15));
3720: }
3721: XEiJ.busWb (a, '\0');
3722: XEiJ.regRn[8] = a;
3723: }
3724:
3725:
3726:
3727:
3728:
3729:
3730:
3731:
3732:
3733:
3734:
3735: public static void fpkFVAL () throws M68kException {
3736: int a = XEiJ.regRn[8];
3737:
3738: int c = XEiJ.busRbs (a++);
3739: while (c == ' ' || c == '\t') {
3740: c = XEiJ.busRbs (a++);
3741: }
3742: if (c == '&') {
3743: c = XEiJ.busRbs (a++) & 0xdf;
3744: XEiJ.regRn[8] = a;
3745: if (c == 'B') {
3746: fpkSTOB ();
3747: fpkLTOF ();
3748: } else if (c == 'O') {
3749: fpkSTOO ();
3750: fpkLTOF ();
3751: } else if (c == 'H') {
3752: fpkSTOH ();
3753: fpkLTOF ();
3754: } else {
3755: XEiJ.regCCR = XEiJ.REG_CCR_N | XEiJ.REG_CCR_C;
3756: }
3757: } else {
3758: fpkSTOF ();
3759: }
3760: }
3761:
3762:
3763:
3764:
3765:
3766:
3767:
3768:
3769:
3770:
3771:
3772:
3773:
3774:
3775:
3776:
3777:
3778:
3779: public static void fpkFUSING () throws M68kException {
3780: fpkUSINGSub (Double.doubleToLongBits ((double) Float.intBitsToFloat (XEiJ.regRn[0])));
3781: }
3782:
3783:
3784:
3785:
3786:
3787:
3788:
3789:
3790:
3791:
3792:
3793: public static void fpkSTOF () throws M68kException {
3794: int h = Float.floatToIntBits ((float) fpkSTODSub ());
3795: if (FPK_FPCP_NAN && h == 0x7fc00000) {
3796: h = 0x7fffffff;
3797: }
3798: XEiJ.regRn[0] = h;
3799: }
3800:
3801:
3802:
3803:
3804:
3805:
3806:
3807:
3808: public static void fpkFTOS () throws M68kException {
3809: fpkDTOSSub (Double.doubleToLongBits ((double) Float.intBitsToFloat (XEiJ.regRn[0])));
3810: }
3811:
3812:
3813:
3814:
3815:
3816:
3817:
3818:
3819:
3820:
3821:
3822: public static void fpkFECVT () throws M68kException {
3823: fpkECVTSub (Double.doubleToLongBits ((double) Float.intBitsToFloat (XEiJ.regRn[0])));
3824: }
3825:
3826:
3827:
3828:
3829:
3830:
3831:
3832:
3833:
3834:
3835: public static void fpkFFCVT () throws M68kException {
3836: fpkFCVTSub (Double.doubleToLongBits ((double) Float.intBitsToFloat (XEiJ.regRn[0])));
3837: }
3838:
3839:
3840:
3841:
3842:
3843:
3844:
3845:
3846:
3847: public static void fpkFGCVT () throws M68kException {
3848: fpkGCVTSub (Double.doubleToLongBits ((double) Float.intBitsToFloat (XEiJ.regRn[0])));
3849: }
3850:
3851:
3852:
3853:
3854:
3855:
3856:
3857:
3858: public static void fpkCLMUL () throws M68kException {
3859: int a7 = XEiJ.regRn[15];
3860: long l = (long) XEiJ.busRls (a7) * (long) XEiJ.busRls (a7 + 4);
3861: int h = (int) l;
3862: XEiJ.busWl (a7, h);
3863: XEiJ.regCCR = (long) h == l ? 0 : XEiJ.REG_CCR_C;
3864: }
3865:
3866:
3867:
3868:
3869:
3870:
3871:
3872:
3873: public static void fpkCLDIV () throws M68kException {
3874: int a7 = XEiJ.regRn[15];
3875: int h = XEiJ.busRls (a7 + 4);
3876: if (h == 0) {
3877:
3878: XEiJ.regCCR = XEiJ.REG_CCR_C;
3879: } else {
3880: XEiJ.busWl (a7, XEiJ.busRls (a7) / h);
3881: XEiJ.regCCR = 0;
3882: }
3883: }
3884:
3885:
3886:
3887:
3888:
3889:
3890:
3891:
3892: public static void fpkCLMOD () throws M68kException {
3893: int a7 = XEiJ.regRn[15];
3894: int h = XEiJ.busRls (a7 + 4);
3895: if (h == 0) {
3896:
3897: XEiJ.regCCR = XEiJ.REG_CCR_C;
3898: } else {
3899: XEiJ.busWl (a7, XEiJ.busRls (a7) % h);
3900: XEiJ.regCCR = 0;
3901: }
3902: }
3903:
3904:
3905:
3906:
3907:
3908:
3909:
3910:
3911: public static void fpkCUMUL () throws M68kException {
3912: int a7 = XEiJ.regRn[15];
3913: long l = (0xffffffffL & XEiJ.busRls (a7)) * (0xffffffffL & XEiJ.busRls (a7 + 4));
3914: int h = (int) l;
3915: XEiJ.busWl (a7, h);
3916: XEiJ.regCCR = (0xffffffffL & h) == l ? 0 : XEiJ.REG_CCR_C;
3917: }
3918:
3919:
3920:
3921:
3922:
3923:
3924:
3925:
3926: public static void fpkCUDIV () throws M68kException {
3927: int a7 = XEiJ.regRn[15];
3928: int h = XEiJ.busRls (a7 + 4);
3929: if (h == 0) {
3930:
3931: XEiJ.regCCR = XEiJ.REG_CCR_C;
3932: } else {
3933: XEiJ.busWl (a7, (int) ((0xffffffffL & XEiJ.busRls (a7)) / (0xffffffffL & h)));
3934: XEiJ.regCCR = 0;
3935: }
3936: }
3937:
3938:
3939:
3940:
3941:
3942:
3943:
3944:
3945: public static void fpkCUMOD () throws M68kException {
3946: int a7 = XEiJ.regRn[15];
3947: int h = XEiJ.busRls (a7 + 4);
3948: if (h == 0) {
3949:
3950: XEiJ.regCCR = XEiJ.REG_CCR_C;
3951: } else {
3952: XEiJ.busWl (a7, (int) ((0xffffffffL & XEiJ.busRls (a7)) % (0xffffffffL & h)));
3953: XEiJ.regCCR = 0;
3954: }
3955: }
3956:
3957:
3958:
3959:
3960:
3961:
3962: public static void fpkCLTOD () throws M68kException {
3963:
3964: int a7 = XEiJ.regRn[15];
3965: long l = Double.doubleToLongBits ((double) XEiJ.busRls (a7));
3966: XEiJ.busWl (a7, (int) (l >>> 32));
3967: XEiJ.busWl (a7 + 4, (int) l);
3968: }
3969:
3970:
3971:
3972:
3973:
3974:
3975:
3976: public static void fpkCDTOL () throws M68kException {
3977:
3978: int a7 = XEiJ.regRn[15];
3979: double d = Double.longBitsToDouble ((long) XEiJ.busRls (a7) << 32 | 0xffffffffL & XEiJ.busRls (a7 + 4));
3980: XEiJ.busWl (a7, (int) d);
3981: XEiJ.regCCR = (double) Integer.MIN_VALUE - 1.0 < d && d < (double) Integer.MAX_VALUE + 1.0 ? 0 : XEiJ.REG_CCR_C;
3982: }
3983:
3984:
3985:
3986:
3987:
3988:
3989: public static void fpkCLTOF () throws M68kException {
3990:
3991: int a7 = XEiJ.regRn[15];
3992: XEiJ.busWl (a7, Float.floatToIntBits ((float) XEiJ.busRls (a7)));
3993: }
3994:
3995:
3996:
3997:
3998:
3999:
4000:
4001: public static void fpkCFTOL () throws M68kException {
4002:
4003: int a7 = XEiJ.regRn[15];
4004: float f = Float.intBitsToFloat (XEiJ.busRls (a7));
4005: XEiJ.busWl (a7, (int) f);
4006: XEiJ.regCCR = (float) Integer.MIN_VALUE - 1.0F < f && f < (float) Integer.MAX_VALUE + 1.0F ? 0 : XEiJ.REG_CCR_C;
4007: }
4008:
4009:
4010:
4011:
4012:
4013:
4014: public static void fpkCFTOD () throws M68kException {
4015:
4016: int a7 = XEiJ.regRn[15];
4017: long l = Double.doubleToLongBits ((double) Float.intBitsToFloat (XEiJ.busRls (a7)));
4018: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
4019: l = 0x7fffffffffffffffL;
4020: }
4021: XEiJ.busWl (a7, (int) (l >>> 32));
4022: XEiJ.busWl (a7 + 4, (int) l);
4023: }
4024:
4025:
4026:
4027:
4028:
4029:
4030:
4031: public static void fpkCDTOF () throws M68kException {
4032:
4033: int a7 = XEiJ.regRn[15];
4034: double d = Double.longBitsToDouble ((long) XEiJ.busRls (a7) << 32 | 0xffffffffL & XEiJ.busRls (a7 + 4));
4035: int h = Float.floatToIntBits ((float) d);
4036: if (FPK_FPCP_NAN && h == 0x7fc00000) {
4037: h = 0x7fffffff;
4038: }
4039: XEiJ.busWl (a7, h);
4040: XEiJ.regCCR = (Double.isNaN (d) || Double.isInfinite (d) ||
4041: Math.abs (d) < (double) Float.MAX_VALUE + 0.5 * (double) Math.ulp (Float.MAX_VALUE) ? 0 : XEiJ.REG_CCR_C);
4042: }
4043:
4044:
4045:
4046:
4047:
4048:
4049:
4050:
4051: public static void fpkCDCMP () throws M68kException {
4052:
4053: int a7 = XEiJ.regRn[15];
4054: double xd = Double.longBitsToDouble ((long) XEiJ.busRls (a7) << 32 | 0xffffffffL & XEiJ.busRls (a7 + 4));
4055: double yd = Double.longBitsToDouble ((long) XEiJ.busRls (a7 + 8) << 32 | 0xffffffffL & XEiJ.busRls (a7 + 12));
4056: XEiJ.regCCR = xd < yd ? XEiJ.REG_CCR_N | XEiJ.REG_CCR_C : xd == yd ? XEiJ.REG_CCR_Z : 0;
4057: }
4058:
4059:
4060:
4061:
4062:
4063:
4064:
4065:
4066: public static void fpkCDADD () throws M68kException {
4067:
4068: int a7 = XEiJ.regRn[15];
4069: double xd = Double.longBitsToDouble ((long) XEiJ.busRls (a7) << 32 | 0xffffffffL & XEiJ.busRls (a7 + 4));
4070: double yd = Double.longBitsToDouble ((long) XEiJ.busRls (a7 + 8) << 32 | 0xffffffffL & XEiJ.busRls (a7 + 12));
4071: double zd = xd + yd;
4072: long l = Double.doubleToLongBits (zd);
4073: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
4074: l = 0x7fffffffffffffffL;
4075: }
4076: XEiJ.busWl (a7, (int) (l >>> 32));
4077: XEiJ.busWl (a7 + 4, (int) l);
4078: XEiJ.regCCR = (Double.isNaN (xd) || Double.isNaN (yd) ? 0 :
4079: Double.isNaN (zd) ? XEiJ.REG_CCR_C :
4080: Double.isInfinite (xd) || Double.isInfinite (yd) ? 0 :
4081: Double.isInfinite (zd) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C :
4082: 0);
4083: }
4084:
4085:
4086:
4087:
4088:
4089:
4090:
4091:
4092: public static void fpkCDSUB () throws M68kException {
4093:
4094: int a7 = XEiJ.regRn[15];
4095: double xd = Double.longBitsToDouble ((long) XEiJ.busRls (a7) << 32 | 0xffffffffL & XEiJ.busRls (a7 + 4));
4096: double yd = Double.longBitsToDouble ((long) XEiJ.busRls (a7 + 8) << 32 | 0xffffffffL & XEiJ.busRls (a7 + 12));
4097: double zd = xd - yd;
4098: long l = Double.doubleToLongBits (zd);
4099: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
4100: l = 0x7fffffffffffffffL;
4101: }
4102: XEiJ.busWl (a7, (int) (l >>> 32));
4103: XEiJ.busWl (a7 + 4, (int) l);
4104: XEiJ.regCCR = (Double.isNaN (xd) || Double.isNaN (yd) ? 0 :
4105: Double.isNaN (zd) ? XEiJ.REG_CCR_C :
4106: Double.isInfinite (xd) || Double.isInfinite (yd) ? 0 :
4107: Double.isInfinite (zd) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C :
4108: 0);
4109: }
4110:
4111:
4112:
4113:
4114:
4115:
4116:
4117:
4118: public static void fpkCDMUL () throws M68kException {
4119:
4120: int a7 = XEiJ.regRn[15];
4121: double xd = Double.longBitsToDouble ((long) XEiJ.busRls (a7) << 32 | 0xffffffffL & XEiJ.busRls (a7 + 4));
4122: double yd = Double.longBitsToDouble ((long) XEiJ.busRls (a7 + 8) << 32 | 0xffffffffL & XEiJ.busRls (a7 + 12));
4123: double zd = xd * yd;
4124: long l = Double.doubleToLongBits (zd);
4125: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
4126: l = 0x7fffffffffffffffL;
4127: }
4128: XEiJ.busWl (a7, (int) (l >>> 32));
4129: XEiJ.busWl (a7 + 4, (int) l);
4130: XEiJ.regCCR = (Double.isNaN (xd) || Double.isNaN (yd) ? 0 :
4131: Double.isNaN (zd) ? XEiJ.REG_CCR_C :
4132: Double.isInfinite (xd) || Double.isInfinite (yd) ? 0 :
4133: Double.isInfinite (zd) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C :
4134: 0);
4135: }
4136:
4137:
4138:
4139:
4140:
4141:
4142:
4143:
4144: public static void fpkCDDIV () throws M68kException {
4145:
4146: int a7 = XEiJ.regRn[15];
4147: double xd = Double.longBitsToDouble ((long) XEiJ.busRls (a7) << 32 | 0xffffffffL & XEiJ.busRls (a7 + 4));
4148: double yd = Double.longBitsToDouble ((long) XEiJ.busRls (a7 + 8) << 32 | 0xffffffffL & XEiJ.busRls (a7 + 12));
4149: double zd = xd / yd;
4150: long l = Double.doubleToLongBits (zd);
4151: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
4152: l = 0x7fffffffffffffffL;
4153: }
4154: XEiJ.busWl (a7, (int) (l >>> 32));
4155: XEiJ.busWl (a7 + 4, (int) l);
4156: XEiJ.regCCR = (Double.isNaN (xd) || Double.isNaN (yd) ? 0 :
4157: Double.isNaN (zd) ? XEiJ.REG_CCR_C :
4158: Double.isInfinite (xd) || Double.isInfinite (yd) ? 0 :
4159: yd == 0.0 ? XEiJ.REG_CCR_Z | XEiJ.REG_CCR_C :
4160: Double.isInfinite (zd) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C :
4161: 0);
4162: }
4163:
4164:
4165:
4166:
4167:
4168:
4169:
4170:
4171: public static void fpkCDMOD () throws M68kException {
4172:
4173: int a7 = XEiJ.regRn[15];
4174: double xd = Double.longBitsToDouble ((long) XEiJ.busRls (a7) << 32 | 0xffffffffL & XEiJ.busRls (a7 + 4));
4175: double yd = Double.longBitsToDouble ((long) XEiJ.busRls (a7 + 8) << 32 | 0xffffffffL & XEiJ.busRls (a7 + 12));
4176: double zd = xd % yd;
4177: long l = Double.doubleToLongBits (zd);
4178: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
4179: l = 0x7fffffffffffffffL;
4180: }
4181: XEiJ.busWl (a7, (int) (l >>> 32));
4182: XEiJ.busWl (a7 + 4, (int) l);
4183: XEiJ.regCCR = (Double.isNaN (xd) || Double.isNaN (yd) ? 0 :
4184: yd == 0.0 ? XEiJ.REG_CCR_Z | XEiJ.REG_CCR_C :
4185: Double.isNaN (zd) ? XEiJ.REG_CCR_C :
4186: Double.isInfinite (xd) || Double.isInfinite (yd) ? 0 :
4187: Double.isInfinite (zd) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C :
4188: 0);
4189: }
4190:
4191:
4192:
4193:
4194:
4195:
4196:
4197:
4198: public static void fpkCFCMP () throws M68kException {
4199:
4200: int a7 = XEiJ.regRn[15];
4201: float xf = Float.intBitsToFloat (XEiJ.busRls (a7));
4202: float yf = Float.intBitsToFloat (XEiJ.busRls (a7 + 4));
4203: XEiJ.regCCR = xf < yf ? XEiJ.REG_CCR_N | XEiJ.REG_CCR_C : xf == yf ? XEiJ.REG_CCR_Z : 0;
4204: }
4205:
4206:
4207:
4208:
4209:
4210:
4211:
4212:
4213: public static void fpkCFADD () throws M68kException {
4214:
4215: int a7 = XEiJ.regRn[15];
4216: float xf = Float.intBitsToFloat (XEiJ.busRls (a7));
4217: float yf = Float.intBitsToFloat (XEiJ.busRls (a7 + 4));
4218: float zf = xf + yf;
4219: int h = Float.floatToIntBits (zf);
4220: if (FPK_FPCP_NAN && h == 0x7fc00000) {
4221: h = 0x7fffffff;
4222: }
4223: XEiJ.busWl (a7, h);
4224: XEiJ.regCCR = (Float.isNaN (xf) || Float.isNaN (yf) ? 0 :
4225: Float.isNaN (zf) ? XEiJ.REG_CCR_C :
4226: Float.isInfinite (xf) || Float.isInfinite (yf) ? 0 :
4227: Float.isInfinite (zf) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C :
4228: 0);
4229: }
4230:
4231:
4232:
4233:
4234:
4235:
4236:
4237:
4238: public static void fpkCFSUB () throws M68kException {
4239:
4240: int a7 = XEiJ.regRn[15];
4241: float xf = Float.intBitsToFloat (XEiJ.busRls (a7));
4242: float yf = Float.intBitsToFloat (XEiJ.busRls (a7 + 4));
4243: float zf = xf - yf;
4244: int h = Float.floatToIntBits (zf);
4245: if (FPK_FPCP_NAN && h == 0x7fc00000) {
4246: h = 0x7fffffff;
4247: }
4248: XEiJ.busWl (a7, h);
4249: XEiJ.regCCR = (Float.isNaN (xf) || Float.isNaN (yf) ? 0 :
4250: Float.isNaN (zf) ? XEiJ.REG_CCR_C :
4251: Float.isInfinite (xf) || Float.isInfinite (yf) ? 0 :
4252: Float.isInfinite (zf) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C :
4253: 0);
4254: }
4255:
4256:
4257:
4258:
4259:
4260:
4261:
4262:
4263: public static void fpkCFMUL () throws M68kException {
4264:
4265: int a7 = XEiJ.regRn[15];
4266: float xf = Float.intBitsToFloat (XEiJ.busRls (a7));
4267: float yf = Float.intBitsToFloat (XEiJ.busRls (a7 + 4));
4268: float zf = xf * yf;
4269: int h = Float.floatToIntBits (zf);
4270: if (FPK_FPCP_NAN && h == 0x7fc00000) {
4271: h = 0x7fffffff;
4272: }
4273: XEiJ.busWl (a7, h);
4274: XEiJ.regCCR = (Float.isNaN (xf) || Float.isNaN (yf) ? 0 :
4275: Float.isNaN (zf) ? XEiJ.REG_CCR_C :
4276: Float.isInfinite (xf) || Float.isInfinite (yf) ? 0 :
4277: Float.isInfinite (zf) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C :
4278: 0);
4279: }
4280:
4281:
4282:
4283:
4284:
4285:
4286:
4287:
4288: public static void fpkCFDIV () throws M68kException {
4289:
4290: int a7 = XEiJ.regRn[15];
4291: float xf = Float.intBitsToFloat (XEiJ.busRls (a7));
4292: float yf = Float.intBitsToFloat (XEiJ.busRls (a7 + 4));
4293: float zf = xf / yf;
4294: int h = Float.floatToIntBits (zf);
4295: if (FPK_FPCP_NAN && h == 0x7fc00000) {
4296: h = 0x7fffffff;
4297: }
4298: XEiJ.busWl (a7, h);
4299: XEiJ.regCCR = (Float.isNaN (xf) || Float.isNaN (yf) ? 0 :
4300: Float.isNaN (zf) ? XEiJ.REG_CCR_C :
4301: Float.isInfinite (xf) || Float.isInfinite (yf) ? 0 :
4302: yf == 0.0F ? XEiJ.REG_CCR_Z | XEiJ.REG_CCR_C :
4303: Float.isInfinite (zf) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C :
4304: 0);
4305: }
4306:
4307:
4308:
4309:
4310:
4311:
4312:
4313:
4314: public static void fpkCFMOD () throws M68kException {
4315:
4316: int a7 = XEiJ.regRn[15];
4317: float xf = Float.intBitsToFloat (XEiJ.busRls (a7));
4318: float yf = Float.intBitsToFloat (XEiJ.busRls (a7 + 4));
4319: float zf = xf % yf;
4320: int h = Float.floatToIntBits (zf);
4321: if (FPK_FPCP_NAN && h == 0x7fc00000) {
4322: h = 0x7fffffff;
4323: }
4324: XEiJ.busWl (a7, h);
4325: XEiJ.regCCR = (Float.isNaN (xf) || Float.isNaN (yf) ? 0 :
4326: yf == 0.0F ? XEiJ.REG_CCR_Z | XEiJ.REG_CCR_C :
4327: Float.isNaN (zf) ? XEiJ.REG_CCR_C :
4328: Float.isInfinite (xf) || Float.isInfinite (yf) ? 0 :
4329: Float.isInfinite (zf) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C :
4330: 0);
4331: }
4332:
4333:
4334:
4335:
4336:
4337:
4338:
4339: public static void fpkCDTST () throws M68kException {
4340: if (true) {
4341: int a7 = XEiJ.regRn[15];
4342: long l = (long) XEiJ.busRls (a7) << 32 | 0xffffffffL & XEiJ.busRls (a7 + 4);
4343: XEiJ.regCCR = l << 1 == 0L ? XEiJ.REG_CCR_Z : 0L <= l ? 0 : XEiJ.REG_CCR_N;
4344: } else {
4345:
4346: int a7 = XEiJ.regRn[15];
4347: double d = Double.longBitsToDouble ((long) XEiJ.busRls (a7) << 32 | 0xffffffffL & XEiJ.busRls (a7 + 4));
4348: XEiJ.regCCR = d < 0.0 ? XEiJ.REG_CCR_N : d == 0.0 ? XEiJ.REG_CCR_Z : 0;
4349: }
4350: }
4351:
4352:
4353:
4354:
4355:
4356:
4357:
4358: public static void fpkCFTST () throws M68kException {
4359:
4360: if (true) {
4361: int h = XEiJ.busRls (XEiJ.regRn[15]);
4362: XEiJ.regCCR = h << 1 == 0 ? XEiJ.REG_CCR_Z : 0 <= h ? 0 : XEiJ.REG_CCR_N;
4363: } else {
4364:
4365: float f = Float.intBitsToFloat (XEiJ.busRls (XEiJ.regRn[15]));
4366: XEiJ.regCCR = f < 0.0F ? XEiJ.REG_CCR_N : f == 0.0F ? XEiJ.REG_CCR_Z : 0;
4367: }
4368: }
4369:
4370:
4371:
4372:
4373:
4374:
4375: public static void fpkCDINC () throws M68kException {
4376:
4377: int a7 = XEiJ.regRn[15];
4378: double xd = Double.longBitsToDouble ((long) XEiJ.busRls (a7) << 32 | 0xffffffffL & XEiJ.busRls (a7 + 4));
4379: double zd = xd + 1.0;
4380: long l = Double.doubleToLongBits (zd);
4381: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
4382: l = 0x7fffffffffffffffL;
4383: }
4384: XEiJ.busWl (a7, (int) (l >>> 32));
4385: XEiJ.busWl (a7 + 4, (int) l);
4386: XEiJ.regCCR = Double.isInfinite (zd) && !Double.isInfinite (xd) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C : 0;
4387: }
4388:
4389:
4390:
4391:
4392:
4393:
4394: public static void fpkCFINC () throws M68kException {
4395:
4396: int a7 = XEiJ.regRn[15];
4397: float xf = Float.intBitsToFloat (XEiJ.busRls (a7));
4398: float zf = xf + 1.0F;
4399: int h = Float.floatToIntBits (zf);
4400: if (FPK_FPCP_NAN && h == 0x7fc00000) {
4401: h = 0x7fffffff;
4402: }
4403: XEiJ.busWl (a7, h);
4404: XEiJ.regCCR = Double.isInfinite (zf) && !Float.isInfinite (xf) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C : 0;
4405: }
4406:
4407:
4408:
4409:
4410:
4411:
4412: public static void fpkCDDEC () throws M68kException {
4413:
4414: int a7 = XEiJ.regRn[15];
4415: double xd = Double.longBitsToDouble ((long) XEiJ.busRls (a7) << 32 | 0xffffffffL & XEiJ.busRls (a7 + 4));
4416: double zd = xd - 1.0;
4417: long l = Double.doubleToLongBits (zd);
4418: if (FPK_FPCP_NAN && l == 0x7ff8000000000000L) {
4419: l = 0x7fffffffffffffffL;
4420: }
4421: XEiJ.busWl (a7, (int) (l >>> 32));
4422: XEiJ.busWl (a7 + 4, (int) l);
4423: XEiJ.regCCR = Double.isInfinite (zd) && !Double.isInfinite (xd) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C : 0;
4424: }
4425:
4426:
4427:
4428:
4429:
4430:
4431: public static void fpkCFDEC () throws M68kException {
4432:
4433: int a7 = XEiJ.regRn[15];
4434: float xf = Float.intBitsToFloat (XEiJ.busRls (a7));
4435: float zf = xf - 1.0F;
4436: int h = Float.floatToIntBits (zf);
4437: if (FPK_FPCP_NAN && h == 0x7fc00000) {
4438: h = 0x7fffffff;
4439: }
4440: XEiJ.busWl (a7, h);
4441: XEiJ.regCCR = Double.isInfinite (zf) && !Float.isInfinite (xf) ? XEiJ.REG_CCR_V | XEiJ.REG_CCR_C : 0;
4442: }
4443:
4444: }
4445:
4446:
4447: