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_1.c (part 2 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 <time.h>
19*09a53ad8SAndrew Turner #include <stdlib.h>
20*09a53ad8SAndrew Turner #include <stdio.h>
21*09a53ad8SAndrew Turner #include "dhry.h"
22*09a53ad8SAndrew Turner /*COMPILER COMPILER COMPILER COMPILER COMPILER COMPILER COMPILER*/
23*09a53ad8SAndrew Turner
24*09a53ad8SAndrew Turner #ifdef COW
25*09a53ad8SAndrew Turner #define compiler "Watcom C/C++ 10.5 Win386"
26*09a53ad8SAndrew Turner #define options " -otexan -zp8 -5r -ms"
27*09a53ad8SAndrew Turner #endif
28*09a53ad8SAndrew Turner #ifdef CNW
29*09a53ad8SAndrew Turner #define compiler "Watcom C/C++ 10.5 Win386"
30*09a53ad8SAndrew Turner #define options " No optimisation"
31*09a53ad8SAndrew Turner #endif
32*09a53ad8SAndrew Turner #ifdef COD
33*09a53ad8SAndrew Turner #define compiler "Watcom C/C++ 10.5 Dos4GW"
34*09a53ad8SAndrew Turner #define options " -otexan -zp8 -5r -ms"
35*09a53ad8SAndrew Turner #endif
36*09a53ad8SAndrew Turner #ifdef CND
37*09a53ad8SAndrew Turner #define compiler "Watcom C/C++ 10.5 Dos4GW"
38*09a53ad8SAndrew Turner #define options " No optimisation"
39*09a53ad8SAndrew Turner #endif
40*09a53ad8SAndrew Turner #ifdef CONT
41*09a53ad8SAndrew Turner #define compiler "Watcom C/C++ 10.5 Win32NT"
42*09a53ad8SAndrew Turner #define options " -otexan -zp8 -5r -ms"
43*09a53ad8SAndrew Turner #endif
44*09a53ad8SAndrew Turner #ifdef CNNT
45*09a53ad8SAndrew Turner #define compiler "Watcom C/C++ 10.5 Win32NT"
46*09a53ad8SAndrew Turner #define options " No optimisation"
47*09a53ad8SAndrew Turner #endif
48*09a53ad8SAndrew Turner #ifdef COO2
49*09a53ad8SAndrew Turner #define compiler "Watcom C/C++ 10.5 OS/2-32"
50*09a53ad8SAndrew Turner #define options " -otexan -zp8 -5r -ms"
51*09a53ad8SAndrew Turner #endif
52*09a53ad8SAndrew Turner #ifdef CNO2
53*09a53ad8SAndrew Turner #define compiler "Watcom C/C++ 10.5 OS/2-32"
54*09a53ad8SAndrew Turner #define options " No optimisation"
55*09a53ad8SAndrew Turner #endif
56*09a53ad8SAndrew Turner
57*09a53ad8SAndrew Turner
58*09a53ad8SAndrew Turner /* Global Variables: */
59*09a53ad8SAndrew Turner
60*09a53ad8SAndrew Turner Rec_Pointer Ptr_Glob,
61*09a53ad8SAndrew Turner Next_Ptr_Glob;
62*09a53ad8SAndrew Turner int Int_Glob;
63*09a53ad8SAndrew Turner Boolean Bool_Glob;
64*09a53ad8SAndrew Turner char Ch_1_Glob,
65*09a53ad8SAndrew Turner Ch_2_Glob;
66*09a53ad8SAndrew Turner int Arr_1_Glob [50];
67*09a53ad8SAndrew Turner int Arr_2_Glob [50] [50];
68*09a53ad8SAndrew Turner int getinput = 1;
69*09a53ad8SAndrew Turner
70*09a53ad8SAndrew Turner
71*09a53ad8SAndrew Turner char Reg_Define[100] = "Register option Selected.";
72*09a53ad8SAndrew Turner
73*09a53ad8SAndrew Turner Enumeration Func_1 (Capital_Letter Ch_1_Par_Val,
74*09a53ad8SAndrew Turner Capital_Letter Ch_2_Par_Val);
75*09a53ad8SAndrew Turner /*
76*09a53ad8SAndrew Turner forward declaration necessary since Enumeration may not simply be int
77*09a53ad8SAndrew Turner */
78*09a53ad8SAndrew Turner
79*09a53ad8SAndrew Turner #ifndef ROPT
80*09a53ad8SAndrew Turner #define REG
81*09a53ad8SAndrew Turner /* REG becomes defined as empty */
82*09a53ad8SAndrew Turner /* i.e. no register variables */
83*09a53ad8SAndrew Turner #else
84*09a53ad8SAndrew Turner #define REG register
85*09a53ad8SAndrew Turner #endif
86*09a53ad8SAndrew Turner
87*09a53ad8SAndrew Turner void Proc_1 (REG Rec_Pointer Ptr_Val_Par);
88*09a53ad8SAndrew Turner void Proc_2 (One_Fifty *Int_Par_Ref);
89*09a53ad8SAndrew Turner void Proc_3 (Rec_Pointer *Ptr_Ref_Par);
90*09a53ad8SAndrew Turner void Proc_4 ();
91*09a53ad8SAndrew Turner void Proc_5 ();
92*09a53ad8SAndrew Turner void Proc_6 (Enumeration Enum_Val_Par, Enumeration *Enum_Ref_Par);
93*09a53ad8SAndrew Turner void Proc_7 (One_Fifty Int_1_Par_Val, One_Fifty Int_2_Par_Val,
94*09a53ad8SAndrew Turner One_Fifty *Int_Par_Ref);
95*09a53ad8SAndrew Turner void Proc_8 (Arr_1_Dim Arr_1_Par_Ref, Arr_2_Dim Arr_2_Par_Ref,
96*09a53ad8SAndrew Turner int Int_1_Par_Val, int Int_2_Par_Val);
97*09a53ad8SAndrew Turner
98*09a53ad8SAndrew Turner Boolean Func_2 (Str_30 Str_1_Par_Ref, Str_30 Str_2_Par_Ref);
99*09a53ad8SAndrew Turner
100*09a53ad8SAndrew Turner
101*09a53ad8SAndrew Turner /* variables for time measurement: */
102*09a53ad8SAndrew Turner
103*09a53ad8SAndrew Turner #define Too_Small_Time 2
104*09a53ad8SAndrew Turner /* Measurements should last at least 2 seconds */
105*09a53ad8SAndrew Turner
106*09a53ad8SAndrew Turner double Begin_Time,
107*09a53ad8SAndrew Turner End_Time,
108*09a53ad8SAndrew Turner User_Time;
109*09a53ad8SAndrew Turner
110*09a53ad8SAndrew Turner double Microseconds,
111*09a53ad8SAndrew Turner Dhrystones_Per_Second,
112*09a53ad8SAndrew Turner Vax_Mips;
113*09a53ad8SAndrew Turner
114*09a53ad8SAndrew Turner /* end of variables for time measurement */
115*09a53ad8SAndrew Turner
116*09a53ad8SAndrew Turner
main(int argc,char * argv[])117*09a53ad8SAndrew Turner void main (int argc, char *argv[])
118*09a53ad8SAndrew Turner /*****/
119*09a53ad8SAndrew Turner
120*09a53ad8SAndrew Turner /* main program, corresponds to procedures */
121*09a53ad8SAndrew Turner /* Main and Proc_0 in the Ada version */
122*09a53ad8SAndrew Turner {
123*09a53ad8SAndrew Turner double dtime();
124*09a53ad8SAndrew Turner
125*09a53ad8SAndrew Turner One_Fifty Int_1_Loc;
126*09a53ad8SAndrew Turner REG One_Fifty Int_2_Loc;
127*09a53ad8SAndrew Turner One_Fifty Int_3_Loc;
128*09a53ad8SAndrew Turner REG char Ch_Index;
129*09a53ad8SAndrew Turner Enumeration Enum_Loc;
130*09a53ad8SAndrew Turner Str_30 Str_1_Loc;
131*09a53ad8SAndrew Turner Str_30 Str_2_Loc;
132*09a53ad8SAndrew Turner REG int Run_Index;
133*09a53ad8SAndrew Turner REG int Number_Of_Runs;
134*09a53ad8SAndrew Turner int endit, count = 10;
135*09a53ad8SAndrew Turner FILE *Ap;
136*09a53ad8SAndrew Turner char general[9][80] = {" "};
137*09a53ad8SAndrew Turner
138*09a53ad8SAndrew Turner /* Initializations */
139*09a53ad8SAndrew Turner if (argc > 1)
140*09a53ad8SAndrew Turner {
141*09a53ad8SAndrew Turner switch (argv[1][0])
142*09a53ad8SAndrew Turner {
143*09a53ad8SAndrew Turner case 'N':
144*09a53ad8SAndrew Turner getinput = 0;
145*09a53ad8SAndrew Turner break;
146*09a53ad8SAndrew Turner case 'n':
147*09a53ad8SAndrew Turner getinput = 0;
148*09a53ad8SAndrew Turner break;
149*09a53ad8SAndrew Turner }
150*09a53ad8SAndrew Turner }
151*09a53ad8SAndrew Turner
152*09a53ad8SAndrew Turner if ((Ap = fopen("Dhry.txt","a+")) == NULL)
153*09a53ad8SAndrew Turner {
154*09a53ad8SAndrew Turner printf("Can not open Dhry.txt\n\n");
155*09a53ad8SAndrew Turner printf("Press any key\n");
156*09a53ad8SAndrew Turner exit(1);
157*09a53ad8SAndrew Turner }
158*09a53ad8SAndrew Turner
159*09a53ad8SAndrew Turner /***********************************************************************
160*09a53ad8SAndrew Turner * Change for compiler and optimisation used *
161*09a53ad8SAndrew Turner ***********************************************************************/
162*09a53ad8SAndrew Turner
163*09a53ad8SAndrew Turner Next_Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));
164*09a53ad8SAndrew Turner Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));
165*09a53ad8SAndrew Turner
166*09a53ad8SAndrew Turner Ptr_Glob->Ptr_Comp = Next_Ptr_Glob;
167*09a53ad8SAndrew Turner Ptr_Glob->Discr = Ident_1;
168*09a53ad8SAndrew Turner Ptr_Glob->variant.var_1.Enum_Comp = Ident_3;
169*09a53ad8SAndrew Turner Ptr_Glob->variant.var_1.Int_Comp = 40;
170*09a53ad8SAndrew Turner strcpy (Ptr_Glob->variant.var_1.Str_Comp,
171*09a53ad8SAndrew Turner "DHRYSTONE PROGRAM, SOME STRING");
172*09a53ad8SAndrew Turner strcpy (Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING");
173*09a53ad8SAndrew Turner
174*09a53ad8SAndrew Turner Arr_2_Glob [8][7] = 10;
175*09a53ad8SAndrew Turner /* Was missing in published program. Without this statement, */
176*09a53ad8SAndrew Turner /* Arr_2_Glob [8][7] would have an undefined value. */
177*09a53ad8SAndrew Turner /* Warning: With 16-Bit processors and Number_Of_Runs > 32000, */
178*09a53ad8SAndrew Turner /* overflow may occur for this array element. */
179*09a53ad8SAndrew Turner
180*09a53ad8SAndrew Turner printf ("\n");
181*09a53ad8SAndrew Turner printf ("Dhrystone Benchmark, Version 2.1 (Language: C or C++)\n");
182*09a53ad8SAndrew Turner printf ("\n");
183*09a53ad8SAndrew Turner
184*09a53ad8SAndrew Turner if (getinput == 0)
185*09a53ad8SAndrew Turner {
186*09a53ad8SAndrew Turner printf ("No run time input data\n\n");
187*09a53ad8SAndrew Turner }
188*09a53ad8SAndrew Turner else
189*09a53ad8SAndrew Turner {
190*09a53ad8SAndrew Turner printf ("With run time input data\n\n");
191*09a53ad8SAndrew Turner }
192*09a53ad8SAndrew Turner
193*09a53ad8SAndrew Turner printf ("Compiler %s\n", compiler);
194*09a53ad8SAndrew Turner printf ("Optimisation %s\n", options);
195*09a53ad8SAndrew Turner #ifdef ROPT
196*09a53ad8SAndrew Turner printf ("Register option selected\n\n");
197*09a53ad8SAndrew Turner #else
198*09a53ad8SAndrew Turner printf ("Register option not selected\n\n");
199*09a53ad8SAndrew Turner strcpy(Reg_Define, "Register option Not selected.");
200*09a53ad8SAndrew Turner #endif
201*09a53ad8SAndrew Turner
202*09a53ad8SAndrew Turner /*
203*09a53ad8SAndrew Turner if (Reg)
204*09a53ad8SAndrew Turner {
205*09a53ad8SAndrew Turner printf ("Program compiled with 'register' attribute\n");
206*09a53ad8SAndrew Turner printf ("\n");
207*09a53ad8SAndrew Turner }
208*09a53ad8SAndrew Turner else
209*09a53ad8SAndrew Turner {
210*09a53ad8SAndrew Turner printf ("Program compiled without 'register' attribute\n");
211*09a53ad8SAndrew Turner printf ("\n");
212*09a53ad8SAndrew Turner }
213*09a53ad8SAndrew Turner
214*09a53ad8SAndrew Turner printf ("Please give the number of runs through the benchmark: ");
215*09a53ad8SAndrew Turner {
216*09a53ad8SAndrew Turner int n;
217*09a53ad8SAndrew Turner scanf ("%d", &n);
218*09a53ad8SAndrew Turner Number_Of_Runs = n;
219*09a53ad8SAndrew Turner }
220*09a53ad8SAndrew Turner printf ("\n");
221*09a53ad8SAndrew Turner printf ("Execution starts, %d runs through Dhrystone\n",
222*09a53ad8SAndrew Turner Number_Of_Runs);
223*09a53ad8SAndrew Turner */
224*09a53ad8SAndrew Turner
225*09a53ad8SAndrew Turner Number_Of_Runs = 5000;
226*09a53ad8SAndrew Turner
227*09a53ad8SAndrew Turner do
228*09a53ad8SAndrew Turner {
229*09a53ad8SAndrew Turner
230*09a53ad8SAndrew Turner Number_Of_Runs = Number_Of_Runs * 2;
231*09a53ad8SAndrew Turner count = count - 1;
232*09a53ad8SAndrew Turner Arr_2_Glob [8][7] = 10;
233*09a53ad8SAndrew Turner
234*09a53ad8SAndrew Turner /***************/
235*09a53ad8SAndrew Turner /* Start timer */
236*09a53ad8SAndrew Turner /***************/
237*09a53ad8SAndrew Turner
238*09a53ad8SAndrew Turner Begin_Time = dtime();
239*09a53ad8SAndrew Turner
240*09a53ad8SAndrew Turner for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index)
241*09a53ad8SAndrew Turner {
242*09a53ad8SAndrew Turner
243*09a53ad8SAndrew Turner Proc_5();
244*09a53ad8SAndrew Turner Proc_4();
245*09a53ad8SAndrew Turner /* Ch_1_Glob == 'A', Ch_2_Glob == 'B', Bool_Glob == true */
246*09a53ad8SAndrew Turner Int_1_Loc = 2;
247*09a53ad8SAndrew Turner Int_2_Loc = 3;
248*09a53ad8SAndrew Turner strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
249*09a53ad8SAndrew Turner Enum_Loc = Ident_2;
250*09a53ad8SAndrew Turner Bool_Glob = ! Func_2 (Str_1_Loc, Str_2_Loc);
251*09a53ad8SAndrew Turner /* Bool_Glob == 1 */
252*09a53ad8SAndrew Turner while (Int_1_Loc < Int_2_Loc) /* loop body executed once */
253*09a53ad8SAndrew Turner {
254*09a53ad8SAndrew Turner Int_3_Loc = 5 * Int_1_Loc - Int_2_Loc;
255*09a53ad8SAndrew Turner /* Int_3_Loc == 7 */
256*09a53ad8SAndrew Turner Proc_7 (Int_1_Loc, Int_2_Loc, &Int_3_Loc);
257*09a53ad8SAndrew Turner /* Int_3_Loc == 7 */
258*09a53ad8SAndrew Turner Int_1_Loc += 1;
259*09a53ad8SAndrew Turner } /* while */
260*09a53ad8SAndrew Turner /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
261*09a53ad8SAndrew Turner Proc_8 (Arr_1_Glob, Arr_2_Glob, Int_1_Loc, Int_3_Loc);
262*09a53ad8SAndrew Turner /* Int_Glob == 5 */
263*09a53ad8SAndrew Turner Proc_1 (Ptr_Glob);
264*09a53ad8SAndrew Turner for (Ch_Index = 'A'; Ch_Index <= Ch_2_Glob; ++Ch_Index)
265*09a53ad8SAndrew Turner /* loop body executed twice */
266*09a53ad8SAndrew Turner {
267*09a53ad8SAndrew Turner if (Enum_Loc == Func_1 (Ch_Index, 'C'))
268*09a53ad8SAndrew Turner /* then, not executed */
269*09a53ad8SAndrew Turner {
270*09a53ad8SAndrew Turner Proc_6 (Ident_1, &Enum_Loc);
271*09a53ad8SAndrew Turner strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING");
272*09a53ad8SAndrew Turner Int_2_Loc = Run_Index;
273*09a53ad8SAndrew Turner Int_Glob = Run_Index;
274*09a53ad8SAndrew Turner }
275*09a53ad8SAndrew Turner }
276*09a53ad8SAndrew Turner /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
277*09a53ad8SAndrew Turner Int_2_Loc = Int_2_Loc * Int_1_Loc;
278*09a53ad8SAndrew Turner Int_1_Loc = Int_2_Loc / Int_3_Loc;
279*09a53ad8SAndrew Turner Int_2_Loc = 7 * (Int_2_Loc - Int_3_Loc) - Int_1_Loc;
280*09a53ad8SAndrew Turner /* Int_1_Loc == 1, Int_2_Loc == 13, Int_3_Loc == 7 */
281*09a53ad8SAndrew Turner Proc_2 (&Int_1_Loc);
282*09a53ad8SAndrew Turner /* Int_1_Loc == 5 */
283*09a53ad8SAndrew Turner
284*09a53ad8SAndrew Turner } /* loop "for Run_Index" */
285*09a53ad8SAndrew Turner
286*09a53ad8SAndrew Turner /**************/
287*09a53ad8SAndrew Turner /* Stop timer */
288*09a53ad8SAndrew Turner /**************/
289*09a53ad8SAndrew Turner
290*09a53ad8SAndrew Turner End_Time = dtime();
291*09a53ad8SAndrew Turner User_Time = End_Time - Begin_Time;
292*09a53ad8SAndrew Turner
293*09a53ad8SAndrew Turner printf ("%12.0f runs %6.2f seconds \n",(double) Number_Of_Runs, User_Time);
294*09a53ad8SAndrew Turner if (User_Time > 5)
295*09a53ad8SAndrew Turner {
296*09a53ad8SAndrew Turner count = 0;
297*09a53ad8SAndrew Turner }
298*09a53ad8SAndrew Turner else
299*09a53ad8SAndrew Turner {
300*09a53ad8SAndrew Turner if (User_Time < 0.1)
301*09a53ad8SAndrew Turner {
302*09a53ad8SAndrew Turner Number_Of_Runs = Number_Of_Runs * 5;
303*09a53ad8SAndrew Turner }
304*09a53ad8SAndrew Turner }
305*09a53ad8SAndrew Turner } /* calibrate/run do while */
306*09a53ad8SAndrew Turner while (count >0);
307*09a53ad8SAndrew Turner
308*09a53ad8SAndrew Turner printf ("\n");
309*09a53ad8SAndrew Turner printf ("Final values (* implementation-dependent):\n");
310*09a53ad8SAndrew Turner printf ("\n");
311*09a53ad8SAndrew Turner printf ("Int_Glob: ");
312*09a53ad8SAndrew Turner if (Int_Glob == 5) printf ("O.K. ");
313*09a53ad8SAndrew Turner else printf ("WRONG ");
314*09a53ad8SAndrew Turner printf ("%d ", Int_Glob);
315*09a53ad8SAndrew Turner
316*09a53ad8SAndrew Turner printf ("Bool_Glob: ");
317*09a53ad8SAndrew Turner if (Bool_Glob == 1) printf ("O.K. ");
318*09a53ad8SAndrew Turner else printf ("WRONG ");
319*09a53ad8SAndrew Turner printf ("%d\n", Bool_Glob);
320*09a53ad8SAndrew Turner
321*09a53ad8SAndrew Turner printf ("Ch_1_Glob: ");
322*09a53ad8SAndrew Turner if (Ch_1_Glob == 'A') printf ("O.K. ");
323*09a53ad8SAndrew Turner else printf ("WRONG ");
324*09a53ad8SAndrew Turner printf ("%c ", Ch_1_Glob);
325*09a53ad8SAndrew Turner
326*09a53ad8SAndrew Turner printf ("Ch_2_Glob: ");
327*09a53ad8SAndrew Turner if (Ch_2_Glob == 'B') printf ("O.K. ");
328*09a53ad8SAndrew Turner else printf ("WRONG ");
329*09a53ad8SAndrew Turner printf ("%c\n", Ch_2_Glob);
330*09a53ad8SAndrew Turner
331*09a53ad8SAndrew Turner printf ("Arr_1_Glob[8]: ");
332*09a53ad8SAndrew Turner if (Arr_1_Glob[8] == 7) printf ("O.K. ");
333*09a53ad8SAndrew Turner else printf ("WRONG ");
334*09a53ad8SAndrew Turner printf ("%d ", Arr_1_Glob[8]);
335*09a53ad8SAndrew Turner
336*09a53ad8SAndrew Turner printf ("Arr_2_Glob8/7: ");
337*09a53ad8SAndrew Turner if (Arr_2_Glob[8][7] == Number_Of_Runs + 10)
338*09a53ad8SAndrew Turner printf ("O.K. ");
339*09a53ad8SAndrew Turner else printf ("WRONG ");
340*09a53ad8SAndrew Turner printf ("%10d\n", Arr_2_Glob[8][7]);
341*09a53ad8SAndrew Turner
342*09a53ad8SAndrew Turner printf ("Ptr_Glob-> ");
343*09a53ad8SAndrew Turner printf (" Ptr_Comp: * %d\n", (int) Ptr_Glob->Ptr_Comp);
344*09a53ad8SAndrew Turner
345*09a53ad8SAndrew Turner printf (" Discr: ");
346*09a53ad8SAndrew Turner if (Ptr_Glob->Discr == 0) printf ("O.K. ");
347*09a53ad8SAndrew Turner else printf ("WRONG ");
348*09a53ad8SAndrew Turner printf ("%d ", Ptr_Glob->Discr);
349*09a53ad8SAndrew Turner
350*09a53ad8SAndrew Turner printf ("Enum_Comp: ");
351*09a53ad8SAndrew Turner if (Ptr_Glob->variant.var_1.Enum_Comp == 2)
352*09a53ad8SAndrew Turner printf ("O.K. ");
353*09a53ad8SAndrew Turner else printf ("WRONG ");
354*09a53ad8SAndrew Turner printf ("%d\n", Ptr_Glob->variant.var_1.Enum_Comp);
355*09a53ad8SAndrew Turner
356*09a53ad8SAndrew Turner printf (" Int_Comp: ");
357*09a53ad8SAndrew Turner if (Ptr_Glob->variant.var_1.Int_Comp == 17) printf ("O.K. ");
358*09a53ad8SAndrew Turner else printf ("WRONG ");
359*09a53ad8SAndrew Turner printf ("%d ", Ptr_Glob->variant.var_1.Int_Comp);
360*09a53ad8SAndrew Turner
361*09a53ad8SAndrew Turner printf ("Str_Comp: ");
362*09a53ad8SAndrew Turner if (strcmp(Ptr_Glob->variant.var_1.Str_Comp,
363*09a53ad8SAndrew Turner "DHRYSTONE PROGRAM, SOME STRING") == 0)
364*09a53ad8SAndrew Turner printf ("O.K. ");
365*09a53ad8SAndrew Turner else printf ("WRONG ");
366*09a53ad8SAndrew Turner printf ("%s\n", Ptr_Glob->variant.var_1.Str_Comp);
367*09a53ad8SAndrew Turner
368*09a53ad8SAndrew Turner printf ("Next_Ptr_Glob-> ");
369*09a53ad8SAndrew Turner printf (" Ptr_Comp: * %d", (int) Next_Ptr_Glob->Ptr_Comp);
370*09a53ad8SAndrew Turner printf (" same as above\n");
371*09a53ad8SAndrew Turner
372*09a53ad8SAndrew Turner printf (" Discr: ");
373*09a53ad8SAndrew Turner if (Next_Ptr_Glob->Discr == 0)
374*09a53ad8SAndrew Turner printf ("O.K. ");
375*09a53ad8SAndrew Turner else printf ("WRONG ");
376*09a53ad8SAndrew Turner printf ("%d ", Next_Ptr_Glob->Discr);
377*09a53ad8SAndrew Turner
378*09a53ad8SAndrew Turner printf ("Enum_Comp: ");
379*09a53ad8SAndrew Turner if (Next_Ptr_Glob->variant.var_1.Enum_Comp == 1)
380*09a53ad8SAndrew Turner printf ("O.K. ");
381*09a53ad8SAndrew Turner else printf ("WRONG ");
382*09a53ad8SAndrew Turner printf ("%d\n", Next_Ptr_Glob->variant.var_1.Enum_Comp);
383*09a53ad8SAndrew Turner
384*09a53ad8SAndrew Turner printf (" Int_Comp: ");
385*09a53ad8SAndrew Turner if (Next_Ptr_Glob->variant.var_1.Int_Comp == 18)
386*09a53ad8SAndrew Turner printf ("O.K. ");
387*09a53ad8SAndrew Turner else printf ("WRONG ");
388*09a53ad8SAndrew Turner printf ("%d ", Next_Ptr_Glob->variant.var_1.Int_Comp);
389*09a53ad8SAndrew Turner
390*09a53ad8SAndrew Turner printf ("Str_Comp: ");
391*09a53ad8SAndrew Turner if (strcmp(Next_Ptr_Glob->variant.var_1.Str_Comp,
392*09a53ad8SAndrew Turner "DHRYSTONE PROGRAM, SOME STRING") == 0)
393*09a53ad8SAndrew Turner printf ("O.K. ");
394*09a53ad8SAndrew Turner else printf ("WRONG ");
395*09a53ad8SAndrew Turner printf ("%s\n", Next_Ptr_Glob->variant.var_1.Str_Comp);
396*09a53ad8SAndrew Turner
397*09a53ad8SAndrew Turner printf ("Int_1_Loc: ");
398*09a53ad8SAndrew Turner if (Int_1_Loc == 5)
399*09a53ad8SAndrew Turner printf ("O.K. ");
400*09a53ad8SAndrew Turner else printf ("WRONG ");
401*09a53ad8SAndrew Turner printf ("%d ", Int_1_Loc);
402*09a53ad8SAndrew Turner
403*09a53ad8SAndrew Turner printf ("Int_2_Loc: ");
404*09a53ad8SAndrew Turner if (Int_2_Loc == 13)
405*09a53ad8SAndrew Turner printf ("O.K. ");
406*09a53ad8SAndrew Turner else printf ("WRONG ");
407*09a53ad8SAndrew Turner printf ("%d\n", Int_2_Loc);
408*09a53ad8SAndrew Turner
409*09a53ad8SAndrew Turner printf ("Int_3_Loc: ");
410*09a53ad8SAndrew Turner if (Int_3_Loc == 7)
411*09a53ad8SAndrew Turner printf ("O.K. ");
412*09a53ad8SAndrew Turner else printf ("WRONG ");
413*09a53ad8SAndrew Turner printf ("%d ", Int_3_Loc);
414*09a53ad8SAndrew Turner
415*09a53ad8SAndrew Turner printf ("Enum_Loc: ");
416*09a53ad8SAndrew Turner if (Enum_Loc == 1)
417*09a53ad8SAndrew Turner printf ("O.K. ");
418*09a53ad8SAndrew Turner else printf ("WRONG ");
419*09a53ad8SAndrew Turner printf ("%d\n", Enum_Loc);
420*09a53ad8SAndrew Turner
421*09a53ad8SAndrew Turner printf ("Str_1_Loc: ");
422*09a53ad8SAndrew Turner if (strcmp(Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING") == 0)
423*09a53ad8SAndrew Turner printf ("O.K. ");
424*09a53ad8SAndrew Turner else printf ("WRONG ");
425*09a53ad8SAndrew Turner printf ("%s\n", Str_1_Loc);
426*09a53ad8SAndrew Turner
427*09a53ad8SAndrew Turner printf ("Str_2_Loc: ");
428*09a53ad8SAndrew Turner if (strcmp(Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING") == 0)
429*09a53ad8SAndrew Turner printf ("O.K. ");
430*09a53ad8SAndrew Turner else printf ("WRONG ");
431*09a53ad8SAndrew Turner printf ("%s\n", Str_2_Loc);
432*09a53ad8SAndrew Turner
433*09a53ad8SAndrew Turner printf ("\n");
434*09a53ad8SAndrew Turner
435*09a53ad8SAndrew Turner
436*09a53ad8SAndrew Turner if (User_Time < Too_Small_Time)
437*09a53ad8SAndrew Turner {
438*09a53ad8SAndrew Turner printf ("Measured time too small to obtain meaningful results\n");
439*09a53ad8SAndrew Turner printf ("Please increase number of runs\n");
440*09a53ad8SAndrew Turner printf ("\n");
441*09a53ad8SAndrew Turner }
442*09a53ad8SAndrew Turner else
443*09a53ad8SAndrew Turner {
444*09a53ad8SAndrew Turner Microseconds = User_Time * Mic_secs_Per_Second
445*09a53ad8SAndrew Turner / (double) Number_Of_Runs;
446*09a53ad8SAndrew Turner Dhrystones_Per_Second = (double) Number_Of_Runs / User_Time;
447*09a53ad8SAndrew Turner Vax_Mips = Dhrystones_Per_Second / 1757.0;
448*09a53ad8SAndrew Turner
449*09a53ad8SAndrew Turner printf ("Microseconds for one run through Dhrystone: ");
450*09a53ad8SAndrew Turner printf ("%12.2lf \n", Microseconds);
451*09a53ad8SAndrew Turner printf ("Dhrystones per Second: ");
452*09a53ad8SAndrew Turner printf ("%10.0lf \n", Dhrystones_Per_Second);
453*09a53ad8SAndrew Turner printf ("VAX MIPS rating = ");
454*09a53ad8SAndrew Turner printf ("%12.2lf \n",Vax_Mips);
455*09a53ad8SAndrew Turner printf ("\n");
456*09a53ad8SAndrew Turner
457*09a53ad8SAndrew Turner /************************************************************************
458*09a53ad8SAndrew Turner * Type details of hardware, software etc. *
459*09a53ad8SAndrew Turner ************************************************************************/
460*09a53ad8SAndrew Turner
461*09a53ad8SAndrew Turner if (getinput == 1)
462*09a53ad8SAndrew Turner {
463*09a53ad8SAndrew Turner printf ("Enter the following which will be added with results to file DHRY.TXT\n");
464*09a53ad8SAndrew Turner printf ("When submitting a number of results you need only provide details once\n");
465*09a53ad8SAndrew Turner printf ("but a cross reference such as an abbreviated CPU type would be useful.\n");
466*09a53ad8SAndrew Turner printf ("You can kill (exit or close) the program now and no data will be added.\n\n");
467*09a53ad8SAndrew Turner
468*09a53ad8SAndrew Turner printf ("PC Supplier/model ? ");
469*09a53ad8SAndrew Turner gets(general[1]);
470*09a53ad8SAndrew Turner
471*09a53ad8SAndrew Turner printf ("CPU chip ? ");
472*09a53ad8SAndrew Turner gets(general[2]);
473*09a53ad8SAndrew Turner
474*09a53ad8SAndrew Turner printf ("Clock MHz ? ");
475*09a53ad8SAndrew Turner gets(general[3]);
476*09a53ad8SAndrew Turner
477*09a53ad8SAndrew Turner printf ("Cache size ? ");
478*09a53ad8SAndrew Turner gets(general[4]);
479*09a53ad8SAndrew Turner
480*09a53ad8SAndrew Turner printf ("Chipset & H/W options ? ");
481*09a53ad8SAndrew Turner gets(general[5]);
482*09a53ad8SAndrew Turner
483*09a53ad8SAndrew Turner printf ("OS/DOS version ? ");
484*09a53ad8SAndrew Turner gets(general[6]);
485*09a53ad8SAndrew Turner
486*09a53ad8SAndrew Turner printf ("Your name ? ");
487*09a53ad8SAndrew Turner gets(general[7]);
488*09a53ad8SAndrew Turner
489*09a53ad8SAndrew Turner printf ("Company/Location ? ");
490*09a53ad8SAndrew Turner gets(general[8]);
491*09a53ad8SAndrew Turner
492*09a53ad8SAndrew Turner printf ("E-mail address ? ");
493*09a53ad8SAndrew Turner gets(general[0]);
494*09a53ad8SAndrew Turner }
495*09a53ad8SAndrew Turner /************************************************************************
496*09a53ad8SAndrew Turner * Add results to output file Dhry.txt *
497*09a53ad8SAndrew Turner ************************************************************************/
498*09a53ad8SAndrew Turner fprintf (Ap, "-------------------- -----------------------------------"
499*09a53ad8SAndrew Turner "\n");
500*09a53ad8SAndrew Turner fprintf (Ap, "Dhrystone Benchmark Version 2.1 (Language: C++)\n\n");
501*09a53ad8SAndrew Turner fprintf (Ap, "PC model %s\n", general[1]);
502*09a53ad8SAndrew Turner fprintf (Ap, "CPU %s\n", general[2]);
503*09a53ad8SAndrew Turner fprintf (Ap, "Clock MHz %s\n", general[3]);
504*09a53ad8SAndrew Turner fprintf (Ap, "Cache %s\n", general[4]);
505*09a53ad8SAndrew Turner fprintf (Ap, "Options %s\n", general[5]);
506*09a53ad8SAndrew Turner fprintf (Ap, "OS/DOS %s\n", general[6]);
507*09a53ad8SAndrew Turner fprintf (Ap, "Compiler %s\n", compiler);
508*09a53ad8SAndrew Turner fprintf (Ap, "OptLevel %s\n", options);
509*09a53ad8SAndrew Turner fprintf (Ap, "Run by %s\n", general[7]);
510*09a53ad8SAndrew Turner fprintf (Ap, "From %s\n", general[8]);
511*09a53ad8SAndrew Turner fprintf (Ap, "Mail %s\n\n", general[0]);
512*09a53ad8SAndrew Turner
513*09a53ad8SAndrew Turner fprintf (Ap, "Final values (* implementation-dependent):\n");
514*09a53ad8SAndrew Turner fprintf (Ap, "\n");
515*09a53ad8SAndrew Turner fprintf (Ap, "Int_Glob: ");
516*09a53ad8SAndrew Turner if (Int_Glob == 5) fprintf (Ap, "O.K. ");
517*09a53ad8SAndrew Turner else fprintf (Ap, "WRONG ");
518*09a53ad8SAndrew Turner fprintf (Ap, "%d\n", Int_Glob);
519*09a53ad8SAndrew Turner
520*09a53ad8SAndrew Turner fprintf (Ap, "Bool_Glob: ");
521*09a53ad8SAndrew Turner if (Bool_Glob == 1) fprintf (Ap, "O.K. ");
522*09a53ad8SAndrew Turner else fprintf (Ap, "WRONG ");
523*09a53ad8SAndrew Turner fprintf (Ap, "%d\n", Bool_Glob);
524*09a53ad8SAndrew Turner
525*09a53ad8SAndrew Turner fprintf (Ap, "Ch_1_Glob: ");
526*09a53ad8SAndrew Turner if (Ch_1_Glob == 'A') fprintf (Ap, "O.K. ");
527*09a53ad8SAndrew Turner else fprintf (Ap, "WRONG ");
528*09a53ad8SAndrew Turner fprintf (Ap, "%c\n", Ch_1_Glob);
529*09a53ad8SAndrew Turner
530*09a53ad8SAndrew Turner fprintf (Ap, "Ch_2_Glob: ");
531*09a53ad8SAndrew Turner if (Ch_2_Glob == 'B') fprintf (Ap, "O.K. ");
532*09a53ad8SAndrew Turner else fprintf (Ap, "WRONG ");
533*09a53ad8SAndrew Turner fprintf (Ap, "%c\n", Ch_2_Glob);
534*09a53ad8SAndrew Turner
535*09a53ad8SAndrew Turner fprintf (Ap, "Arr_1_Glob[8]: ");
536*09a53ad8SAndrew Turner if (Arr_1_Glob[8] == 7) fprintf (Ap, "O.K. ");
537*09a53ad8SAndrew Turner else fprintf (Ap, "WRONG ");
538*09a53ad8SAndrew Turner fprintf (Ap, "%d\n", Arr_1_Glob[8]);
539*09a53ad8SAndrew Turner
540*09a53ad8SAndrew Turner fprintf (Ap, "Arr_2_Glob8/7: ");
541*09a53ad8SAndrew Turner if (Arr_2_Glob[8][7] == Number_Of_Runs + 10)
542*09a53ad8SAndrew Turner fprintf (Ap, "O.K. ");
543*09a53ad8SAndrew Turner else fprintf (Ap, "WRONG ");
544*09a53ad8SAndrew Turner fprintf (Ap, "%10d\n", Arr_2_Glob[8][7]);
545*09a53ad8SAndrew Turner
546*09a53ad8SAndrew Turner fprintf (Ap, "Ptr_Glob-> \n");
547*09a53ad8SAndrew Turner fprintf (Ap, " Ptr_Comp: * %d\n", (int) Ptr_Glob->Ptr_Comp);
548*09a53ad8SAndrew Turner
549*09a53ad8SAndrew Turner fprintf (Ap, " Discr: ");
550*09a53ad8SAndrew Turner if (Ptr_Glob->Discr == 0) fprintf (Ap, "O.K. ");
551*09a53ad8SAndrew Turner else fprintf (Ap, "WRONG ");
552*09a53ad8SAndrew Turner fprintf (Ap, "%d\n", Ptr_Glob->Discr);
553*09a53ad8SAndrew Turner
554*09a53ad8SAndrew Turner fprintf (Ap, " Enum_Comp: ");
555*09a53ad8SAndrew Turner if (Ptr_Glob->variant.var_1.Enum_Comp == 2)
556*09a53ad8SAndrew Turner fprintf (Ap, "O.K. ");
557*09a53ad8SAndrew Turner else fprintf (Ap, "WRONG ");
558*09a53ad8SAndrew Turner fprintf (Ap, "%d\n", Ptr_Glob->variant.var_1.Enum_Comp);
559*09a53ad8SAndrew Turner
560*09a53ad8SAndrew Turner fprintf (Ap, " Int_Comp: ");
561*09a53ad8SAndrew Turner if (Ptr_Glob->variant.var_1.Int_Comp == 17) fprintf (Ap, "O.K. ");
562*09a53ad8SAndrew Turner else fprintf (Ap, "WRONG ");
563*09a53ad8SAndrew Turner fprintf (Ap, "%d\n", Ptr_Glob->variant.var_1.Int_Comp);
564*09a53ad8SAndrew Turner
565*09a53ad8SAndrew Turner fprintf (Ap, " Str_Comp: ");
566*09a53ad8SAndrew Turner if (strcmp(Ptr_Glob->variant.var_1.Str_Comp,
567*09a53ad8SAndrew Turner "DHRYSTONE PROGRAM, SOME STRING") == 0)
568*09a53ad8SAndrew Turner fprintf (Ap, "O.K. ");
569*09a53ad8SAndrew Turner else fprintf (Ap, "WRONG ");
570*09a53ad8SAndrew Turner fprintf (Ap, "%s\n", Ptr_Glob->variant.var_1.Str_Comp);
571*09a53ad8SAndrew Turner
572*09a53ad8SAndrew Turner fprintf (Ap, "Next_Ptr_Glob-> \n");
573*09a53ad8SAndrew Turner fprintf (Ap, " Ptr_Comp: * %d", (int) Next_Ptr_Glob->Ptr_Comp);
574*09a53ad8SAndrew Turner fprintf (Ap, " same as above\n");
575*09a53ad8SAndrew Turner
576*09a53ad8SAndrew Turner fprintf (Ap, " Discr: ");
577*09a53ad8SAndrew Turner if (Next_Ptr_Glob->Discr == 0)
578*09a53ad8SAndrew Turner fprintf (Ap, "O.K. ");
579*09a53ad8SAndrew Turner else fprintf (Ap, "WRONG ");
580*09a53ad8SAndrew Turner fprintf (Ap, "%d\n", Next_Ptr_Glob->Discr);
581*09a53ad8SAndrew Turner
582*09a53ad8SAndrew Turner fprintf (Ap, " Enum_Comp: ");
583*09a53ad8SAndrew Turner if (Next_Ptr_Glob->variant.var_1.Enum_Comp == 1)
584*09a53ad8SAndrew Turner fprintf (Ap, "O.K. ");
585*09a53ad8SAndrew Turner else fprintf (Ap, "WRONG ");
586*09a53ad8SAndrew Turner fprintf (Ap, "%d\n", Next_Ptr_Glob->variant.var_1.Enum_Comp);
587*09a53ad8SAndrew Turner
588*09a53ad8SAndrew Turner fprintf (Ap, " Int_Comp: ");
589*09a53ad8SAndrew Turner if (Next_Ptr_Glob->variant.var_1.Int_Comp == 18)
590*09a53ad8SAndrew Turner fprintf (Ap, "O.K. ");
591*09a53ad8SAndrew Turner else fprintf (Ap, "WRONG ");
592*09a53ad8SAndrew Turner fprintf (Ap, "%d\n", Next_Ptr_Glob->variant.var_1.Int_Comp);
593*09a53ad8SAndrew Turner
594*09a53ad8SAndrew Turner fprintf (Ap, " Str_Comp: ");
595*09a53ad8SAndrew Turner if (strcmp(Next_Ptr_Glob->variant.var_1.Str_Comp,
596*09a53ad8SAndrew Turner "DHRYSTONE PROGRAM, SOME STRING") == 0)
597*09a53ad8SAndrew Turner fprintf (Ap, "O.K. ");
598*09a53ad8SAndrew Turner else fprintf (Ap, "WRONG ");
599*09a53ad8SAndrew Turner fprintf (Ap, "%s\n", Next_Ptr_Glob->variant.var_1.Str_Comp);
600*09a53ad8SAndrew Turner
601*09a53ad8SAndrew Turner fprintf (Ap, "Int_1_Loc: ");
602*09a53ad8SAndrew Turner if (Int_1_Loc == 5)
603*09a53ad8SAndrew Turner fprintf (Ap, "O.K. ");
604*09a53ad8SAndrew Turner else fprintf (Ap, "WRONG ");
605*09a53ad8SAndrew Turner fprintf (Ap, "%d\n", Int_1_Loc);
606*09a53ad8SAndrew Turner
607*09a53ad8SAndrew Turner fprintf (Ap, "Int_2_Loc: ");
608*09a53ad8SAndrew Turner if (Int_2_Loc == 13)
609*09a53ad8SAndrew Turner fprintf (Ap, "O.K. ");
610*09a53ad8SAndrew Turner else fprintf (Ap, "WRONG ");
611*09a53ad8SAndrew Turner fprintf (Ap, "%d\n", Int_2_Loc);
612*09a53ad8SAndrew Turner
613*09a53ad8SAndrew Turner fprintf (Ap, "Int_3_Loc: ");
614*09a53ad8SAndrew Turner if (Int_3_Loc == 7)
615*09a53ad8SAndrew Turner fprintf (Ap, "O.K. ");
616*09a53ad8SAndrew Turner else fprintf (Ap, "WRONG ");
617*09a53ad8SAndrew Turner fprintf (Ap, "%d\n", Int_3_Loc);
618*09a53ad8SAndrew Turner
619*09a53ad8SAndrew Turner fprintf (Ap, "Enum_Loc: ");
620*09a53ad8SAndrew Turner if (Enum_Loc == 1)
621*09a53ad8SAndrew Turner fprintf (Ap, "O.K. ");
622*09a53ad8SAndrew Turner else fprintf (Ap, "WRONG ");
623*09a53ad8SAndrew Turner fprintf (Ap, "%d\n", Enum_Loc);
624*09a53ad8SAndrew Turner
625*09a53ad8SAndrew Turner fprintf (Ap, "Str_1_Loc: ");
626*09a53ad8SAndrew Turner if (strcmp(Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING") == 0)
627*09a53ad8SAndrew Turner fprintf (Ap, "O.K. ");
628*09a53ad8SAndrew Turner else fprintf (Ap, "WRONG ");
629*09a53ad8SAndrew Turner fprintf (Ap, "%s\n", Str_1_Loc);
630*09a53ad8SAndrew Turner
631*09a53ad8SAndrew Turner fprintf (Ap, "Str_2_Loc: ");
632*09a53ad8SAndrew Turner if (strcmp(Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING") == 0)
633*09a53ad8SAndrew Turner fprintf (Ap, "O.K. ");
634*09a53ad8SAndrew Turner else fprintf (Ap, "WRONG ");
635*09a53ad8SAndrew Turner fprintf (Ap, "%s\n", Str_2_Loc);
636*09a53ad8SAndrew Turner
637*09a53ad8SAndrew Turner
638*09a53ad8SAndrew Turner fprintf (Ap, "\n");
639*09a53ad8SAndrew Turner fprintf(Ap,"%s\n",Reg_Define);
640*09a53ad8SAndrew Turner fprintf (Ap, "\n");
641*09a53ad8SAndrew Turner fprintf(Ap,"Microseconds 1 loop: %12.2lf\n",Microseconds);
642*09a53ad8SAndrew Turner fprintf(Ap,"Dhrystones / second: %10.0lf\n",Dhrystones_Per_Second);
643*09a53ad8SAndrew Turner fprintf(Ap,"VAX MIPS rating: %12.2lf\n\n",Vax_Mips);
644*09a53ad8SAndrew Turner fclose(Ap);
645*09a53ad8SAndrew Turner }
646*09a53ad8SAndrew Turner
647*09a53ad8SAndrew Turner printf ("\n");
648*09a53ad8SAndrew Turner printf ("A new results file will have been created in the same directory as the\n");
649*09a53ad8SAndrew Turner printf (".EXE files if one did not already exist. If you made a mistake on input, \n");
650*09a53ad8SAndrew Turner printf ("you can use a text editor to correct it, delete the results or copy \n");
651*09a53ad8SAndrew Turner printf ("them to a different file name. If you intend to run multiple tests you\n");
652*09a53ad8SAndrew Turner printf ("you may wish to rename DHRY.TXT with a more informative title.\n\n");
653*09a53ad8SAndrew Turner printf ("Please submit feedback and results files as a posting in Section 12\n");
654*09a53ad8SAndrew Turner printf ("or to Roy_Longbottom@compuserve.com\n\n");
655*09a53ad8SAndrew Turner
656*09a53ad8SAndrew Turner if (getinput == 1)
657*09a53ad8SAndrew Turner {
658*09a53ad8SAndrew Turner printf("Press any key to exit\n");
659*09a53ad8SAndrew Turner printf ("\nIf this is displayed you must close the window in the normal way\n");
660*09a53ad8SAndrew Turner }
661*09a53ad8SAndrew Turner }
662*09a53ad8SAndrew Turner
663*09a53ad8SAndrew Turner
Proc_1(REG Rec_Pointer Ptr_Val_Par)664*09a53ad8SAndrew Turner void Proc_1 (REG Rec_Pointer Ptr_Val_Par)
665*09a53ad8SAndrew Turner /******************/
666*09a53ad8SAndrew Turner
667*09a53ad8SAndrew Turner /* executed once */
668*09a53ad8SAndrew Turner {
669*09a53ad8SAndrew Turner REG Rec_Pointer Next_Record = Ptr_Val_Par->Ptr_Comp;
670*09a53ad8SAndrew Turner /* == Ptr_Glob_Next */
671*09a53ad8SAndrew Turner /* Local variable, initialized with Ptr_Val_Par->Ptr_Comp, */
672*09a53ad8SAndrew Turner /* corresponds to "rename" in Ada, "with" in Pascal */
673*09a53ad8SAndrew Turner
674*09a53ad8SAndrew Turner structassign (*Ptr_Val_Par->Ptr_Comp, *Ptr_Glob);
675*09a53ad8SAndrew Turner Ptr_Val_Par->variant.var_1.Int_Comp = 5;
676*09a53ad8SAndrew Turner Next_Record->variant.var_1.Int_Comp
677*09a53ad8SAndrew Turner = Ptr_Val_Par->variant.var_1.Int_Comp;
678*09a53ad8SAndrew Turner Next_Record->Ptr_Comp = Ptr_Val_Par->Ptr_Comp;
679*09a53ad8SAndrew Turner Proc_3 (&Next_Record->Ptr_Comp);
680*09a53ad8SAndrew Turner /* Ptr_Val_Par->Ptr_Comp->Ptr_Comp
681*09a53ad8SAndrew Turner == Ptr_Glob->Ptr_Comp */
682*09a53ad8SAndrew Turner if (Next_Record->Discr == Ident_1)
683*09a53ad8SAndrew Turner /* then, executed */
684*09a53ad8SAndrew Turner {
685*09a53ad8SAndrew Turner Next_Record->variant.var_1.Int_Comp = 6;
686*09a53ad8SAndrew Turner Proc_6 (Ptr_Val_Par->variant.var_1.Enum_Comp,
687*09a53ad8SAndrew Turner &Next_Record->variant.var_1.Enum_Comp);
688*09a53ad8SAndrew Turner Next_Record->Ptr_Comp = Ptr_Glob->Ptr_Comp;
689*09a53ad8SAndrew Turner Proc_7 (Next_Record->variant.var_1.Int_Comp, 10,
690*09a53ad8SAndrew Turner &Next_Record->variant.var_1.Int_Comp);
691*09a53ad8SAndrew Turner }
692*09a53ad8SAndrew Turner else /* not executed */
693*09a53ad8SAndrew Turner structassign (*Ptr_Val_Par, *Ptr_Val_Par->Ptr_Comp);
694*09a53ad8SAndrew Turner } /* Proc_1 */
695*09a53ad8SAndrew Turner
696*09a53ad8SAndrew Turner
Proc_2(One_Fifty * Int_Par_Ref)697*09a53ad8SAndrew Turner void Proc_2 (One_Fifty *Int_Par_Ref)
698*09a53ad8SAndrew Turner /******************/
699*09a53ad8SAndrew Turner /* executed once */
700*09a53ad8SAndrew Turner /* *Int_Par_Ref == 1, becomes 4 */
701*09a53ad8SAndrew Turner
702*09a53ad8SAndrew Turner {
703*09a53ad8SAndrew Turner One_Fifty Int_Loc;
704*09a53ad8SAndrew Turner Enumeration Enum_Loc;
705*09a53ad8SAndrew Turner
706*09a53ad8SAndrew Turner Int_Loc = *Int_Par_Ref + 10;
707*09a53ad8SAndrew Turner do /* executed once */
708*09a53ad8SAndrew Turner if (Ch_1_Glob == 'A')
709*09a53ad8SAndrew Turner /* then, executed */
710*09a53ad8SAndrew Turner {
711*09a53ad8SAndrew Turner Int_Loc -= 1;
712*09a53ad8SAndrew Turner *Int_Par_Ref = Int_Loc - Int_Glob;
713*09a53ad8SAndrew Turner Enum_Loc = Ident_1;
714*09a53ad8SAndrew Turner } /* if */
715*09a53ad8SAndrew Turner while (Enum_Loc != Ident_1); /* true */
716*09a53ad8SAndrew Turner } /* Proc_2 */
717*09a53ad8SAndrew Turner
718*09a53ad8SAndrew Turner
Proc_3(Rec_Pointer * Ptr_Ref_Par)719*09a53ad8SAndrew Turner void Proc_3 (Rec_Pointer *Ptr_Ref_Par)
720*09a53ad8SAndrew Turner /******************/
721*09a53ad8SAndrew Turner /* executed once */
722*09a53ad8SAndrew Turner /* Ptr_Ref_Par becomes Ptr_Glob */
723*09a53ad8SAndrew Turner
724*09a53ad8SAndrew Turner {
725*09a53ad8SAndrew Turner if (Ptr_Glob != Null)
726*09a53ad8SAndrew Turner /* then, executed */
727*09a53ad8SAndrew Turner *Ptr_Ref_Par = Ptr_Glob->Ptr_Comp;
728*09a53ad8SAndrew Turner Proc_7 (10, Int_Glob, &Ptr_Glob->variant.var_1.Int_Comp);
729*09a53ad8SAndrew Turner } /* Proc_3 */
730*09a53ad8SAndrew Turner
731*09a53ad8SAndrew Turner
Proc_4()732*09a53ad8SAndrew Turner void Proc_4 () /* without parameters */
733*09a53ad8SAndrew Turner /*******/
734*09a53ad8SAndrew Turner /* executed once */
735*09a53ad8SAndrew Turner {
736*09a53ad8SAndrew Turner Boolean Bool_Loc;
737*09a53ad8SAndrew Turner
738*09a53ad8SAndrew Turner Bool_Loc = Ch_1_Glob == 'A';
739*09a53ad8SAndrew Turner Bool_Glob = Bool_Loc | Bool_Glob;
740*09a53ad8SAndrew Turner Ch_2_Glob = 'B';
741*09a53ad8SAndrew Turner } /* Proc_4 */
742*09a53ad8SAndrew Turner
743*09a53ad8SAndrew Turner
Proc_5()744*09a53ad8SAndrew Turner void Proc_5 () /* without parameters */
745*09a53ad8SAndrew Turner /*******/
746*09a53ad8SAndrew Turner /* executed once */
747*09a53ad8SAndrew Turner {
748*09a53ad8SAndrew Turner Ch_1_Glob = 'A';
749*09a53ad8SAndrew Turner Bool_Glob = false;
750*09a53ad8SAndrew Turner } /* Proc_5 */
751*09a53ad8SAndrew Turner
752*09a53ad8SAndrew Turner
753*09a53ad8SAndrew Turner /* Procedure for the assignment of structures, */
754*09a53ad8SAndrew Turner /* if the C compiler doesn't support this feature */
755*09a53ad8SAndrew Turner #ifdef NOSTRUCTASSIGN
memcpy(d,s,l)756*09a53ad8SAndrew Turner memcpy (d, s, l)
757*09a53ad8SAndrew Turner register char *d;
758*09a53ad8SAndrew Turner register char *s;
759*09a53ad8SAndrew Turner register int l;
760*09a53ad8SAndrew Turner {
761*09a53ad8SAndrew Turner while (l--) *d++ = *s++;
762*09a53ad8SAndrew Turner }
763*09a53ad8SAndrew Turner #endif
764*09a53ad8SAndrew Turner
765*09a53ad8SAndrew Turner
dtime()766*09a53ad8SAndrew Turner double dtime()
767*09a53ad8SAndrew Turner {
768*09a53ad8SAndrew Turner
769*09a53ad8SAndrew Turner /* #include <ctype.h> */
770*09a53ad8SAndrew Turner
771*09a53ad8SAndrew Turner #define HZ CLOCKS_PER_SEC
772*09a53ad8SAndrew Turner clock_t tnow;
773*09a53ad8SAndrew Turner
774*09a53ad8SAndrew Turner double q;
775*09a53ad8SAndrew Turner tnow = clock();
776*09a53ad8SAndrew Turner q = (double)tnow / (double)HZ;
777*09a53ad8SAndrew Turner return q;
778*09a53ad8SAndrew Turner }
779