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

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [sw/] [example/] [dhrystone/] [dhry_2.c] - Blame information for rev 63

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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