1*09a53ad8SAndrew Turner /* 2*09a53ad8SAndrew Turner ************************************************************************* 3*09a53ad8SAndrew Turner * 4*09a53ad8SAndrew Turner * "DHRYSTONE" Benchmark Program 5*09a53ad8SAndrew Turner * ----------------------------- 6*09a53ad8SAndrew Turner * 7*09a53ad8SAndrew Turner * Version: C, Version 2.1 8*09a53ad8SAndrew Turner * 9*09a53ad8SAndrew Turner * File: dhry_2.c (part 3 of 3) 10*09a53ad8SAndrew Turner * 11*09a53ad8SAndrew Turner * Date: May 25, 1988 12*09a53ad8SAndrew Turner * 13*09a53ad8SAndrew Turner * Author: Reinhold P. Weicker 14*09a53ad8SAndrew Turner * 15*09a53ad8SAndrew Turner ************************************************************************* 16*09a53ad8SAndrew Turner */ 17*09a53ad8SAndrew Turner 18*09a53ad8SAndrew Turner #include "dhry.h" 19*09a53ad8SAndrew Turner 20*09a53ad8SAndrew Turner #ifndef REG 21*09a53ad8SAndrew Turner #define REG 22*09a53ad8SAndrew Turner /* REG becomes defined as empty */ 23*09a53ad8SAndrew Turner /* i.e. no register variables */ 24*09a53ad8SAndrew Turner #else 25*09a53ad8SAndrew Turner #define REG register 26*09a53ad8SAndrew Turner #endif 27*09a53ad8SAndrew Turner 28*09a53ad8SAndrew Turner extern int Int_Glob; 29*09a53ad8SAndrew Turner extern char Ch_1_Glob; 30*09a53ad8SAndrew Turner 31*09a53ad8SAndrew Turner Boolean Func_3 (Enumeration Enum_Par_Val); 32*09a53ad8SAndrew Turner Proc_6(Enumeration Enum_Val_Par,Enumeration * Enum_Ref_Par)33*09a53ad8SAndrew Turner void Proc_6 (Enumeration Enum_Val_Par, Enumeration *Enum_Ref_Par) 34*09a53ad8SAndrew Turner /*********************************/ 35*09a53ad8SAndrew Turner /* executed once */ 36*09a53ad8SAndrew Turner /* Enum_Val_Par == Ident_3, Enum_Ref_Par becomes Ident_2 */ 37*09a53ad8SAndrew Turner 38*09a53ad8SAndrew Turner { 39*09a53ad8SAndrew Turner *Enum_Ref_Par = Enum_Val_Par; 40*09a53ad8SAndrew Turner if (! Func_3 (Enum_Val_Par)) 41*09a53ad8SAndrew Turner /* then, not executed */ 42*09a53ad8SAndrew Turner *Enum_Ref_Par = Ident_4; 43*09a53ad8SAndrew Turner switch (Enum_Val_Par) 44*09a53ad8SAndrew Turner { 45*09a53ad8SAndrew Turner case Ident_1: 46*09a53ad8SAndrew Turner *Enum_Ref_Par = Ident_1; 47*09a53ad8SAndrew Turner break; 48*09a53ad8SAndrew Turner case Ident_2: 49*09a53ad8SAndrew Turner if (Int_Glob > 100) 50*09a53ad8SAndrew Turner /* then */ 51*09a53ad8SAndrew Turner *Enum_Ref_Par = Ident_1; 52*09a53ad8SAndrew Turner else *Enum_Ref_Par = Ident_4; 53*09a53ad8SAndrew Turner break; 54*09a53ad8SAndrew Turner case Ident_3: /* executed */ 55*09a53ad8SAndrew Turner *Enum_Ref_Par = Ident_2; 56*09a53ad8SAndrew Turner break; 57*09a53ad8SAndrew Turner case Ident_4: break; 58*09a53ad8SAndrew Turner case Ident_5: 59*09a53ad8SAndrew Turner *Enum_Ref_Par = Ident_3; 60*09a53ad8SAndrew Turner break; 61*09a53ad8SAndrew Turner } /* switch */ 62*09a53ad8SAndrew Turner } /* Proc_6 */ 63*09a53ad8SAndrew Turner 64*09a53ad8SAndrew Turner Proc_7(One_Fifty Int_1_Par_Val,One_Fifty Int_2_Par_Val,One_Fifty * Int_Par_Ref)65*09a53ad8SAndrew Turner void Proc_7 (One_Fifty Int_1_Par_Val, One_Fifty Int_2_Par_Val, 66*09a53ad8SAndrew Turner One_Fifty *Int_Par_Ref) 67*09a53ad8SAndrew Turner /**********************************************/ 68*09a53ad8SAndrew Turner /* executed three times */ 69*09a53ad8SAndrew Turner /* first call: Int_1_Par_Val == 2, Int_2_Par_Val == 3, */ 70*09a53ad8SAndrew Turner /* Int_Par_Ref becomes 7 */ 71*09a53ad8SAndrew Turner /* second call: Int_1_Par_Val == 10, Int_2_Par_Val == 5, */ 72*09a53ad8SAndrew Turner /* Int_Par_Ref becomes 17 */ 73*09a53ad8SAndrew Turner /* third call: Int_1_Par_Val == 6, Int_2_Par_Val == 10, */ 74*09a53ad8SAndrew Turner /* Int_Par_Ref becomes 18 */ 75*09a53ad8SAndrew Turner 76*09a53ad8SAndrew Turner { 77*09a53ad8SAndrew Turner One_Fifty Int_Loc; 78*09a53ad8SAndrew Turner 79*09a53ad8SAndrew Turner Int_Loc = Int_1_Par_Val + 2; 80*09a53ad8SAndrew Turner *Int_Par_Ref = Int_2_Par_Val + Int_Loc; 81*09a53ad8SAndrew Turner } /* Proc_7 */ 82*09a53ad8SAndrew Turner 83*09a53ad8SAndrew Turner Proc_8(Arr_1_Dim Arr_1_Par_Ref,Arr_2_Dim Arr_2_Par_Ref,int Int_1_Par_Val,int Int_2_Par_Val)84*09a53ad8SAndrew Turner void Proc_8 (Arr_1_Dim Arr_1_Par_Ref, Arr_2_Dim Arr_2_Par_Ref, 85*09a53ad8SAndrew Turner int Int_1_Par_Val, int Int_2_Par_Val) 86*09a53ad8SAndrew Turner /*********************************************************************/ 87*09a53ad8SAndrew Turner /* executed once */ 88*09a53ad8SAndrew Turner /* Int_Par_Val_1 == 3 */ 89*09a53ad8SAndrew Turner /* Int_Par_Val_2 == 7 */ 90*09a53ad8SAndrew Turner 91*09a53ad8SAndrew Turner { 92*09a53ad8SAndrew Turner REG One_Fifty Int_Index; 93*09a53ad8SAndrew Turner REG One_Fifty Int_Loc; 94*09a53ad8SAndrew Turner 95*09a53ad8SAndrew Turner Int_Loc = Int_1_Par_Val + 5; 96*09a53ad8SAndrew Turner Arr_1_Par_Ref [Int_Loc] = Int_2_Par_Val; 97*09a53ad8SAndrew Turner Arr_1_Par_Ref [Int_Loc+1] = Arr_1_Par_Ref [Int_Loc]; 98*09a53ad8SAndrew Turner Arr_1_Par_Ref [Int_Loc+30] = Int_Loc; 99*09a53ad8SAndrew Turner for (Int_Index = Int_Loc; Int_Index <= Int_Loc+1; ++Int_Index) 100*09a53ad8SAndrew Turner Arr_2_Par_Ref [Int_Loc] [Int_Index] = Int_Loc; 101*09a53ad8SAndrew Turner Arr_2_Par_Ref [Int_Loc] [Int_Loc-1] += 1; 102*09a53ad8SAndrew Turner Arr_2_Par_Ref [Int_Loc+20] [Int_Loc] = Arr_1_Par_Ref [Int_Loc]; 103*09a53ad8SAndrew Turner Int_Glob = 5; 104*09a53ad8SAndrew Turner } /* Proc_8 */ 105*09a53ad8SAndrew Turner 106*09a53ad8SAndrew Turner Func_1(Capital_Letter Ch_1_Par_Val,Capital_Letter Ch_2_Par_Val)107*09a53ad8SAndrew Turner Enumeration Func_1 (Capital_Letter Ch_1_Par_Val, 108*09a53ad8SAndrew Turner Capital_Letter Ch_2_Par_Val) 109*09a53ad8SAndrew Turner /*************************************************/ 110*09a53ad8SAndrew Turner /* executed three times */ 111*09a53ad8SAndrew Turner /* first call: Ch_1_Par_Val == 'H', Ch_2_Par_Val == 'R' */ 112*09a53ad8SAndrew Turner /* second call: Ch_1_Par_Val == 'A', Ch_2_Par_Val == 'C' */ 113*09a53ad8SAndrew Turner /* third call: Ch_1_Par_Val == 'B', Ch_2_Par_Val == 'C' */ 114*09a53ad8SAndrew Turner 115*09a53ad8SAndrew Turner { 116*09a53ad8SAndrew Turner Capital_Letter Ch_1_Loc; 117*09a53ad8SAndrew Turner Capital_Letter Ch_2_Loc; 118*09a53ad8SAndrew Turner 119*09a53ad8SAndrew Turner Ch_1_Loc = Ch_1_Par_Val; 120*09a53ad8SAndrew Turner Ch_2_Loc = Ch_1_Loc; 121*09a53ad8SAndrew Turner if (Ch_2_Loc != Ch_2_Par_Val) 122*09a53ad8SAndrew Turner /* then, executed */ 123*09a53ad8SAndrew Turner return (Ident_1); 124*09a53ad8SAndrew Turner else /* not executed */ 125*09a53ad8SAndrew Turner { 126*09a53ad8SAndrew Turner Ch_1_Glob = Ch_1_Loc; 127*09a53ad8SAndrew Turner return (Ident_2); 128*09a53ad8SAndrew Turner } 129*09a53ad8SAndrew Turner } /* Func_1 */ 130*09a53ad8SAndrew Turner 131*09a53ad8SAndrew Turner Func_2(Str_30 Str_1_Par_Ref,Str_30 Str_2_Par_Ref)132*09a53ad8SAndrew Turner Boolean Func_2 (Str_30 Str_1_Par_Ref, Str_30 Str_2_Par_Ref) 133*09a53ad8SAndrew Turner /*************************************************/ 134*09a53ad8SAndrew Turner /* executed once */ 135*09a53ad8SAndrew Turner /* Str_1_Par_Ref == "DHRYSTONE PROGRAM, 1'ST STRING" */ 136*09a53ad8SAndrew Turner /* Str_2_Par_Ref == "DHRYSTONE PROGRAM, 2'ND STRING" */ 137*09a53ad8SAndrew Turner 138*09a53ad8SAndrew Turner { 139*09a53ad8SAndrew Turner REG One_Thirty Int_Loc; 140*09a53ad8SAndrew Turner Capital_Letter Ch_Loc; 141*09a53ad8SAndrew Turner 142*09a53ad8SAndrew Turner Int_Loc = 2; 143*09a53ad8SAndrew Turner while (Int_Loc <= 2) /* loop body executed once */ 144*09a53ad8SAndrew Turner if (Func_1 (Str_1_Par_Ref[Int_Loc], 145*09a53ad8SAndrew Turner Str_2_Par_Ref[Int_Loc+1]) == Ident_1) 146*09a53ad8SAndrew Turner /* then, executed */ 147*09a53ad8SAndrew Turner { 148*09a53ad8SAndrew Turner Ch_Loc = 'A'; 149*09a53ad8SAndrew Turner Int_Loc += 1; 150*09a53ad8SAndrew Turner } /* if, while */ 151*09a53ad8SAndrew Turner if (Ch_Loc >= 'W' && Ch_Loc < 'Z') 152*09a53ad8SAndrew Turner /* then, not executed */ 153*09a53ad8SAndrew Turner Int_Loc = 7; 154*09a53ad8SAndrew Turner if (Ch_Loc == 'R') 155*09a53ad8SAndrew Turner /* then, not executed */ 156*09a53ad8SAndrew Turner return (true); 157*09a53ad8SAndrew Turner else /* executed */ 158*09a53ad8SAndrew Turner { 159*09a53ad8SAndrew Turner if (strcmp (Str_1_Par_Ref, Str_2_Par_Ref) > 0) 160*09a53ad8SAndrew Turner /* then, not executed */ 161*09a53ad8SAndrew Turner { 162*09a53ad8SAndrew Turner Int_Loc += 7; 163*09a53ad8SAndrew Turner Int_Glob = Int_Loc; 164*09a53ad8SAndrew Turner return (true); 165*09a53ad8SAndrew Turner } 166*09a53ad8SAndrew Turner else /* executed */ 167*09a53ad8SAndrew Turner return (false); 168*09a53ad8SAndrew Turner } /* if Ch_Loc */ 169*09a53ad8SAndrew Turner } /* Func_2 */ 170*09a53ad8SAndrew Turner 171*09a53ad8SAndrew Turner Func_3(Enumeration Enum_Par_Val)172*09a53ad8SAndrew Turner Boolean Func_3 (Enumeration Enum_Par_Val) 173*09a53ad8SAndrew Turner /***************************/ 174*09a53ad8SAndrew Turner /* executed once */ 175*09a53ad8SAndrew Turner /* Enum_Par_Val == Ident_3 */ 176*09a53ad8SAndrew Turner 177*09a53ad8SAndrew Turner { 178*09a53ad8SAndrew Turner Enumeration Enum_Loc; 179*09a53ad8SAndrew Turner 180*09a53ad8SAndrew Turner Enum_Loc = Enum_Par_Val; 181*09a53ad8SAndrew Turner if (Enum_Loc == Ident_3) 182*09a53ad8SAndrew Turner /* then, executed */ 183*09a53ad8SAndrew Turner return (true); 184*09a53ad8SAndrew Turner else /* not executed */ 185*09a53ad8SAndrew Turner return (false); 186*09a53ad8SAndrew Turner } /* Func_3 */ 187