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

Subversion Repositories amber

[/] [amber/] [trunk/] [sw/] [dhry/] [dhry_2.c] - Blame information for rev 31

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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