/* Generated with C2C (Cedar To C)*/ /* Copyright (C) 1992 by Xerox Corporation. All rights reserved. */ /* time: February 21, 1992 9:05:08 pm PST */ /* C2C version: October 16, 1990 (native) */ /* ref-counting: off */ /* file: DRealImpl, module: DRealImpl */ /* switches: bcfhklnouw */ #include <cedar/InstallationSupport.h> #include <cedar/CedarExtra.h> static char versionStamp[] = "@(#)mob←version [1187355559,2157231177] DRealImpl"; typedef unsigned word, *ptr; typedef unsigned char byte, *bPt; typedef unsigned short half, *hPt; typedef struct {word f0, f1, f2, f3;} W4; typedef struct {word f0, f1;} W2; typedef W2 *W2Pt; typedef W4 *W4Pt; typedef word (*fPt)(); #define SOURCE(p, l) /* source p, l */ static double fc4 = 1.0; static double fc5 = 10.0; static double fc6 = 9.0; static double fc8 = 0.0; #define BCK(idx, lim) ( ((unsigned) idx) >= ((unsigned) lim) ? (XR←RaiseBoundsFault()) : (idx) ) #define SGNCK(i) ((int) (word) (i) < 0 ? XR←RaiseArithmeticFault(): i ) static void NoName←Q2184(); static void DRealImpl←P0(); static void ComputeMagic←P60(); static void FScale←P120(); static void Round←P180(); static void Fix←P240(); static void Ceiling←P300(); static void Floor←P360(); static void XRound←P420(); static void TenToThe←P480(); static void RealToPair←P540(); static void DebugPrint←P600(); static struct {unsigned f; char r[16];} string1 = {851984, "\257\300\106\305\233\247\300\200\224\274\111\100\164\000\000"}; static struct {unsigned f; char r[16];} string2 = {851984, "\257\300\233\213\041\256\300\330\147\331\041\100\150\000\000"}; static struct {unsigned f; char r[16];} string3 = {851984, "\257\300\325\357\120\064\300\204\001\046\072\100\150\000\000"}; static struct { word f0[16]; word f16; word f17; word f18; word f19; word f20; word f21; word f22; word f23; word f24; word f25; word f26; word f27; word f28; word f29; word f30; word f31; word f32; word f33; word f34; word f35; word f36; word f37[3]; } globalframe = { {0}, (word) DebugPrint←P600, 0, (word) RealToPair←P540, 0, (word) TenToThe←P480, 0, (word) XRound←P420, 0, (word) Floor←P360, 0, (word) Ceiling←P300, 0, (word) Fix←P240, 0, (word) Round←P180, 0, (word) FScale←P120, 0, (word) ComputeMagic←P60, 0, (word) DRealImpl←P0, {0} }; static void NoName←Q2184() { register ptr gf←c0146 = (ptr) &globalframe; word var←c12500; (void) XR←DeclareGlobalFrame((word) "DRealImpl", &globalframe, (word) XR←GetTypeIndexS((word) (&string1)), (word) (( (bPt) gf←c0146)+144) /* var←c11092 */ ); var←c12500 = (word) XR←ImportInterface((word) "DRealSupport", (word) XR←GetTypeIndexS((word) (&string2)), 26); (* (( (ptr) gf←c0146)+38)/* var←c11380 */ ) = var←c12500; (void) XR←ImportProcS(var←c12500, 67633153); (void) XR←ImportProcS(var←c12500, 135006210); var←c12500 = (word) XR←ExportInterface((word) "DReal", (word) XR←GetTypeIndexS((word) (&string3)), 7); (* (( (ptr) gf←c0146)+39)/* var←c12532 */ ) = var←c12500; (void) XR←ExportProcS(var←c12500, (word) (( (bPt) gf←c0146)+128)/* var←c11028 */ , 135004162); (void) XR←ExportProcS(var←c12500, (word) (( (bPt) gf←c0146)+112)/* var←c10964 */ , 134742273); (void) XR←ExportProcS(var←c12500, (word) (( (bPt) gf←c0146)+120)/* var←c10996 */ , 134742529); (void) XR←ExportProcS(var←c12500, (word) (( (bPt) gf←c0146)+104)/* var←c10932 */ , 134742785); (void) XR←ExportProcS(var←c12500, (word) (( (bPt) gf←c0146)+96)/* var←c10900 */ , 134743041); (void) XR←ExportProcS(var←c12500, (word) (( (bPt) gf←c0146)+72)/* var←c10804 */ , 269223426); } static void DRealImpl←P0(formal←c026, formal←c018) word formal←c026; word formal←c018; { register ptr gf←c12564 = (ptr) &globalframe; /* DRealImpl: */ SOURCE(61, 2899) SOURCE(348, 35) (void) ComputeMagic←P60((word) ((( (bPt) gf←c12564)+16)/* magic←v2580 */ )); SOURCE(1809, 38) { W4 var←c11124; W4 result←v10692; W2 a←v10724; a←v10724 = (* (W2Pt) &fc4 ); (void) XR←ExtendedFromDReal((word) &a←v10724, (word) &result←v10692); var←c11124 = result←v10692; (* (W4Pt) (( (ptr) gf←c12564)+8)/* one←v2804 */ ) = var←c11124; }; SOURCE(1849, 39) { W4 var←c11156; W4 result←v10612; W2 a←v10644; a←v10644 = (* (W2Pt) &fc5 ); (void) XR←ExtendedFromDReal((word) &a←v10644, (word) &result←v10612); var←c11156 = result←v10612; (* (W4Pt) (( (ptr) gf←c12564)+12)/* ten←v2832 */ ) = var←c11156; }; } static void ComputeMagic←P60(formal←c041) word formal←c041; { W4 var←c3524; W4 one←v4584; W4 m←v4612; /* ComputeMagic: */ SOURCE(385, 231) SOURCE(430, 38) { W4 result←v10532; W2 a←v10564; a←v10564 = (* (W2Pt) &fc4 ); (void) XR←ExtendedFromDReal((word) &a←v10564, (word) &result←v10532); one←v4584 = result←v10532; }; SOURCE(470, 48) { W4 result←v10452; W2 a←v10484; a←v10484 = (* (W2Pt) &fc6 ); (void) XR←ExtendedFromDReal((word) &a←v10484, (word) &result←v10452); m←v4612 = result←v10452; }; SOURCE(520, 64) lab←L100007: ; if ((m←v4612.f3 != 1)) { } else { goto lab←L100005; }; SOURCE(538, 46) { W4 var←c11284; W4 result←v10104; W4 a←v10136; W4 b←v10164; { W4 result←v9996; W4 a←v10028; W4 b←v10056; a←v10028 = m←v4612; b←v10056 = m←v4612; (void) XR←ExtendedFloatAdd((word) &a←v10028, (word) &b←v10056, (word) &result←v9996); a←v10136 = result←v9996; }; b←v10164 = one←v4584; (void) XR←ExtendedFloatSubtract((word) &a←v10136, (word) &b←v10164, (word) &result←v10104); var←c11284 = result←v10104; m←v4612 = var←c11284; }; goto lab←L100007; lab←L100005: ; SOURCE(595, 8) m←v4612.f3 = 0; SOURCE(605, 11) var←c3524 = m←v4612; /* removed tail goto */ (* (W4Pt) formal←c041 ) = var←c3524; return; } static void FScale←P120(formal←c047, a←v3584, scale←v3612) word formal←c047; W2 a←v3584; word scale←v3612; { register ptr gf←c12596 = (ptr) &globalframe; W2 var←c3656; /* FScale: */ SOURCE(620, 106) SOURCE(687, 39) { W2 var←c11412; { word pd7; pd7 = (* (( (ptr) (* (( (ptr) gf←c12596)+38)/* var←c11380 */ ))+12) ); (void) ( *( (fPt) ((* (ptr) pd7 ))))((word) &var←c11412, a←v3584, scale←v3612, pd7); }; var←c3656 = var←c11412; /* removed tail goto */ }; (* (W2Pt) formal←c047 ) = var←c3656; return; } static void Round←P180(formal←c058, dreal←v3716) word formal←c058; W2 dreal←v3716; { register ptr gf←c12628 = (ptr) &globalframe; W2 var←c3760; word neg←v4656; W4 m←v4684; word chk←v4712; /* Round: */ SOURCE(730, 304) SOURCE(783, 21) neg←v4656 = XR←DRealGtI(&fc8, &dreal←v3716); SOURCE(806, 73) { W4 result←v9888; W4 a←v9920; W4 b←v9948; { W4 result←v10372; W2 a←v10404; XR←DRealAbsI(&a←v10404, &dreal←v3716); (void) XR←ExtendedFromDReal((word) &a←v10404, (word) &result←v10372); a←v9920 = result←v10372; }; b←v9948 = (* (W4Pt) (( (ptr) gf←c12628)+4)/* magic←v2580 */ ); (void) XR←ExtendedFloatAdd((word) &a←v9920, (word) &b←v9948, (word) &result←v9888); m←v4684 = result←v9888; }; SOURCE(881, 82) { word tc9; W2 D10; W2 D11; W2 D12; W2 D13; W2 D14; word idx15; if ( ! XR←EqualWords(&m←v4684, (( (ptr) gf←c12628)+4), 2)) { tc9 = (word) 1; } else { XR←DCardCard(&D12, 2); XR←DCardCard(&D13, 63); XR←DCardPwrI(&D11, &D12, &D13); XR←DCardCard(&D14, (0 == neg←v4656)); XR←DCardSubI(&D10, &D11, &D14); tc9 = (word) XR←DCardGtI((( (ptr) gf←c12628)+6), &D10); }; chk←v4712 = ( idx15 = (word) tc9, BCK(idx15, 1) ); }; SOURCE(965, 69) { W2 D16; if ((0 != neg←v4656)) { XR←DIntNegI(&D16, (( (ptr) &m←v4684)+2)); var←c3760 = D16; } else { var←c3760 = (* (W2Pt) (( (ptr) &m←v4684)+2) ); }; }; /* removed tail goto */ (* (W2Pt) formal←c058 ) = var←c3760; return; } static void Fix←P240(formal←c069, dreal←v3820) word formal←c069; W2 dreal←v3820; { register ptr gf←c12660 = (ptr) &globalframe; W2 var←c3864; word neg←v4776; W4 m←v4804; word chk←v4832; /* Fix: */ SOURCE(1038, 346) SOURCE(1089, 21) neg←v4776 = XR←DRealGtI(&fc8, &dreal←v3820); SOURCE(1112, 73) { W4 result←v9780; W4 a←v9812; W4 b←v9840; { W4 result←v10292; W2 a←v10324; XR←DRealAbsI(&a←v10324, &dreal←v3820); (void) XR←ExtendedFromDReal((word) &a←v10324, (word) &result←v10292); a←v9812 = result←v10292; }; b←v9840 = (* (W4Pt) (( (ptr) gf←c12660)+4)/* magic←v2580 */ ); (void) XR←ExtendedFloatAdd((word) &a←v9812, (word) &b←v9840, (word) &result←v9780); m←v4804 = result←v9780; }; SOURCE(1187, 83) { word tc17; W2 D18; W2 D19; W2 D20; W2 D21; W2 D22; word idx23; if ( ! XR←EqualWords(&m←v4804, (( (ptr) gf←c12660)+4), 2)) { tc17 = (word) 1; } else { XR←DCardCard(&D20, 2); XR←DCardCard(&D21, 63); XR←DCardPwrI(&D19, &D20, &D21); XR←DCardCard(&D22, (0 == neg←v4776)); XR←DCardSubI(&D18, &D19, &D22); tc17 = (word) XR←DCardGtI((( (ptr) gf←c12660)+6), &D18); }; chk←v4832 = ( idx23 = (word) tc17, BCK(idx23, 1) ); }; SOURCE(1272, 41) { W2 D24; W2 x25; XR←DFloatDCardI(&D24, ((( (ptr) &m←v4804)+2))); XR←DRealAbsI(&x25, &dreal←v3820); if (XR←DRealGtI(&D24, &x25)) { SOURCE(1298, 15) { W2 D26; W2 D27; XR←DCardCard(&D27, 1); XR←DCardSubI(&D26, (( (ptr) &m←v4804)+2), &D27); (* (W2Pt) (( (ptr) &m←v4804)+2) ) = D26; }; }; }; SOURCE(1315, 69) { W2 D28; if ((0 != neg←v4776)) { XR←DIntNegI(&D28, (( (ptr) &m←v4804)+2)); var←c3864 = D28; } else { var←c3864 = (* (W2Pt) (( (ptr) &m←v4804)+2) ); }; }; /* removed tail goto */ (* (W2Pt) formal←c069 ) = var←c3864; return; } static void Ceiling←P300(formal←c073, dreal←v3924) word formal←c073; W2 dreal←v3924; { W2 ans←v3968; /* Ceiling: */ SOURCE(1388, 113) SOURCE(1448, 18) (void) Round←P180((word) &ans←v3968, dreal←v3924); SOURCE(1468, 33) { W2 D29; XR←DFloatDIntI(&D29, (&ans←v3968)); if (XR←DRealGtI(&dreal←v3924, &D29)) { SOURCE(1488, 13) { W2 D30; W2 D31; XR←DCardCard(&D31, 1); XR←DCardAddI(&D30, &ans←v3968, &D31); ans←v3968 = D30; }; }; }; /* removed tail goto */ (* (W2Pt) formal←c073 ) = ans←v3968; return; } static void Floor←P360(formal←c077, dreal←v4028) word formal←c077; W2 dreal←v4028; { W2 ans←v4072; /* Floor: */ SOURCE(1507, 111) SOURCE(1565, 18) (void) Round←P180((word) &ans←v4072, dreal←v4028); SOURCE(1585, 33) { W2 D32; XR←DFloatDIntI(&D32, (&ans←v4072)); if (XR←DRealGtI(&D32, &dreal←v4028)) { SOURCE(1605, 13) { W2 D33; W2 D34; XR←DCardCard(&D34, 1); XR←DCardSubI(&D33, &ans←v4072, &D34); ans←v4072 = D33; }; }; }; /* removed tail goto */ (* (W2Pt) formal←c077 ) = ans←v4072; return; } static void XRound←P420(formal←c085, xreal←v4132, neg←v4160) word formal←c085; W4 xreal←v4132; word neg←v4160; { register ptr gf←c12692 = (ptr) &globalframe; W2 var←c4204; W4 m←v4896; /* XRound: */ SOURCE(1624, 181) SOURCE(1685, 49) { W4 result←v9672; W4 a←v9704; W4 b←v9732; a←v9704 = xreal←v4132; b←v9732 = (* (W4Pt) (( (ptr) gf←c12692)+4)/* magic←v2580 */ ); (void) XR←ExtendedFloatAdd((word) &a←v9704, (word) &b←v9732, (word) &result←v9672); m←v4896 = result←v9672; }; SOURCE(1736, 69) { W2 D35; if ((0 != neg←v4160)) { XR←DIntNegI(&D35, (( (ptr) &m←v4896)+2)); var←c4204 = D35; } else { var←c4204 = (* (W2Pt) (( (ptr) &m←v4896)+2) ); }; }; /* removed tail goto */ (* (W2Pt) formal←c085 ) = var←c4204; return; } static void TenToThe←P480(formal←c0109, i←v4264) word formal←c0109; word i←v4264; { register ptr gf←c12724 = (ptr) &globalframe; W4 var←c4308; /* TenToThe: */ SOURCE(1891, 286) if ((i←v4264 == 0)) { SOURCE(2043, 12) var←c4308 = (* (W4Pt) (( (ptr) gf←c12724)+8)/* one←v2804 */ ); /* removed tail goto */ } else { if ((i←v4264 == 1)) { SOURCE(2066, 12) var←c4308 = (* (W4Pt) (( (ptr) gf←c12724)+12)/* ten←v2832 */ ); /* removed tail goto */ } else { if (((i←v4264 & 1) == 0)) { SOURCE(2095, 27) { W4 var←c11892; { W4 var←c11796; W4 d←v8824; (void) TenToThe←P480((word) &d←v8824, (i←v4264 >> 1)); SOURCE(1991, 23) { W4 var←c11860; W4 result←v9348; W4 a←v9380; W4 b←v9408; a←v9380 = d←v8824; b←v9408 = d←v8824; (void) XR←ExtendedFloatMultiply((word) &a←v9380, (word) &b←v9408, (word) &result←v9348); var←c11860 = result←v9348; var←c11796 = var←c11860; }; var←c11892 = var←c11796; }; var←c4308 = var←c11892; /* removed tail goto */ }; } else { SOURCE(2135, 42) { W4 var←c12084; { W4 var←c11956; W4 result←v9456; W4 a←v9488; W4 b←v9516; a←v9488 = (* (W4Pt) (( (ptr) gf←c12724)+12)/* ten←v2832 */ ); { W4 d←v8776; (void) TenToThe←P480((word) &d←v8776, (i←v4264 >> 1)); SOURCE(1991, 23) { W4 var←c12052; W4 result←v9564; W4 a←v9596; W4 b←v9624; a←v9596 = d←v8776; b←v9624 = d←v8776; (void) XR←ExtendedFloatMultiply((word) &a←v9596, (word) &b←v9624, (word) &result←v9564); var←c12052 = result←v9564; b←v9516 = var←c12052; }; }; (void) XR←ExtendedFloatMultiply((word) &a←v9488, (word) &b←v9516, (word) &result←v9456); var←c11956 = result←v9456; var←c12084 = var←c11956; }; var←c4308 = var←c12084; /* removed tail goto */ }; }; }; }; (* (W4Pt) formal←c0109 ) = var←c4308; return; } static void RealToPair←P540(formal←c0144, r←v4368, precision←v4396) word formal←c0144; W2 r←v4368; word precision←v4396; { register ptr gf←c12756 = (ptr) &globalframe; word type←v4440; W2 fr←v4468; word exp10←v4496; /* RealToPair: */ SOURCE(2183, 777) SOURCE(2297, 663) { word var←c12116; { word pd36; pd36 = (* (( (ptr) (* (( (ptr) gf←c12756)+38)/* var←c11380 */ ))+4) ); var←c12116 = (word) ( *( (fPt) ((* (ptr) pd36 ))))(r←v4368, pd36); }; switch (var←c12116) { case 0: SOURCE(2344, 20) type←v4440 = 1; { W2 D37; XR←DCardCard(&D37, 0); fr←v4468 = D37; }; exp10←v4496 = 0; /* removed tail goto */ break; case 3: SOURCE(2381, 73) if (XR←DRealGtI(&fc8, &r←v4368)) { fr←v4468.f0 = 2147483648; fr←v4468.f1 = 0; } else { fr←v4468.f0 = 0; fr←v4468.f1 = 0; }; type←v4440 = 2; exp10←v4496 = 2147483647; /* removed tail goto */ break; case 4: case 5: case 6: SOURCE(2486, 29) type←v4440 = 3; fr←v4468 = r←v4368; exp10←v4496 = 0; /* removed tail goto */ break; default: SOURCE(2529, 433) { W4 vMin←v5088; W4 vMax←v5116; word negative←v5144; W4 v←v5172; word exponent←v5200 = 0; word var←c12244; W4 a←v9056; W4 b←v9084; word var←c12340; W4 a←v8980; W4 b←v9008; SOURCE(2531, 38) (void) TenToThe←P480((word) &vMin←v5088, SGNCK((precision←v4396 - 1))); SOURCE(2571, 36) { W4 result←v9240; W4 a←v9272; W4 b←v9300; a←v9272 = vMin←v5088; b←v9300 = (* (W4Pt) (( (ptr) gf←c12756)+12)/* ten←v2832 */ ); (void) XR←ExtendedFloatMultiply((word) &a←v9272, (word) &b←v9300, (word) &result←v9240); vMax←v5116 = result←v9240; }; SOURCE(2609, 22) negative←v5144 = XR←DRealGtI(&fc8, &r←v4368); SOURCE(2633, 59) { W4 result←v10212; W2 a←v10244; if ((0 != negative←v5144)) { XR←DRealNegI(&a←v10244, &r←v4368); } else { a←v10244 = r←v4368; }; (void) XR←ExtendedFromDReal((word) &a←v10244, (word) &result←v10212); v←v5172 = result←v10212; }; SOURCE(2713, 13) (void) DebugPrint←P600(v←v5172); SOURCE(2728, 81) lab←L100032: ; a←v9056 = v←v5172; b←v9084 = vMax←v5116; var←c12244 = (word) XR←ExtendedFloatLess((word) &a←v9056, (word) &b←v9084); if (((0 == var←c12244) )) { } else { goto lab←L100030; }; SOURCE(2751, 18) { W4 var←c12308; W4 result←v8872; W4 a←v8904; W4 b←v8932; a←v8904 = v←v5172; b←v8932 = (* (W4Pt) (( (ptr) gf←c12756)+12)/* ten←v2832 */ ); (void) XR←ExtendedFloatDivide((word) &a←v8904, (word) &b←v8932, (word) &result←v8872); var←c12308 = result←v8872; v←v5172 = var←c12308; }; SOURCE(2771, 23) exponent←v5200 = (exponent←v5200 + 1); SOURCE(2796, 13) (void) DebugPrint←P600(v←v5172); goto lab←L100032; lab←L100030: ; SOURCE(2820, 83) lab←L100037: ; a←v8980 = v←v5172; b←v9008 = vMin←v5088; var←c12340 = (word) XR←ExtendedFloatLess((word) &a←v8980, (word) &b←v9008); if ((var←c12340 )) { } else { goto lab←L100035; }; SOURCE(2843, 20) { W4 var←c12404; W4 result←v9132; W4 a←v9164; W4 b←v9192; a←v9164 = v←v5172; b←v9192 = (* (W4Pt) (( (ptr) gf←c12756)+12)/* ten←v2832 */ ); (void) XR←ExtendedFloatMultiply((word) &a←v9164, (word) &b←v9192, (word) &result←v9132); var←c12404 = result←v9132; v←v5172 = var←c12404; }; SOURCE(2865, 23) exponent←v5200 = (exponent←v5200 - 1); SOURCE(2890, 13) (void) DebugPrint←P600(v←v5172); goto lab←L100037; lab←L100035: ; SOURCE(2914, 46) { W2 var←c12468; (void) XRound←P420((word) &var←c12468, v←v5172, negative←v5144); type←v4440 = 0; fr←v4468 = var←c12468; exp10←v4496 = exponent←v5200; /* removed tail goto */ }; }; break; }; }; (* (ptr) formal←c0144 ) = type←v4440; (* (W2Pt) (( (ptr) formal←c0144)+1) ) = fr←v4468; (* (( (ptr) formal←c0144)+3) ) = exp10←v4496; return; } static void DebugPrint←P600(x←v4556) W4 x←v4556; { /* DebugPrint: */ } /* file: DRealImpl, module: DRealImpl, compiled at: February 21, 1992 9:05:07 pm PST */ extern void XR←install←DRealImpl() { NoName←Q2184(); } extern void XR←run←DRealImpl() { XR←Start(&globalframe); }