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

Subversion Repositories openrisc

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

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

powered by: WebSVN 2.1.0

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