SAMV71 Xplained Ultra Software Package 1.4

dhry_2.c

00001 /*
00002  * The 'old-style' K&R function declarations have been replaced with 
00003  * 'ANSI-C-style' function declarations (in dhry_1.c and dhry_2,c)
00004  */
00005 
00006 /*
00007  ****************************************************************************
00008  *
00009  *                   "DHRYSTONE" Benchmark Program
00010  *                   -----------------------------
00011  *                                                                            
00012  *  Version:    C, Version 2.1
00013  *                                                                            
00014  *  File:       dhry_2.c (part 3 of 3)
00015  *
00016  *  Date:       May 25, 1988
00017  *
00018  *  Author:     Reinhold P. Weicker
00019  *
00020  ****************************************************************************
00021  */
00022 
00023 #include "dhry.h"
00024 #include <string.h>
00025 
00026 #ifndef REG 
00027 #define REG
00028         /* REG becomes defined as empty */
00029         /* i.e. no register variables   */
00030 #endif
00031 extern Boolean Func_3 (Enumeration Enum_Par_Val);
00032 extern  int     Int_Glob;   
00033 extern  char    Ch_1_Glob;
00034  /***************************/ 
00035     /* executed once        */ 
00036     /* Enum_Par_Val == Ident_3 */
00037 // 
00038 Boolean Func_3 (Enumeration Enum_Par_Val)
00039 
00040 {
00041 
00042     Enumeration Enum_Loc;
00043 
00044     Enum_Loc = Enum_Par_Val;
00045     if (Enum_Loc == Ident_3) 
00046     /* then, executed */
00047         return (true);
00048     else /* not executed */
00049         return (false);
00050 
00051 } /* Func_3 */
00052 
00053 void Proc_6 ( Enumeration Enum_Val_Par, Enumeration *Enum_Ref_Par)
00054 /*********************************/
00055     /* executed once */
00056     /* Enum_Val_Par == Ident_3, Enum_Ref_Par becomes Ident_2 */
00057 {
00058     *Enum_Ref_Par = Enum_Val_Par;
00059     if (! Func_3 (Enum_Val_Par))
00060         /* then, not executed */
00061         *Enum_Ref_Par = Ident_4;
00062     switch (Enum_Val_Par)
00063     {
00064         case Ident_1:
00065             *Enum_Ref_Par = Ident_1;
00066             break;
00067         case Ident_2:
00068             if (Int_Glob > 100)
00069                 *Enum_Ref_Par = Ident_1;
00070             else 
00071                 *Enum_Ref_Par = Ident_4;
00072             break;
00073         case Ident_3: /* executed */
00074             *Enum_Ref_Par = Ident_2;
00075             break;
00076         case Ident_4: 
00077             break;
00078         case Ident_5:
00079             *Enum_Ref_Par = Ident_3;
00080             break;
00081     } /* switch */
00082 } /* Proc_6 */
00083 
00084 
00085 void Proc_7 ( One_Fifty Int_1_Par_Val, 
00086               One_Fifty Int_2_Par_Val, 
00087               One_Fifty *Int_Par_Ref )
00088 /**********************************************/
00089     /* executed three times                                      */
00090     /* first call:      Int_1_Par_Val == 2, Int_2_Par_Val == 3,  */
00091     /*                  Int_Par_Ref becomes 7                    */
00092     /* second call:     Int_1_Par_Val == 10, Int_2_Par_Val == 5, */
00093     /*                  Int_Par_Ref becomes 17                   */
00094     /* third call:      Int_1_Par_Val == 6, Int_2_Par_Val == 10, */
00095     /*                  Int_Par_Ref becomes 18                   */
00096 {
00097     One_Fifty Int_Loc;
00098 
00099     Int_Loc = Int_1_Par_Val + 2;
00100     *Int_Par_Ref = Int_2_Par_Val + Int_Loc;
00101 } /* Proc_7 */
00102 
00103 
00104 void Proc_8 ( Arr_1_Dim Arr_1_Par_Ref, 
00105               Arr_2_Dim Arr_2_Par_Ref, 
00106               int Int_1_Par_Val, 
00107               int Int_2_Par_Val)
00108 /*********************************************************************/
00109     /* executed once      */
00110     /* Int_Par_Val_1 == 3 */
00111     /* Int_Par_Val_2 == 7 */
00112 {
00113   REG One_Fifty Int_Index;
00114   REG One_Fifty Int_Loc;
00115 
00116     Int_Loc = Int_1_Par_Val + 5;
00117     Arr_1_Par_Ref [Int_Loc] = Int_2_Par_Val;
00118     Arr_1_Par_Ref [Int_Loc+1] = Arr_1_Par_Ref [Int_Loc];
00119     Arr_1_Par_Ref [Int_Loc+30] = Int_Loc;
00120     for (Int_Index = Int_Loc; Int_Index <= Int_Loc+1; ++Int_Index)
00121         Arr_2_Par_Ref [Int_Loc] [Int_Index] = Int_Loc;
00122     Arr_2_Par_Ref [Int_Loc] [Int_Loc-1] += 1;
00123     Arr_2_Par_Ref [Int_Loc+20] [Int_Loc] = Arr_1_Par_Ref [Int_Loc];
00124     Int_Glob = 5;
00125 } /* Proc_8 */
00126 
00127 
00128 Enumeration Func_1 (Capital_Letter Ch_1_Par_Val, Capital_Letter Ch_2_Par_Val)
00129 /*************************************************/
00130     /* executed three times                                         */
00131     /* first call:      Ch_1_Par_Val == 'H', Ch_2_Par_Val == 'R'    */
00132     /* second call:     Ch_1_Par_Val == 'A', Ch_2_Par_Val == 'C'    */
00133     /* third call:      Ch_1_Par_Val == 'B', Ch_2_Par_Val == 'C'    */
00134 {
00135     Capital_Letter        Ch_1_Loc;
00136     Capital_Letter        Ch_2_Loc;
00137 
00138     Ch_1_Loc = Ch_1_Par_Val;
00139     Ch_2_Loc = Ch_1_Loc;
00140     if (Ch_2_Loc != Ch_2_Par_Val)
00141     /* then, executed */
00142         return (Ident_1);
00143     else  /* not executed */
00144     {
00145         Ch_1_Glob = Ch_1_Loc;
00146         return (Ident_2);
00147     }
00148 } /* Func_1 */
00149 
00150 
00151 Boolean Func_2 (Str_30  Str_1_Par_Ref, Str_30  Str_2_Par_Ref)
00152 /*************************************************/
00153     /* executed once */
00154     /* Str_1_Par_Ref == "DHRYSTONE PROGRAM, 1'ST STRING" */
00155     /* Str_2_Par_Ref == "DHRYSTONE PROGRAM, 2'ND STRING" */
00156 
00157 {
00158     REG One_Thirty      Int_Loc;
00159     Capital_Letter      Ch_Loc;
00160 
00161     Int_Loc = 2;
00162     while (Int_Loc <= 2) /* loop body executed once */
00163     if (Func_1 (Str_1_Par_Ref[Int_Loc],
00164                 Str_2_Par_Ref[Int_Loc+1]) == Ident_1)
00165     /* then, executed */
00166     {
00167         Ch_Loc = 'A';
00168         Int_Loc += 1;
00169     } /* if, while */
00170 
00171     if (Ch_Loc >= 'W' && Ch_Loc < 'Z')
00172     /* then, not executed */
00173     Int_Loc = 7;
00174     if (Ch_Loc == 'R')
00175     /* then, not executed */
00176     return (true);
00177     else /* executed */
00178     {
00179         if (strcmp (Str_1_Par_Ref, Str_2_Par_Ref) > 0)
00180         /* then, not executed */
00181         {
00182             Int_Loc += 7;
00183             Int_Glob = Int_Loc;
00184             return (true);
00185         }
00186         else /* executed */
00187             return (false);
00188     } /* if Ch_Loc */
00189 } /* Func_2 */
00190 
00191 
00192 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines