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

Subversion Repositories openmsp430

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 olivier.gi
/*******************************************************************************
2
 * Copyright (c) 2004 by Graham Davies, ECROS Technology.  This work is        *
3
 * released into the Public Domain on condition that the forgoing copyright    *
4
 * notice is preserved in this and all derived files.                          *
5
 ******************************************************************************/
6
 
7
/*******************************************************************************
8
 * File: estubs.c - embedded stubs used to adapt the Dhrystone benchmark for
9
 * small (4 Kbyte RAM) microcontrollers.
10
 *
11
 * Last edited on $Date: Wednesday, June 09, 2004 1:05:22 PM $ by
12
 * $Author: Graham $ saved as $Revision: 1.5 $ $Version: NONE $
13
 ******************************************************************************/
14
 
15
#include <stdio.h>
16
#include <stdarg.h>
17
#include "dhry.h"
18
 
19
/*******************************************************************************
20
 * Function emalloc() - provides a dynamic memory allocation service sufficient
21
 * for two allocations of 50 bytes each or less.
22
 */
23
void * emalloc( size_t nbytes )
24
{
25
   static char   space[100];
26
   static char * ptr = space;
27
   static char * result;
28
 
29
   result = ptr;
30
   nbytes = (nbytes & 0xFFFC) + 4;
31
   ptr += nbytes;
32
 
33
   return ( result );
34
 
35
} /* end of function emalloc() */
36
 
37
/*******************************************************************************
38
 * Function fopen() - initialize an output port bit.
39
 */
40
FILE * fopen( const char * filename, const char * mode )
41
{
42
#if defined( __AVR_ARCH__ )
43
   DDRB = 0x01;    /* bit 0 output */
44
   PORTB = 0x00;   /* start low (zero) */
45
#elif defined( __ENCORE__ )
46
   PAADDR = 4;
47
   PACTL  = 0x01;  /* bit 0 high drive */
48
   PAADDR = 1;
49
   PACTL  = 0xFE;  /* bit 0 output */
50
   PAADDR = 0;
51
   PAOUT  = 0x00;  /* start low (zero) */
52
#endif
53
 
54
   return ( (FILE *)1 );
55
 
56
} /* end of function fopen() */
57
 
58
/*******************************************************************************
59
 * Function fclose() - stub; does nothing.
60
 */
61
int fclose( FILE * stream )
62
{
63
   return ( 0 );
64
 
65
} /* end of function fclose() */
66
 
67
/*******************************************************************************
68
 * Function scanf() - fake a value typed by the user.
69
 */
70
int scanf( const char * format, ... )
71
{
72
   va_list args;
73
   int *   ptr;
74
 
75
   va_start( args, format );
76
   ptr = va_arg( args, int * );
77
   *ptr = 30000;
78
   va_end( args );
79
 
80
   return ( 0 );
81
 
82
} /* end of function scanf() */
83
 
84
/* end of file estubs.c */

powered by: WebSVN 2.1.0

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