OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [bootloaders/] [orpmon/] [cmds/] [dhry.c] - Blame information for rev 355

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 marcus.erl
/*
2
 ****************************************************************************
3
 *
4
 *                   "DHRYSTONE" Benchmark Program
5
 *                   -----------------------------
6
 *
7
 *  Version:    C, Version 2.1
8
 *
9
 *  File:       dhry_1.c (part 2 of 3)
10
 *
11
 *  Date:       May 25, 1988
12
 *
13
 *  Author:     Reinhold P. Weicker
14
 *
15
 ****************************************************************************
16
 */
17
#include "dhry.h"
18 246 julius
#include "spr-defs.h"
19 2 marcus.erl
#include "common.h"
20
#include "support.h"
21
 
22
#define PROC_6 0
23
 
24
#define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080)
25
#define UNALIGNED(X, Y) \
26
  (((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1)))
27
 
28
void start_timer(void)
29
{
30
        unsigned long val;
31
 
32
        val = SPR_TTMR_SR | 0x0fffffff;
33
        asm("l.mtspr    r0,%0,%1": : "r" (val), "i" (SPR_TTMR));
34
        val = 0;
35
        asm("l.mtspr    r0,%0,%1": : "r" (val), "i" (SPR_TTCR));
36
}
37
 
38
unsigned long read_timer(void)
39
{
40 140 julius
#if 0
41 2 marcus.erl
        unsigned long val;
42
 
43
        asm("l.mfspr    %0,r0,%1": "=r" (val) : "i" (SPR_TTCR));
44
        return val;
45 140 julius
#else
46
        return timestamp;
47
#endif
48 2 marcus.erl
}
49
 
50
/* Global Variables: */
51
 
52
Rec_Pointer     Ptr_Glob,
53
                Next_Ptr_Glob;
54
int             Int_Glob;
55
Boolean         Bool_Glob;
56
char            Ch_1_Glob,
57
                Ch_2_Glob;
58
int             Arr_1_Glob [50];
59
int             Arr_2_Glob [50] [50];
60
 
61
 
62
  /* forward declaration necessary since Enumeration may not simply be int */
63
 
64
#ifndef REG
65
        Boolean Reg = false;
66
#define REG
67
        /* REG becomes defined as empty */
68
        /* i.e. no register variables   */
69
#else
70
        Boolean Reg = true;
71
#endif
72
 
73
/* variables for time measurement: */
74
 
75 140 julius
#define Too_Small_Time US_PER_TICK
76 2 marcus.erl
 
77 140 julius
 
78 2 marcus.erl
#define TIMER0 0
79
#define TIMER1 1
80
 
81
 
82
 
83
 
84
 
85
unsigned int    Begin_Time,
86
                End_Time,
87
                User_Time,
88
                Microseconds,
89
                Dhrystones_Per_Second;
90
 
91
/* end of variables for time measurement */
92
 
93
 
94
void Proc_1(REG Rec_Pointer Ptr_Val_Par);
95
void Proc_2(One_Fifty      *Int_Par_Ref);
96
void Proc_3(Rec_Pointer    *Ptr_Ref_Par);
97
void Proc_4(void);
98
void Proc_5(void);
99
void Proc_6(
100
    Enumeration     Enum_Val_Par,
101
    Enumeration    *Enum_Ref_Par);
102
void Proc_7(
103
    One_Fifty       Int_1_Par_Val,
104
    One_Fifty       Int_2_Par_Val,
105
    One_Fifty      *Int_Par_Ref);
106
void Proc_8(
107
    Arr_1_Dim       Arr_1_Par_Ref,
108
    Arr_2_Dim       Arr_2_Par_Ref,
109
    int             Int_1_Par_Val,
110
    int             Int_2_Par_Val);
111
Enumeration Func_1(Capital_Letter Ch_1_Par_Val,
112
                   Capital_Letter Ch_2_Par_Val);
113
Boolean Func_2(Str_30 Str_1_Par_Ref, Str_30 Str_2_Par_Ref);
114
Boolean Func_3(Enumeration     Enum_Par_Val);
115
 
116
int dhry_main (int num_runs)
117
/*****/
118
 
119
  /* main program, corresponds to procedures        */
120
  /* Main and Proc_0 in the Ada version             */
121
{
122
        One_Fifty       Int_1_Loc;
123
  REG   One_Fifty       Int_2_Loc;
124
        One_Fifty       Int_3_Loc;
125
  REG   char            Ch_Index;
126
        Enumeration     Enum_Loc;
127
        Str_30          Str_1_Loc;
128
        Str_30          Str_2_Loc;
129
  REG   int             Run_Index;
130
  REG   int             Number_Of_Runs;
131
  Rec_Type              x, y;
132
 
133
  /* Initializations */
134
 
135
  Next_Ptr_Glob = (Rec_Pointer) &x;
136
  Ptr_Glob = (Rec_Pointer) &y;
137
 
138
  Ptr_Glob->Ptr_Comp                    = Next_Ptr_Glob;
139
  Ptr_Glob->Discr                       = Ident_1;
140
  Ptr_Glob->variant.var_1.Enum_Comp     = Ident_3;
141
  Ptr_Glob->variant.var_1.Int_Comp      = 40;
142
  strcpy (Ptr_Glob->variant.var_1.Str_Comp,
143
          "DHRYSTONE PROGRAM, SOME STRING");
144
  strcpy (Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING");
145
 
146
  Arr_2_Glob [8][7] = 10;
147
        /* Was missing in published program. Without this statement,    */
148
        /* Arr_2_Glob [8][7] would have an undefined value.             */
149
        /* Warning: With 16-Bit processors and Number_Of_Runs > 32000,  */
150
        /* overflow may occur for this array element.                   */
151
 
152
/* Initalize Data and Instruction Cache */
153
 
154
 
155
/*  printf ("\n");
156
  printf ("Dhrystone Benchmark, Version 2.1 (Language: C)\n");
157
  printf ("\n");
158
  if (Reg)
159
  {
160
    printf ("Program compiled with 'register' attribute\n");
161
    printf ("\n");
162
  }
163
  else
164
  {
165
    printf ("Program compiled without 'register' attribute\n");
166
    printf ("\n");
167
  }
168
  printf ("Please give the number of runs through the benchmark: ");
169
 */
170
  {
171
    int n;
172
    /* scanf ("%d", &n);
173
 */
174
    n = num_runs;
175
    Number_Of_Runs = n;
176
  }
177
  printf ("\n");
178
 
179
  printf ("Execution starts, %d runs through Dhrystone\n", Number_Of_Runs);
180
 
181
 
182
  /***************/
183
  /* Start timer */
184
  /***************/
185
 
186
/*  printf("%d", my_test2(Number_Of_Runs));*/
187 140 julius
  //start_timer();
188
  Begin_Time = read_timer();
189 2 marcus.erl
 
190
  for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index)
191
  {
192
 
193
    Proc_5();
194
    Proc_4();
195
      /* Ch_1_Glob == 'A', Ch_2_Glob == 'B', Bool_Glob == true */
196
    Int_1_Loc = 2;
197
    Int_2_Loc = 3;
198
    strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
199
    Enum_Loc = Ident_2;
200
 
201
    Bool_Glob = ! Func_2 (Str_1_Loc, Str_2_Loc);
202
      /* Bool_Glob == 1 */
203
    while (Int_1_Loc < Int_2_Loc)  /* loop body executed once */
204
    {
205
      Int_3_Loc = 5 * Int_1_Loc - Int_2_Loc;
206
        /* Int_3_Loc == 7 */
207
      Proc_7 (Int_1_Loc, Int_2_Loc, &Int_3_Loc);
208
        /* Int_3_Loc == 7 */
209
      Int_1_Loc += 1;
210
    } /* while */
211
      /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
212
#if DBG
213
      printf("a) Int_1_Loc: %x\n", Int_1_Loc);
214
      printf("a) Int_2_Loc: %x\n", Int_2_Loc);
215
      printf("a) Int_3_Loc: %x\n\n", Int_3_Loc);
216
#endif
217
    Proc_8 (Arr_1_Glob, Arr_2_Glob, Int_1_Loc, Int_3_Loc);
218
      /* Int_Glob == 5 */
219
#if DBG
220
      printf("b) Int_1_Loc: %x\n", Int_1_Loc);
221
      printf("b) Int_2_Loc: %x\n", Int_2_Loc);
222
      printf("b) Int_3_Loc: %x\n\n", Int_3_Loc);
223
#endif
224
 
225
    Proc_1 (Ptr_Glob);
226
#if DBG
227
      printf("c) Int_1_Loc: %x\n", Int_1_Loc);
228
      printf("c) Int_2_Loc: %x\n", Int_2_Loc);
229
      printf("c) Int_3_Loc: %x\n\n", Int_3_Loc);
230
#endif
231
 
232
    for (Ch_Index = 'A'; Ch_Index <= Ch_2_Glob; ++Ch_Index)
233
                             /* loop body executed twice */
234
    {
235
      if (Enum_Loc == Func_1 (Ch_Index, 'C'))
236
          /* then, not executed */
237
        {
238
        Proc_6 (Ident_1, &Enum_Loc);
239
        strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING");
240
        Int_2_Loc = Run_Index;
241
        Int_Glob = Run_Index;
242
#if DBG
243
      printf("d) Int_1_Loc: %x\n", Int_1_Loc);
244
      printf("d) Int_2_Loc: %x\n", Int_2_Loc);
245
      printf("d) Int_3_Loc: %x\n\n", Int_3_Loc);
246
#endif
247
        }
248
    }
249
 
250
      /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
251
#if DBG
252
      printf("e) Int_1_Loc: %x\n", Int_1_Loc);
253
      printf("e) Int_2_Loc: %x\n", Int_2_Loc);
254
      printf("e) Int_3_Loc: %x\n", Int_3_Loc);
255
      printf("e) Ch_1_Glob: %c\n\n", Ch_1_Glob);
256
#endif
257
    Int_2_Loc = Int_2_Loc * Int_1_Loc;
258
    Int_1_Loc = Int_2_Loc * Int_3_Loc;
259
    Int_2_Loc = 7 * (Int_2_Loc - Int_3_Loc) - Int_1_Loc;
260
      /* Int_1_Loc == 1, Int_2_Loc == 13, Int_3_Loc == 7 */
261
    Proc_2 (&Int_1_Loc);
262
 
263
      /* Int_1_Loc == 5 */
264
#if DBG
265
      printf("f) Int_1_Loc: %x\n", Int_1_Loc);
266
      printf("f) Int_2_Loc: %x\n", Int_2_Loc);
267
      printf("f) Int_3_Loc: %x\n\n", Int_3_Loc);
268
#endif
269
 
270
  } /* loop "for Run_Index" */
271
 
272
  /**************/
273
  /* Stop timer */
274
  /**************/
275
 
276
  End_Time = read_timer();
277
 
278
/*  printf ("Execution ends\n");
279
  printf ("\n");
280
  printf ("Final values of the variables used in the benchmark:\n");
281
  printf ("\n");
282
  printf ("Int_Glob:            %d\n", Int_Glob);
283
  printf ("        should be:   %d\n", 5);
284
  printf ("Bool_Glob:           %d\n", Bool_Glob);
285
  printf ("        should be:   %d\n", 1);
286
  printf ("Ch_1_Glob:           %c\n", Ch_1_Glob);
287
  printf ("        should be:   %c\n", 'A');
288
  printf ("Ch_2_Glob:           %c\n", Ch_2_Glob);
289
  printf ("        should be:   %c\n", 'B');
290
  printf ("Arr_1_Glob[8]:       %d\n", Arr_1_Glob[8]);
291
  printf ("        should be:   %d\n", 7);
292
  printf ("Arr_2_Glob[8][7]:    %d\n", Arr_2_Glob[8][7]);
293
  printf ("        should be:   Number_Of_Runs + 10\n");
294
  printf ("Ptr_Glob->\n");
295
  printf ("  Ptr_Comp:          %d\n", (int) Ptr_Glob->Ptr_Comp);
296
  printf ("        should be:   (implementation-dependent)\n");
297
  printf ("  Discr:             %d\n", Ptr_Glob->Discr);
298
  printf ("        should be:   %d\n", 0);
299
  printf ("  Enum_Comp:         %d\n", Ptr_Glob->variant.var_1.Enum_Comp);
300
  printf ("        should be:   %d\n", 2);
301
  printf ("  Int_Comp:          %d\n", Ptr_Glob->variant.var_1.Int_Comp);
302
  printf ("        should be:   %d\n", 17);
303
  printf ("  Str_Comp:          %s\n", Ptr_Glob->variant.var_1.Str_Comp);
304
  printf ("        should be:   DHRYSTONE PROGRAM, SOME STRING\n");
305
  printf ("Next_Ptr_Glob->\n");
306
  printf ("  Ptr_Comp:          %d\n", (int) Next_Ptr_Glob->Ptr_Comp);
307
  printf ("        should be:   (implementation-dependent), same as above\n");
308
  printf ("  Discr:             %d\n", Next_Ptr_Glob->Discr);
309
  printf ("        should be:   %d\n", 0);
310
  printf ("  Enum_Comp:         %d\n", Next_Ptr_Glob->variant.var_1.Enum_Comp);
311
  printf ("        should be:   %d\n", 1);
312
  printf ("  Int_Comp:          %d\n", Next_Ptr_Glob->variant.var_1.Int_Comp);
313
  printf ("        should be:   %d\n", 18);
314
  printf ("  Str_Comp:          %s\n",
315
                                Next_Ptr_Glob->variant.var_1.Str_Comp);
316
  printf ("        should be:   DHRYSTONE PROGRAM, SOME STRING\n");
317
  printf ("Int_1_Loc:           %d\n", Int_1_Loc);
318
  printf ("        should be:   %d\n", 5);
319
  printf ("Int_2_Loc:           %d\n", Int_2_Loc);
320
  printf ("        should be:   %d\n", 13);
321
  printf ("Int_3_Loc:           %d\n", Int_3_Loc);
322
  printf ("        should be:   %d\n", 7);
323
  printf ("Enum_Loc:            %d\n", Enum_Loc);
324
  printf ("        should be:   %d\n", 1);
325
  printf ("Str_1_Loc:           %s\n", Str_1_Loc);
326
  printf ("        should be:   DHRYSTONE PROGRAM, 1'ST STRING\n");
327
  printf ("Str_2_Loc:           %s\n", Str_2_Loc);
328
  printf ("        should be:   DHRYSTONE PROGRAM, 2'ND STRING\n");
329
 
330
*/
331
 
332
 
333 140 julius
 
334 2 marcus.erl
  User_Time = End_Time - Begin_Time;
335
 
336 355 julius
  printf("Timer ticks, %d/Sec, (%d - %d) =\t%d\n",TICKS_PER_SEC,
337
         End_Time, Begin_Time, User_Time);
338 2 marcus.erl
 
339 140 julius
 /* microseconds */
340
 
341 2 marcus.erl
  printf ("\nNumber of Runs %i", num_runs);
342 355 julius
  printf ("\nElapsed time %d.%d%ds\n",
343
          (User_Time/TICKS_PER_SEC),
344
          (User_Time/(TICKS_PER_SEC/10))%10,
345
          (User_Time/( TICKS_PER_SEC/100))%10);
346 2 marcus.erl
 
347 140 julius
 
348 355 julius
  if (User_Time < (5*TICKS_PER_SEC))
349 2 marcus.erl
  {
350
    printf ("Measured time too small to obtain meaningful results\n");
351
    printf ("Please increase number of runs\n");
352
    printf ("\n");
353
  }
354
  else
355
  {
356 140 julius
    printf("Processor at %d MHz\n",(IN_CLK/1000000));
357
 
358 355 julius
 
359
    // User_Time is ticks in resolution TICKS_PER_SEC, so to convert to uS
360
    Microseconds = (User_Time * (1000000/TICKS_PER_SEC));
361
 
362
    Dhrystones_Per_Second = Number_Of_Runs / (User_Time/TICKS_PER_SEC);
363
 
364 2 marcus.erl
    printf ("Microseconds for one run through Dhrystone: ");
365 355 julius
    printf ("( %d uS / %dk ) = %d uS\n", Microseconds,(Number_Of_Runs/1000),
366
            Microseconds / Number_Of_Runs);
367 2 marcus.erl
    printf ("Dhrystones per Second:                      ");
368
    printf ("%d \n", Dhrystones_Per_Second);
369
  }
370
  return 0;
371
}
372
 
373
 
374
void Proc_1(Ptr_Val_Par)
375
/******************/
376
 
377
        REG Rec_Pointer Ptr_Val_Par;
378
 /* executed once */
379
{
380
        REG Rec_Pointer Next_Record = Ptr_Val_Par->Ptr_Comp;
381
        /* == Ptr_Glob_Next */
382
        /* Local variable, initialized with Ptr_Val_Par->Ptr_Comp,    */
383
        /* corresponds to "rename" in Ada, "with" in Pascal           */
384
 
385
 
386
        structassign(*Ptr_Val_Par->Ptr_Comp, *Ptr_Glob);
387
        Ptr_Val_Par->variant.var_1.Int_Comp = 5;
388
        Next_Record->variant.var_1.Int_Comp
389
        = Ptr_Val_Par->variant.var_1.Int_Comp;
390
        Next_Record->Ptr_Comp = Ptr_Val_Par->Ptr_Comp;
391
        Proc_3(&Next_Record->Ptr_Comp);
392
        /*
393
         * Ptr_Val_Par->Ptr_Comp->Ptr_Comp == Ptr_Glob->Ptr_Comp
394
         */
395
        if (Next_Record->Discr == Ident_1)
396
        /* then, executed */
397
        {
398
        Next_Record->variant.var_1.Int_Comp = 6;
399
        Proc_6(Ptr_Val_Par->variant.var_1.Enum_Comp,
400
                   &Next_Record->variant.var_1.Enum_Comp);
401
        Next_Record->Ptr_Comp = Ptr_Glob->Ptr_Comp;
402
        Proc_7(Next_Record->variant.var_1.Int_Comp, 10,
403
                   &Next_Record->variant.var_1.Int_Comp);
404
        } else          /* not executed */
405
        structassign(*Ptr_Val_Par, *Ptr_Val_Par->Ptr_Comp);
406
 
407
}               /* Proc_1 */
408
 
409
 
410
void
411
  Proc_2(Int_Par_Ref)
412
/******************/
413
 /* executed once */
414
 /* *Int_Par_Ref == 1, becomes 4 */
415
 
416
        One_Fifty      *Int_Par_Ref;
417
{
418
        One_Fifty       Int_Loc;
419
        Enumeration     Enum_Loc = 0;
420
 
421
 
422
        Int_Loc = *Int_Par_Ref + 10;
423
        do              /* executed once */
424
        if (Ch_1_Glob == 'A')
425
                /* then, executed */
426
        {
427
                Int_Loc -= 1;
428
                *Int_Par_Ref = Int_Loc - Int_Glob;
429
                Enum_Loc = Ident_1;
430
        }           /* if */
431
        while (Enum_Loc != Ident_1);/* true */
432
}               /* Proc_2 */
433
 
434
 
435
void
436
  Proc_3(Ptr_Ref_Par)
437
/******************/
438
 /* executed once */
439
 /* Ptr_Ref_Par becomes Ptr_Glob */
440
 
441
        Rec_Pointer    *Ptr_Ref_Par;
442
 
443
{
444
 
445
        if (Ptr_Glob != Null)
446
        /* then, executed */
447
        *Ptr_Ref_Par = Ptr_Glob->Ptr_Comp;
448
        Proc_7(10, Int_Glob, &Ptr_Glob->variant.var_1.Int_Comp);
449
}               /* Proc_3 */
450
 
451
 
452
void
453
  Proc_4()
454
{               /* without parameters */
455
        /*******/
456
        /* executed once */
457
        Boolean         Bool_Loc;
458
 
459
 
460
        Bool_Loc = Ch_1_Glob == 'A';
461
        Bool_Glob = Bool_Loc | Bool_Glob;
462
        Ch_2_Glob = 'B';
463
}               /* Proc_4 */
464
 
465
 
466
void
467
  Proc_5()
468
{               /* without parameters */
469
        /*******/
470
        /* executed once */
471
 
472
        Ch_1_Glob = 'A';
473
        Bool_Glob = false;
474
}               /* Proc_5 */
475
 
476
/* @(#)dhry_2.c 1.2 92/05/28 14:44:54, AMD */
477
/*
478
 ****************************************************************************
479
 *
480
 *                   "DHRYSTONE" Benchmark Program
481
 *                   -----------------------------
482
 *
483
 *  Version:    C, Version 2.1
484
 *
485
 *  File:       dhry_2.c (part 3 of 3)
486
 *
487
 *  Date:       May 25, 1988
488
 *
489
 *  Author:     Reinhold P. Weicker
490
 *
491
 ****************************************************************************
492
 */
493
 
494
#ifndef REG
495
#define REG
496
 /* REG becomes defined as empty */
497
 /* i.e. no register variables   */
498
#ifdef _AM29K
499
#undef REG
500
#define REG register    /* Define REG; saves room on 127-char MS-DOS cmd line */
501
#endif
502
#endif
503
 
504
 
505
void
506
  Proc_6(Enum_Val_Par, Enum_Ref_Par)
507
/*********************************/
508
 /* executed once */
509
 /* Enum_Val_Par == Ident_3, Enum_Ref_Par becomes Ident_2 */
510
 
511
    Enumeration     Enum_Val_Par;
512
    Enumeration    *Enum_Ref_Par;
513
{
514
#if PROC_6
515
 
516
    *Enum_Ref_Par = Enum_Val_Par;
517
    if (!Func_3(Enum_Val_Par))
518
        /* then, not executed */
519
        *Enum_Ref_Par = Ident_4;
520
    switch (Enum_Val_Par) {
521
    case Ident_1:
522
        *Enum_Ref_Par = Ident_1;
523
        break;
524
    case Ident_2:
525
        if (Int_Glob > 100)
526
            /* then */
527
            *Enum_Ref_Par = Ident_1;
528
        else
529
            *Enum_Ref_Par = Ident_4;
530
        break;
531
    case Ident_3:               /* executed */
532
        *Enum_Ref_Par = Ident_2;
533
        break;
534
    case Ident_4:
535
        break;
536
    case Ident_5:
537
        *Enum_Ref_Par = Ident_3;
538
        break;
539
    }                           /* switch */
540
#endif
541
    return;
542
}                               /* Proc_6 */
543
 
544
void
545
  Proc_7(Int_1_Par_Val, Int_2_Par_Val, Int_Par_Ref)
546
/**********************************************/
547
 /* executed three times                                      */
548
 /* first call:      Int_1_Par_Val == 2, Int_2_Par_Val == 3,  */
549
 /* Int_Par_Ref becomes 7                    */
550
 /* second call:     Int_1_Par_Val == 10, Int_2_Par_Val == 5, */
551
 /* Int_Par_Ref becomes 17                   */
552
 /* third call:      Int_1_Par_Val == 6, Int_2_Par_Val == 10, */
553
 /* Int_Par_Ref becomes 18                   */
554
    One_Fifty       Int_1_Par_Val;
555
    One_Fifty       Int_2_Par_Val;
556
    One_Fifty      *Int_Par_Ref;
557
{
558
    One_Fifty       Int_Loc;
559
 
560
 
561
    Int_Loc = Int_1_Par_Val + 2;
562
    *Int_Par_Ref = Int_2_Par_Val + Int_Loc;
563
}                               /* Proc_7 */
564
 
565
 
566
void
567
  Proc_8(Arr_1_Par_Ref, Arr_2_Par_Ref, Int_1_Par_Val, Int_2_Par_Val)
568
/*********************************************************************/
569
 /* executed once      */
570
 /* Int_Par_Val_1 == 3 */
571
 /* Int_Par_Val_2 == 7 */
572
    Arr_1_Dim       Arr_1_Par_Ref;
573
    Arr_2_Dim       Arr_2_Par_Ref;
574
    int             Int_1_Par_Val;
575
    int             Int_2_Par_Val;
576
{
577
    REG One_Fifty   Int_Index;
578
    REG One_Fifty   Int_Loc;
579
 
580
#if DBG
581
      printf("X) Int_1_Par_Val: %x\n", Int_1_Par_Val);
582
      printf("X) Int_2_Par_Val: %x\n", Int_2_Par_Val);
583
#endif
584
 
585
 
586
    Int_Loc = Int_1_Par_Val + 5;
587
    Arr_1_Par_Ref[Int_Loc] = Int_2_Par_Val;
588
    Arr_1_Par_Ref[Int_Loc + 1] = Arr_1_Par_Ref[Int_Loc];
589
    Arr_1_Par_Ref[Int_Loc + 30] = Int_Loc;
590
    for (Int_Index = Int_Loc; Int_Index <= Int_Loc + 1; ++Int_Index)
591
        Arr_2_Par_Ref[Int_Loc][Int_Index] = Int_Loc;
592
    Arr_2_Par_Ref[Int_Loc][Int_Loc - 1] += 1;
593
    Arr_2_Par_Ref[Int_Loc + 20][Int_Loc] = Arr_1_Par_Ref[Int_Loc];
594
    Int_Glob = 5;
595
 
596
#if DBG
597
      printf("Y) Int_1_Par_Val: %x\n", Int_1_Par_Val);
598
      printf("Y) Int_2_Par_Val: %x\n", Int_2_Par_Val);
599
#endif
600
 
601
}                               /* Proc_8 */
602
 
603
 
604
Enumeration
605
  Func_1(Ch_1_Par_Val, Ch_2_Par_Val)
606
/*************************************************/
607
 /* executed three times                                         */
608
 /* first call:      Ch_1_Par_Val == 'H', Ch_2_Par_Val == 'R'    */
609
 /* second call:     Ch_1_Par_Val == 'A', Ch_2_Par_Val == 'C'    */
610
 /* third call:      Ch_1_Par_Val == 'B', Ch_2_Par_Val == 'C'    */
611
 
612
    Capital_Letter  Ch_1_Par_Val;
613
    Capital_Letter  Ch_2_Par_Val;
614
{
615
    Capital_Letter  Ch_1_Loc;
616
    Capital_Letter  Ch_2_Loc;
617
 
618
 
619
    Ch_1_Loc = Ch_1_Par_Val;
620
    Ch_2_Loc = Ch_1_Loc;
621
    if (Ch_2_Loc != Ch_2_Par_Val)
622
        /* then, executed */
623
        return (Ident_1);
624
    else {                      /* not executed */
625
        Ch_1_Glob = Ch_1_Loc;
626
        return (Ident_2);
627
    }
628
}                               /* Func_1 */
629
 
630
 
631
Boolean
632
  Func_2(Str_1_Par_Ref, Str_2_Par_Ref)
633
/*************************************************/
634
 /* executed once */
635
 /* Str_1_Par_Ref == "DHRYSTONE PROGRAM, 1'ST STRING" */
636
 /* Str_2_Par_Ref == "DHRYSTONE PROGRAM, 2'ND STRING" */
637
 
638
    Str_30          Str_1_Par_Ref;
639
    Str_30          Str_2_Par_Ref;
640
{
641
    REG One_Thirty  Int_Loc;
642
    Capital_Letter  Ch_Loc = 0;
643
 
644
 
645
    Int_Loc = 2;
646
    while (Int_Loc <= 2)        /* loop body executed once */
647
        if (Func_1(Str_1_Par_Ref[Int_Loc],
648
                   Str_2_Par_Ref[Int_Loc + 1]) == Ident_1)
649
            /* then, executed */
650
        {
651
            Ch_Loc = 'A';
652
            Int_Loc += 1;
653
        }                       /* if, while */
654
 
655
    if (Ch_Loc >= 'W' && Ch_Loc < 'Z')
656
        /* then, not executed */
657
        Int_Loc = 7;
658
    if (Ch_Loc == 'R')
659
        /* then, not executed */
660
        return (true);
661
    else {                      /* executed */
662
        if (strcmp(Str_1_Par_Ref, Str_2_Par_Ref) > 0)
663
            /* then, not executed */
664
        {
665
            Int_Loc += 7;
666
            Int_Glob = Int_Loc;
667
            return (true);
668
        } else                  /* executed */
669
            return (false);
670
    }                           /* if Ch_Loc */
671
}                               /* Func_2 */
672
 
673
 
674
Boolean
675
  Func_3(Enum_Par_Val)
676
/***************************/
677
 /* executed once        */
678
 /* Enum_Par_Val == Ident_3 */
679
    Enumeration     Enum_Par_Val;
680
{
681
    Enumeration     Enum_Loc;
682
 
683
    Enum_Loc = Enum_Par_Val;
684
    if (Enum_Loc == Ident_3)
685
        /* then, executed */
686
        return (true);
687
    else                        /* not executed */
688
        return (false);
689
}                               /* Func_3 */
690
 
691
int dhry_cmd (int argc, char *argv[])
692
{
693
  if (argc == 1) dhry_main(strtoul (argv[0], 0, 0));
694
  else if (argc == 0) dhry_main(20);
695
  else return -1;
696
  return 0;
697
}
698
 
699
void module_dhry_init (void)
700
{
701
  register_command ("dhry", "[<num_runs>]", "run dhrystone", dhry_cmd);
702
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.