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

Subversion Repositories eco32

[/] [eco32/] [trunk/] [stdalone/] [dhrystone/] [dhry_2.c] - Blame information for rev 323

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

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

powered by: WebSVN 2.1.0

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