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

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [sw/] [example/] [dhrystone/] [dhry_1.c] - Blame information for rev 65

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_1.c (part 2 of 3)
10
 *
11
 *  Date:       May 25, 1988
12
 *
13
 *  Author:     Reinhold P. Weicker
14
 *
15
 ****************************************************************************
16
 */
17
 
18
/*
19
  Original from https://github.com/sifive/benchmark-dhrystone
20
  Modified for the NEORV32 Processor
21
*/
22
 
23
#define TIME
24
 
25
#include <neorv32.h>
26
#include <string.h>
27
#include "dhry.h"
28
 
29
 
30
#ifndef DHRY_ITERS
31 65 zero_gravi
#define DHRY_ITERS 10000
32 63 zero_gravi
#endif
33
 
34
/* Global Variables: */
35
 
36
Rec_Pointer     Ptr_Glob,
37
                Next_Ptr_Glob;
38
int             Int_Glob;
39
Boolean         Bool_Glob;
40
char            Ch_1_Glob,
41
                Ch_2_Glob;
42
int             Arr_1_Glob [50];
43
int             Arr_2_Glob [50] [50];
44
 
45
//extern char     *malloc ();
46
Enumeration     Func_1 ();
47
  /* forward declaration necessary since Enumeration may not simply be int */
48
 
49
#ifndef REG
50
        Boolean Reg = false;
51
#define REG
52
        /* REG becomes defined as empty */
53
        /* i.e. no register variables   */
54
#else
55
        Boolean Reg = true;
56
#endif
57
 
58
/* variables for time measurement: */
59
 
60
#ifdef TIMES
61
struct tms      time_info;
62
extern  int     times ();
63
                /* see library function "times" */
64
#define Too_Small_Time (2*HZ)
65
                /* Measurements should last at least about 2 seconds */
66
#endif
67
#ifdef TIME
68
extern long     time();
69
                /* see library function "time"  */
70
#define Too_Small_Time 2
71
                /* Measurements should last at least 2 seconds */
72
#endif
73
#ifdef MSC_CLOCK
74
extern clock_t  clock();
75
#define Too_Small_Time (2*HZ)
76
#endif
77
 
78
long            Begin_Time,
79
                End_Time,
80
                User_Time;
81
float           Microseconds,
82
                Dhrystones_Per_Second;
83
 
84
/* end of variables for time measurement */
85
 
86
 
87
int main (void)
88
/*****/
89
 
90
  /* main program, corresponds to procedures        */
91
  /* Main and Proc_0 in the Ada version             */
92
{
93
        One_Fifty       Int_1_Loc;
94
  REG   One_Fifty       Int_2_Loc;
95
        One_Fifty       Int_3_Loc;
96
  REG   char            Ch_Index;
97
        Enumeration     Enum_Loc;
98
        Str_30          Str_1_Loc;
99
        Str_30          Str_2_Loc;
100
  REG   int             Run_Index;
101
  REG   int             Number_Of_Runs;
102
 
103
 
104
  { /* *****  NEORV32-SPECIFIC ***** */
105
    neorv32_cpu_dint(); // no interrupt, thanks
106
    neorv32_rte_setup(); // capture all exceptions and give debug information, ho hw flow control
107 65 zero_gravi
    neorv32_uart0_setup(19200, PARITY_NONE, FLOW_CONTROL_NONE);
108 63 zero_gravi
    // check available hardware extensions and compare with compiler flags
109
    neorv32_rte_check_isa(0); // silent = 0 -> show message if isa mismatch
110
 
111 65 zero_gravi
    neorv32_uart0_printf("NEORV32: Processor running at %u Hz\n", (uint32_t)NEORV32_SYSINFO.CLK);
112
    neorv32_uart0_printf("NEORV32: Executing Dhrystone (%u iterations). This may take some time...\n\n", (uint32_t)DHRY_ITERS);
113 63 zero_gravi
 
114
    // clear cycle counter
115
    neorv32_cpu_set_mcycle(0);
116
 
117
#ifndef RUN_DHRYSTONE
118
    #warning DHRYSTONE HAS NOT BEEN COMPILED! Use >>make USER_FLAGS+=-DRUN_DHRYSTONE clean_all exe<< to compile it.
119
 
120
    // inform the user if you are actually executing this
121 65 zero_gravi
    neorv32_uart0_printf("ERROR! CoreMark has not been compiled. Use >>make USER_FLAGS+=-DRUN_COREMARK clean_all exe<< to compile it.\n");
122 63 zero_gravi
 
123
    while(1);
124
#endif
125
  } /* ***** /NEORV32-SPECIFIC ***** */
126
 
127
 
128
  /* Initializations */
129
  { /* *****  NEORV32-SPECIFIC ***** */
130
    // use static memory allocation, no dynamic malloc
131
    //Next_Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));
132
    //Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));
133
    static Rec_Type Rec_Type_v0, Rec_Type_v1;
134
    Next_Ptr_Glob = &Rec_Type_v0;
135
    Ptr_Glob = &Rec_Type_v1;
136
  } /* ***** /NEORV32-SPECIFIC ***** */
137
 
138
 
139
  Ptr_Glob->Ptr_Comp                    = Next_Ptr_Glob;
140
  Ptr_Glob->Discr                       = Ident_1;
141
  Ptr_Glob->variant.var_1.Enum_Comp     = Ident_3;
142
  Ptr_Glob->variant.var_1.Int_Comp      = 40;
143
  strcpy (Ptr_Glob->variant.var_1.Str_Comp,
144
          "DHRYSTONE PROGRAM, SOME STRING");
145
  strcpy (Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING");
146
 
147
  Arr_2_Glob [8][7] = 10;
148
        /* Was missing in published program. Without this statement,    */
149
        /* Arr_2_Glob [8][7] would have an undefined value.             */
150
        /* Warning: With 16-Bit processors and Number_Of_Runs > 32000,  */
151
        /* overflow may occur for this array element.                   */
152
 
153 65 zero_gravi
  neorv32_uart0_printf ("\n");
154
  neorv32_uart0_printf ("Dhrystone Benchmark, Version 2.1 (Language: C)\n");
155
  neorv32_uart0_printf ("\n");
156 63 zero_gravi
  if (Reg)
157
  {
158 65 zero_gravi
    neorv32_uart0_printf ("Program compiled with 'register' attribute\n");
159
    neorv32_uart0_printf ("\n");
160 63 zero_gravi
  }
161
  else
162
  {
163 65 zero_gravi
    neorv32_uart0_printf ("Program compiled without 'register' attribute\n");
164
    neorv32_uart0_printf ("\n");
165 63 zero_gravi
  }
166
#ifdef DHRY_ITERS
167
  Number_Of_Runs = DHRY_ITERS;
168
#else
169 65 zero_gravi
  neorv32_uart0_printf ("Please give the number of runs through the benchmark: ");
170 63 zero_gravi
  {
171
    int n;
172
    scanf ("%d", &n);
173
    Number_Of_Runs = n;
174
  }
175 65 zero_gravi
  neorv32_uart0_printf ("\n");
176 63 zero_gravi
#endif
177
 
178 65 zero_gravi
  neorv32_uart0_printf ("Execution starts, %u runs through Dhrystone\n", (uint32_t)Number_Of_Runs);
179 63 zero_gravi
 
180
  /***************/
181
  /* Start timer */
182
  /***************/
183
 
184
/*
185
#ifdef TIMES
186
  times (&time_info);
187
  Begin_Time = (long) time_info.tms_utime;
188
#endif
189
#ifdef TIME
190
  Begin_Time = time ( (long *) 0);
191
#endif
192
#ifdef MSC_CLOCK
193
  Begin_Time = clock();
194
#endif
195
*/
196
 
197
  { /* *****  NEORV32-SPECIFIC ***** */
198
    Begin_Time = (long)neorv32_cpu_get_systime();
199
  } /* ***** /NEORV32-SPECIFIC ***** */
200
 
201
  for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index)
202
  {
203
 
204
    Proc_5();
205
    Proc_4();
206
      /* Ch_1_Glob == 'A', Ch_2_Glob == 'B', Bool_Glob == true */
207
    Int_1_Loc = 2;
208
    Int_2_Loc = 3;
209
    strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
210
    Enum_Loc = Ident_2;
211
    Bool_Glob = ! Func_2 (Str_1_Loc, Str_2_Loc);
212
      /* Bool_Glob == 1 */
213
    while (Int_1_Loc < Int_2_Loc)  /* loop body executed once */
214
    {
215
      Int_3_Loc = 5 * Int_1_Loc - Int_2_Loc;
216
        /* Int_3_Loc == 7 */
217
      Proc_7 (Int_1_Loc, Int_2_Loc, &Int_3_Loc);
218
        /* Int_3_Loc == 7 */
219
      Int_1_Loc += 1;
220
    } /* while */
221
      /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
222
    Proc_8 (Arr_1_Glob, Arr_2_Glob, Int_1_Loc, Int_3_Loc);
223
      /* Int_Glob == 5 */
224
    Proc_1 (Ptr_Glob);
225
    for (Ch_Index = 'A'; Ch_Index <= Ch_2_Glob; ++Ch_Index)
226
                             /* loop body executed twice */
227
    {
228
      if (Enum_Loc == Func_1 (Ch_Index, 'C'))
229
          /* then, not executed */
230
        {
231
        Proc_6 (Ident_1, &Enum_Loc);
232
        strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING");
233
        Int_2_Loc = Run_Index;
234
        Int_Glob = Run_Index;
235
        }
236
    }
237
      /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
238
    Int_2_Loc = Int_2_Loc * Int_1_Loc;
239
    Int_1_Loc = Int_2_Loc / Int_3_Loc;
240
    Int_2_Loc = 7 * (Int_2_Loc - Int_3_Loc) - Int_1_Loc;
241
      /* Int_1_Loc == 1, Int_2_Loc == 13, Int_3_Loc == 7 */
242
    Proc_2 (&Int_1_Loc);
243
      /* Int_1_Loc == 5 */
244
 
245
  } /* loop "for Run_Index" */
246
 
247
  /**************/
248
  /* Stop timer */
249
  /**************/
250
 
251
/*
252
#ifdef TIMES
253
  times (&time_info);
254
  End_Time = (long) time_info.tms_utime;
255
#endif
256
#ifdef TIME
257
  End_Time = time ( (long *) 0);
258
#endif
259
#ifdef MSC_CLOCK
260
  End_Time = clock();
261
#endif
262
*/
263
 
264
  { /* *****  NEORV32-SPECIFIC ***** */
265
    End_Time = (long)neorv32_cpu_get_systime();
266
  } /* ***** /NEORV32-SPECIFIC ***** */
267
 
268
 
269 65 zero_gravi
  neorv32_uart0_printf ("Execution ends\n");
270
  neorv32_uart0_printf ("\n");
271
  neorv32_uart0_printf ("Final values of the variables used in the benchmark:\n");
272
  neorv32_uart0_printf ("\n");
273
  neorv32_uart0_printf ("Int_Glob:            %u\n", (uint32_t)Int_Glob);
274
  neorv32_uart0_printf ("        should be:   %u\n", 5);
275
  neorv32_uart0_printf ("Bool_Glob:           %u\n", (uint32_t)Bool_Glob);
276
  neorv32_uart0_printf ("        should be:   %u\n", 1);
277
  neorv32_uart0_printf ("Ch_1_Glob:           %c\n", (uint32_t)Ch_1_Glob);
278
  neorv32_uart0_printf ("        should be:   %c\n", 'A');
279
  neorv32_uart0_printf ("Ch_2_Glob:           %c\n", (uint32_t)Ch_2_Glob);
280
  neorv32_uart0_printf ("        should be:   %c\n", 'B');
281
  neorv32_uart0_printf ("Arr_1_Glob[8]:       %u\n", (uint32_t)Arr_1_Glob[8]);
282
  neorv32_uart0_printf ("        should be:   %u\n", 7);
283
  neorv32_uart0_printf ("Arr_2_Glob[8][7]:    %u\n", (uint32_t)Arr_2_Glob[8][7]);
284
  neorv32_uart0_printf ("        should be:   Number_Of_Runs + 10\n");
285
  neorv32_uart0_printf ("Ptr_Glob->\n");
286
  neorv32_uart0_printf ("  Ptr_Comp:          %u\n", (uint32_t) Ptr_Glob->Ptr_Comp);
287
  neorv32_uart0_printf ("        should be:   (implementation-dependent)\n");
288
  neorv32_uart0_printf ("  Discr:             %u\n", (uint32_t)Ptr_Glob->Discr);
289
  neorv32_uart0_printf ("        should be:   %u\n", 0);
290
  neorv32_uart0_printf ("  Enum_Comp:         %u\n", (uint32_t)Ptr_Glob->variant.var_1.Enum_Comp);
291
  neorv32_uart0_printf ("        should be:   %u\n", 2);
292
  neorv32_uart0_printf ("  Int_Comp:          %u\n", (uint32_t)Ptr_Glob->variant.var_1.Int_Comp);
293
  neorv32_uart0_printf ("        should be:   %u\n", 17);
294
  neorv32_uart0_printf ("  Str_Comp:          %s\n", Ptr_Glob->variant.var_1.Str_Comp);
295
  neorv32_uart0_printf ("        should be:   DHRYSTONE PROGRAM, SOME STRING\n");
296
  neorv32_uart0_printf ("Next_Ptr_Glob->\n");
297
  neorv32_uart0_printf ("  Ptr_Comp:          %u\n", (uint32_t) Next_Ptr_Glob->Ptr_Comp);
298
  neorv32_uart0_printf ("        should be:   (implementation-dependent), same as above\n");
299
  neorv32_uart0_printf ("  Discr:             %u\n", (uint32_t)Next_Ptr_Glob->Discr);
300
  neorv32_uart0_printf ("        should be:   %u\n", 0);
301
  neorv32_uart0_printf ("  Enum_Comp:         %u\n", (uint32_t)Next_Ptr_Glob->variant.var_1.Enum_Comp);
302
  neorv32_uart0_printf ("        should be:   %u\n", 1);
303
  neorv32_uart0_printf ("  Int_Comp:          %u\n", (uint32_t)Next_Ptr_Glob->variant.var_1.Int_Comp);
304
  neorv32_uart0_printf ("        should be:   %u\n", 18);
305
  neorv32_uart0_printf ("  Str_Comp:          %s\n",
306 63 zero_gravi
                                Next_Ptr_Glob->variant.var_1.Str_Comp);
307 65 zero_gravi
  neorv32_uart0_printf ("        should be:   DHRYSTONE PROGRAM, SOME STRING\n");
308
  neorv32_uart0_printf ("Int_1_Loc:           %u\n", (uint32_t)Int_1_Loc);
309
  neorv32_uart0_printf ("        should be:   %u\n", 5);
310
  neorv32_uart0_printf ("Int_2_Loc:           %u\n", (uint32_t)Int_2_Loc);
311
  neorv32_uart0_printf ("        should be:   %u\n", 13);
312
  neorv32_uart0_printf ("Int_3_Loc:           %u\n", (uint32_t)Int_3_Loc);
313
  neorv32_uart0_printf ("        should be:   %u\n", 7);
314
  neorv32_uart0_printf ("Enum_Loc:            %u\n", (uint32_t)Enum_Loc);
315
  neorv32_uart0_printf ("        should be:   %u\n", 1);
316
  neorv32_uart0_printf ("Str_1_Loc:           %s\n", Str_1_Loc);
317
  neorv32_uart0_printf ("        should be:   DHRYSTONE PROGRAM, 1'ST STRING\n");
318
  neorv32_uart0_printf ("Str_2_Loc:           %s\n", Str_2_Loc);
319
  neorv32_uart0_printf ("        should be:   DHRYSTONE PROGRAM, 2'ND STRING\n");
320
  neorv32_uart0_printf ("\n");
321 63 zero_gravi
 
322
  User_Time = End_Time - Begin_Time;
323
 
324
//  if (User_Time < Too_Small_Time)
325
//  {
326 65 zero_gravi
//    neorv32_uart0_printf ("Measured time too small to obtain meaningful results\n");
327
//    neorv32_uart0_printf ("Please increase number of runs\n");
328
//    neorv32_uart0_printf ("\n");
329 63 zero_gravi
//  }
330
//  else
331
  {
332
/*
333
#ifdef TIME
334
    Microseconds = (float) User_Time * Mic_secs_Per_Second
335
                        / (float) Number_Of_Runs;
336
    Dhrystones_Per_Second = (float) Number_Of_Runs / (float) User_Time;
337
#else
338
    Microseconds = (float) User_Time * Mic_secs_Per_Second
339
                        / ((float) HZ * ((float) Number_Of_Runs));
340
    Dhrystones_Per_Second = ((float) HZ * (float) Number_Of_Runs)
341
                        / (float) User_Time;
342
#endif
343
*/
344 65 zero_gravi
    { /* *****  NEORV32-SPECIFIC ***** */
345
      neorv32_uart0_printf ("Microseconds for one run through Dhrystone: %u \n", (uint32_t)((User_Time * (Mic_secs_Per_Second / Number_Of_Runs)) / NEORV32_SYSINFO.CLK));
346 63 zero_gravi
 
347 65 zero_gravi
      uint32_t dhry_per_sec = (uint32_t)(NEORV32_SYSINFO.CLK / (User_Time / Number_Of_Runs));
348 63 zero_gravi
 
349 65 zero_gravi
      neorv32_uart0_printf ("Dhrystones per Second:                      %u \n\n", (uint32_t)dhry_per_sec);
350 63 zero_gravi
 
351 65 zero_gravi
      neorv32_uart0_printf("NEORV32: << DETAILED RESULTS (integer parts only) >>\n");
352
      neorv32_uart0_printf("NEORV32: Total cycles:      %u\n", (uint32_t)User_Time);
353
      neorv32_uart0_printf("NEORV32: Cycles per second: %u\n", (uint32_t)NEORV32_SYSINFO.CLK);
354
      neorv32_uart0_printf("NEORV32: Total runs:        %u\n", (uint32_t)Number_Of_Runs);
355 63 zero_gravi
 
356 65 zero_gravi
      neorv32_uart0_printf("\n");
357
      neorv32_uart0_printf("NEORV32: DMIPS/s:           %u\n", (uint32_t)dhry_per_sec);
358
      neorv32_uart0_printf("NEORV32: DMIPS/s/MHz:       %u\n", (uint32_t)(dhry_per_sec / (NEORV32_SYSINFO.CLK / 1000000)));
359
 
360
      neorv32_uart0_printf("\n");
361
      neorv32_uart0_printf("NEORV32: VAX DMIPS/s:       %u\n", (uint32_t)dhry_per_sec/1757);
362
      neorv32_uart0_printf("NEORV32: VAX DMIPS/s/MHz:   %u/1757\n", (uint32_t)(dhry_per_sec / (NEORV32_SYSINFO.CLK / 1000000)));
363
    } /* ***** /NEORV32-SPECIFIC ***** */
364
    /*
365
      neorv32_uart0_printf ("Microseconds for one run through Dhrystone: ");
366
      //neorv32_uart0_printf ("%6.1f \n", Microseconds);
367
      neorv32_uart0_printf ("%d \n", (int)Microseconds);
368
      neorv32_uart0_printf ("Dhrystones per Second:                      ");
369
      //neorv32_uart0_printf ("%6.1f \n", Dhrystones_Per_Second);
370
      neorv32_uart0_printf ("%d \n", (int)Dhrystones_Per_Second);
371
      neorv32_uart0_printf ("\n");
372
    */
373 63 zero_gravi
  }
374
 
375
  return 0;
376
}
377
 
378
 
379
void Proc_1 (Ptr_Val_Par)
380
/******************/
381
 
382
REG Rec_Pointer Ptr_Val_Par;
383
    /* executed once */
384
{
385
  REG Rec_Pointer Next_Record = Ptr_Val_Par->Ptr_Comp;
386
                                        /* == Ptr_Glob_Next */
387
  /* Local variable, initialized with Ptr_Val_Par->Ptr_Comp,    */
388
  /* corresponds to "rename" in Ada, "with" in Pascal           */
389
 
390
  structassign (*Ptr_Val_Par->Ptr_Comp, *Ptr_Glob);
391
  Ptr_Val_Par->variant.var_1.Int_Comp = 5;
392
  Next_Record->variant.var_1.Int_Comp
393
        = Ptr_Val_Par->variant.var_1.Int_Comp;
394
  Next_Record->Ptr_Comp = Ptr_Val_Par->Ptr_Comp;
395
  Proc_3 (&Next_Record->Ptr_Comp);
396
    /* Ptr_Val_Par->Ptr_Comp->Ptr_Comp
397
                        == Ptr_Glob->Ptr_Comp */
398
  if (Next_Record->Discr == Ident_1)
399
    /* then, executed */
400
  {
401
    Next_Record->variant.var_1.Int_Comp = 6;
402
    Proc_6 (Ptr_Val_Par->variant.var_1.Enum_Comp,
403
           &Next_Record->variant.var_1.Enum_Comp);
404
    Next_Record->Ptr_Comp = Ptr_Glob->Ptr_Comp;
405
    Proc_7 (Next_Record->variant.var_1.Int_Comp, 10,
406
           &Next_Record->variant.var_1.Int_Comp);
407
  }
408
  else /* not executed */
409
    structassign (*Ptr_Val_Par, *Ptr_Val_Par->Ptr_Comp);
410
} /* Proc_1 */
411
 
412
 
413
void Proc_2 (Int_Par_Ref)
414
/******************/
415
    /* executed once */
416
    /* *Int_Par_Ref == 1, becomes 4 */
417
 
418
One_Fifty   *Int_Par_Ref;
419
{
420
  One_Fifty  Int_Loc;
421
  Enumeration   Enum_Loc;
422
 
423
  Int_Loc = *Int_Par_Ref + 10;
424
  do /* executed once */
425
    if (Ch_1_Glob == 'A')
426
      /* then, executed */
427
    {
428
      Int_Loc -= 1;
429
      *Int_Par_Ref = Int_Loc - Int_Glob;
430
      Enum_Loc = Ident_1;
431
    } /* if */
432
  while (Enum_Loc != Ident_1); /* true */
433
} /* Proc_2 */
434
 
435
 
436
void Proc_3 (Ptr_Ref_Par)
437
/******************/
438
    /* executed once */
439
    /* Ptr_Ref_Par becomes Ptr_Glob */
440
 
441
Rec_Pointer *Ptr_Ref_Par;
442
 
443
{
444
  if (Ptr_Glob != Null)
445
    /* then, executed */
446
    *Ptr_Ref_Par = Ptr_Glob->Ptr_Comp;
447
  Proc_7 (10, Int_Glob, &Ptr_Glob->variant.var_1.Int_Comp);
448
} /* Proc_3 */
449
 
450
 
451
void Proc_4 (void) /* without parameters */
452
/*******/
453
    /* executed once */
454
{
455
  Boolean Bool_Loc;
456
 
457
  Bool_Loc = Ch_1_Glob == 'A';
458
  Bool_Glob = Bool_Loc | Bool_Glob;
459
  Ch_2_Glob = 'B';
460
} /* Proc_4 */
461
 
462
 
463
void Proc_5 (void) /* without parameters */
464
/*******/
465
    /* executed once */
466
{
467
  Ch_1_Glob = 'A';
468
  Bool_Glob = false;
469
} /* Proc_5 */
470
 
471
 
472
        /* Procedure for the assignment of structures,          */
473
        /* if the C compiler doesn't support this feature       */
474
#ifdef  NOSTRUCTASSIGN
475
memcpy (d, s, l)
476
register char   *d;
477
register char   *s;
478
register int    l;
479
{
480
        while (l--) *d++ = *s++;
481
}
482
#endif
483
 
484
 
485
/* Compare S1 and S2, returning less than, equal to or
486
   greater than zero if S1 is lexicographically less than,
487
   equal to or greater than S2. [from glibc] */
488
int strcmp(const char *p1, const char *p2)
489
{
490
  const unsigned char *s1 = (const unsigned char *) p1;
491
  const unsigned char *s2 = (const unsigned char *) p2;
492
  unsigned char c1, c2;
493
  do
494
    {
495
      c1 = (unsigned char) *s1++;
496
      c2 = (unsigned char) *s2++;
497
      if (c1 == '\0')
498
        return c1 - c2;
499
    }
500
  while (c1 == c2);
501
  return c1 - c2;
502
}

powered by: WebSVN 2.1.0

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