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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [sim/] [rtl_sim/] [src-c/] [dhrystone_4mcu/] [dhry21b.c] - Blame information for rev 145

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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